From a74b790ce0583d9b07a2c65a701be5a339de96b4 Mon Sep 17 00:00:00 2001 From: Brendan Irvine-Broque Date: Tue, 24 Nov 2026 09:39:39 -0800 Subject: [PATCH 1/7] refactor(cli): migrate runtime argument parsing to Stricli --- .changeset/stricli-parser.md | 7 + AGENTS.md | 2 +- docs/architecture.md | 21 +- packages/cli/AGENTS.md | 4 +- packages/cli/package.json | 4 +- .../generator/plugin/body-description.test.ts | 5 +- .../generator/plugin/body-positionals.test.ts | 12 +- .../__tests__/generator/plugin/emit.test.ts | 43 +- .../generator/plugin/json-shape.test.ts | 5 +- .../plugin/nested-array-flags.test.ts | 12 +- .../plugin/nested-body-overrides.test.ts | 12 +- .../generator/plugin/nested-unions.test.ts | 13 +- .../generator/plugin/oneof-body-flags.test.ts | 13 +- .../plugin/query-array-flags.test.ts | 12 +- .../plugin/required-raw-bodies.test.ts | 12 +- .../plugin/scalar-union-positionals.test.ts | 19 +- .../src/__tests__/helpers/command-parser.ts | 28 + .../lib/hand-written-dry-run.test.ts | 26 +- .../cli/src/__tests__/lib/stricli.test.ts | 32 + packages/cli/src/index.ts | 513 +++--------- packages/cli/src/lib/stricli.ts | 782 ++++++++++++++++++ pnpm-lock.yaml | 11 +- 22 files changed, 1034 insertions(+), 554 deletions(-) create mode 100644 .changeset/stricli-parser.md create mode 100644 packages/cli/src/__tests__/helpers/command-parser.ts create mode 100644 packages/cli/src/__tests__/lib/stricli.test.ts create mode 100644 packages/cli/src/lib/stricli.ts diff --git a/.changeset/stricli-parser.md b/.changeset/stricli-parser.md new file mode 100644 index 0000000000..7e2b23545c --- /dev/null +++ b/.changeset/stricli-parser.md @@ -0,0 +1,7 @@ +--- +"cf": minor +--- + +Parse CLI arguments with Stricli instead of yargs. + +Keep the existing command names and flags. Explicit boolean values must be `true` or `false`; malformed values such as `--force=maybe` are rejected before the command runs. diff --git a/AGENTS.md b/AGENTS.md index d23059b2a8..513d04dc78 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -124,7 +124,7 @@ In the rules below, `src/` means `packages/cli/src/`. - Keep the hand-written registry import-free plain data; root lazy loaders and telemetry belong in `root-commands.ts`. Keep each command's `meta.ts` sidecar and the typed `hand-written-meta.ts` list in sync. -- Let strict yargs own unknown-option validation. Keep emitter options and +- Keep unknown-option validation in the shared command parser. Keep emitter options and metadata synchronized. Reserve a new cross-cutting flag in `src/lib/global-options.ts` before introducing it; generation fails on any API field that would take a flag cf owns. diff --git a/docs/architecture.md b/docs/architecture.md index 6230c3eea7..756fac97ad 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -22,7 +22,7 @@ Paths below are relative to the repository root unless a section uses the cf/ ├── packages/cli/ # cf — CLI + generator │ ├── src/ -│ │ ├── index.ts # yargs entry; registers lazy-loaded generated +│ │ ├── index.ts # Stricli entry; registers lazy-loaded generated │ │ │ # commands + hand-written commands │ │ ├── dev.ts # tsx entry wrapper (maps CliExit → process.exit); │ │ │ # NOT the `cf dev` command @@ -210,7 +210,7 @@ the complete generated and hand-written `_meta/commands.json` catalogue (see | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Add/fix a generated command | Overlay files in `@cloudflare/forge` — NOT in this repo. Edit forge; Renovate picks up the next tagged release. | | Add a generated-command rule | `packages/cli/generator/plugin/` — emits handler body, arg shapes, body validation, confirm prompts, etc.; rerun `pnpm generate` | -| New cross-product flag | yargs middleware in `packages/cli/src/index.ts` (`--zone`, `--profile`, `--quiet`, `--local`, `--persist-to`) | +| New cross-product flag | startup hook in `packages/cli/src/index.ts` (`--zone`, `--profile`, `--quiet`, `--local`, `--persist-to`) | | Hand-written command | roots under `packages/cli/src/commands/{auth,build,cli,completions,dev,deploy,init,previews}/` plus `schema.ts` and `tools.ts`; generated-tree exceptions under `{access,ai,registrar,d1,observability,tunnels,workers}/`; register every one in `src/commands/hand-written.ts` | | Hand-written metadata/emit | per-command `meta.ts`, `packages/cli/src/commands/{hand-written,hand-written-meta,root-commands}.ts` | | `cf init` scaffold / setup | `packages/cli/src/commands/init/{index,workers,template}.ts` | @@ -220,7 +220,7 @@ the complete generated and hand-written `_meta/commands.json` catalogue (see | Auth / OAuth | `packages/cli/src/lib/auth.ts`, `packages/cli/src/lib/oauth/` | | `cloudflare.config.ts` settings | `packages/cli/src/lib/project-settings.ts` | | Global CLI state | `packages/cli/src/lib/state.ts` (shell-completion and telemetry state under workers-auth's canonical cf config directory) | -| Help formatting | yargs built-in (cf no longer overrides help) | +| Help formatting | declaration-driven renderer in `packages/cli/src/lib/stricli.ts` | | `--local` request routing | `packages/cli/src/lib/{local,local-runtime}.ts` | | Local-install delegation | `packages/cli/src/lib/delegate.ts` | | Output / spinner / errors | `packages/cli/src/lib/{output,progress,errors,prompt}.ts`, `lib/ui/` | @@ -269,7 +269,7 @@ the complete generated and hand-written `_meta/commands.json` catalogue (see | `ui/theme.ts` | background-neutral semantic colour palette and Chalk wrapper | | `ui/format.ts` | one-line `success`, `warning`, and `hint` helpers | | `ui/log.ts` | stderr messages: clack notices (hidden by `--quiet`), warnings and flow lines, each notice or warning optionally followed by copyable commands; not re-exported from `ui/index.ts` | -| `input-validation.ts` | yargs-time arg coercion + `resolveFileToken(value, fieldName, format)` for `@` ingestion; runtime body/path validation | +| `input-validation.ts` | parse-time arg coercion + `resolveFileToken(value, fieldName, format)` for `@` ingestion; runtime body/path validation | | `resolve.ts` | URL templating (path-param substitution), `isId`, `isValidDomainName` | ## Critical Invariants @@ -357,7 +357,7 @@ Practical extensions of this rule: ### Lazy command registration -Each generated top-level root and each hand-written root is registered via `lazyCommand` (`src/lib/lazy-command.ts`). The outer shell exposes only the `command` + `describe` strings yargs needs; selecting a root dynamically imports its root module/chunk. Within that selected generated root, index files statically import and register the full subtree. Without the outer lazy boundary, `cf --help` / `cf --version` / any command would eagerly load every generated root, the complete command catalogue, the API client, and every helper. +Each generated top-level root and each hand-written root is registered via `lazyCommand` (`src/lib/lazy-command.ts`). The outer shell exposes only the `command` + `describe` strings the router needs; selecting a root dynamically imports its root module/chunk. Within that selected generated root, index files statically import and register the full subtree. Without the outer lazy boundary, `cf --help` / `cf --version` / any command would eagerly load every generated root, the complete command catalogue, the API client, and every helper. Vite+ Pack preserves those dynamic root imports as code-split chunks (and may factor shared dependencies into additional chunks), so do not assume a strict one-chunk-per-root correspondence. Don't reintroduce eager top-level imports of `_generated/index.ts` from anywhere besides the lazy shell registration in `src/index.ts`. @@ -577,7 +577,7 @@ to know before editing `generator/plugin/`. fail with a clear "--body is required" error instead of an opaque EOF API error. - Per-field-flag `demandOption: true` is suppressed when `--body` is - also supported (so `--body @file` isn't rejected by yargs for + also supported (so `--body @file` isn't rejected during parsing for missing required fields — handler-time enforcement instead). - Required body positionals remain mandatory when `--body` is supplied, even when the JSON contains the same fields. Body positionals merge into JSON @@ -755,10 +755,9 @@ break at sunset; surfacing them encourages users to adopt doomed paths. each accepted body in one request. No automatic batching is inferred from schema limits. -### Strict yargs +### Argument parsing -`yargs.strict()` handles unknown flags. There are no pre-yargs -allowlists — yargs is authoritative. Keep it that way. +`src/lib/stricli.ts` collects the selected command’s builder declarations, resolves aliases, and constructs a Stricli command for the flags and positionals. Unknown options are rejected before startup unless the command explicitly accepts dynamic flags or forwards arguments. Keep the declarations authoritative; do not add product-specific allowlists to the parser. Generated and hand-written modules retain the yargs builder **types**, not the runtime dependency. ### Output @@ -802,7 +801,7 @@ pass its `cursor` value to `cf zero-trust casb findings list --cursor `. Required fields inside an optional request-body object are validated only when a flag supplies that object. Omitting the object leaves those nested fields -optional. Because yargs performs this validation before the handler, missing +optional. Because the parser performs this validation before the handler, missing fields in a supplied optional object are rejected rather than prompted for. For other required body fields, when stdin is a TTY and the field is not supplied: @@ -867,7 +866,7 @@ These have stabilised this repo's voice; preserve them. (the commands passed to `log.info` / `log.warn`); other commands in a message are styled as code. `--quiet` hides notices and success lines, never warnings, fixes or prompts. -- **Splash screen:** bare `cf` prints the headline, a short getting-started list, and the docs link. Yargs owns root, group, and command help rendering. +- **Splash screen:** bare `cf` prints the headline, a short getting-started list, and the docs link. The cf declaration adapter renders root, group, and command help. ## Global Flags diff --git a/packages/cli/AGENTS.md b/packages/cli/AGENTS.md index 7cc598ec67..d44e9846c8 100644 --- a/packages/cli/AGENTS.md +++ b/packages/cli/AGENTS.md @@ -1,6 +1,6 @@ # cf (`packages/cli`) -Cloudflare CLI. Yargs-based, TypeScript, ESM, Node ≥ 22. +Cloudflare CLI. Stricli runtime with yargs-compatible command declarations, TypeScript, ESM, Node ≥ 22. This package IS the CLI. It also owns the generator that produces its per-API command surface: the forge plugin in `generator/plugin/`, which @@ -49,7 +49,7 @@ second consumer. | Global CLI state | `src/lib/state.ts` | | Local request routing | `src/lib/local.ts`, `src/lib/local-runtime.ts` | | Build/deploy conversion | `src/lib/{build-output,deploy-context,deploy-input}.ts` | -| Help labels and flag groups | yargs configuration in `src/index.ts` (no custom renderer) | +| Help labels and flag groups | declaration-driven help in `src/lib/stricli.ts` | | Generator output shape | `generator/plugin/` (rerun `pnpm generate`) | | Metadata JSON shape | `generator/plugin/files.ts` | | Shell completions | `src/commands/completions/index.ts` (`@bomb.sh/tab`, backed by complete `commands.json` metadata) | diff --git a/packages/cli/package.json b/packages/cli/package.json index 614c5eed3b..ea5922c01b 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -89,6 +89,7 @@ "@cloudflare/workers-auth": "0.18.8", "@cloudflare/workers-utils": "0.57.0", "@redocly/openapi-core": "2.82.0", + "@stricli/core": "1.3.0", "@types/node": "26.6.6", "@types/semver": "7.8.0", "@types/shell-quote": "^1.7.5", @@ -109,8 +110,7 @@ "tsx": "4.21.0", "undici": "8.13.0", "vite-plus": "catalog:", - "ws": "8.23.0", - "yargs": "18.2.0" + "ws": "8.23.0" }, "config": { "openApiVersion": "2f687dad103baa5342ddd1532a2463c5f268f37d" diff --git a/packages/cli/src/__tests__/generator/plugin/body-description.test.ts b/packages/cli/src/__tests__/generator/plugin/body-description.test.ts index e05c52e580..81204126a3 100644 --- a/packages/cli/src/__tests__/generator/plugin/body-description.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/body-description.test.ts @@ -1,9 +1,10 @@ import { stripTypeScriptTypes } from "node:module"; import { Script } from "node:vm"; import { describe, expect, it } from "vite-plus/test"; -import yargs, { type CommandModule } from "yargs"; import { generateFiles } from "../../helpers/cli-plugin.js"; +import { commandParser } from "../../helpers/command-parser.js"; import type { CommandMeta } from "../../../lib/command-meta.js"; +import type { CommandModule } from "yargs"; const JSON_BODY = "Raw JSON request body (bypasses individual flags)"; const PLAIN = "Send the workflow name as plain text, without JSON quotes."; @@ -41,7 +42,7 @@ async function bodyDescriptions(contentTypes: string[], description?: string) { .replace(/^import[\s\S]*?;\n/gm, "") .replace("export default command;", "command;"); const command = new Script(source).runInNewContext() as CommandModule; - const help = await yargs(["update"]).command(command).wrap(null).getHelp(); + const help = await commandParser(["update"], command).getHelp(); return { metadata: bodyDescription, help }; } diff --git a/packages/cli/src/__tests__/generator/plugin/body-positionals.test.ts b/packages/cli/src/__tests__/generator/plugin/body-positionals.test.ts index 3993f32a8b..c86a04e5dc 100644 --- a/packages/cli/src/__tests__/generator/plugin/body-positionals.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/body-positionals.test.ts @@ -2,11 +2,12 @@ import { stripTypeScriptTypes } from "node:module"; import { Script } from "node:vm"; import { runInTempDir, seed } from "@cloudflare/workers-utils/test-helpers"; import { beforeAll, describe, expect, it, vi } from "vite-plus/test"; -import yargs, { type CommandModule } from "yargs"; import * as bodyParser from "../../../lib/body-parser.js"; import { resolveFileToken } from "../../../lib/input-validation.js"; import { generateFiles } from "../../helpers/cli-plugin.js"; +import { commandParser } from "../../helpers/command-parser.js"; import type { CommandMeta } from "../../../lib/command-meta.js"; +import type { CommandModule } from "yargs"; function setup(code: string) { const send = vi.fn(async () => undefined); @@ -36,14 +37,7 @@ function setup(code: string) { createCommandClient, formatDryRun, run: async (args: string[]) => - yargs(["save", ...args]) - .exitProcess(false) - .command(command) - .strict() - .fail((message, error) => { - throw error ?? new Error(message); - }) - .parseAsync(), + commandParser(["save", ...args], command).parse(), }; } diff --git a/packages/cli/src/__tests__/generator/plugin/emit.test.ts b/packages/cli/src/__tests__/generator/plugin/emit.test.ts index 9c56bca21e..51b6e9e079 100644 --- a/packages/cli/src/__tests__/generator/plugin/emit.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/emit.test.ts @@ -1,7 +1,6 @@ import { stripTypeScriptTypes } from "node:module"; import { Script } from "node:vm"; import { describe, expect, it } from "vite-plus/test"; -import yargs, { type Argv } from "yargs"; import { builderLines } from "../../../../generator/plugin/emit/builder.js"; import { ACCOUNT_OR_ZONE_HELP, @@ -27,9 +26,11 @@ import { param, wire, } from "../../helpers/cli-plugin.js"; +import { commandParser } from "../../helpers/command-parser.js"; import type { Arg, ArgType } from "../../../../generator/plugin/args.js"; import type { Method } from "../../../../generator/plugin/commands.js"; import type { OperationInfo } from "../../../../generator/plugin/operation.js"; +import type { Argv } from "yargs"; describe("descriptions", () => { it("labels POST validation without claiming to create a resource", () => { @@ -367,7 +368,7 @@ describe("variant prompts", () => { }); describe("optional joined query enums", () => { - it("leaves an omitted optional array unset", () => { + it("leaves an omitted optional array unset", async () => { const ctx = context( method("list", "example-list"), "example", @@ -382,10 +383,18 @@ describe("optional joined query enums", () => { wire: wire({ joined: ["selector"] }), }) ); - const parser = new Script( - stripTypeScriptTypes(`yargs${builderLines(ctx).join("\n")}`) - ).runInNewContext({ yargs: yargs([]).exitProcess(false) }) as Argv; - expect(parser.parseSync().selector).toBeUndefined(); + const builder = new Script( + stripTypeScriptTypes(`(yargs) => yargs${builderLines(ctx).join("\n")}`) + ).runInNewContext() as (args: Argv) => Argv; + expect( + ( + await commandParser(["list"], { + command: "list", + builder, + handler() {}, + }).parse() + ).selector + ).toBeUndefined(); }); }); @@ -456,14 +465,7 @@ describe("optional body-object validation", () => { `(yargs) => yargs\n${builderLines(ctx).join("\n")}` ).runInNewContext() as (args: Argv) => Argv; const parse = async (args: string[]) => - yargs(args) - .exitProcess(false) - .fail((message, error) => { - throw error ?? new Error(message); - }) - .command("create", "", builder, () => {}) - .strict() - .parseAsync(); + commandParser(args, { command: "create", builder, handler() {} }).parse(); await expect( parse(["create", "--parameters-order-by-order", "asc"]) @@ -632,14 +634,11 @@ describe("Fern names", () => { `(yargs) => yargs\n${builderLines(ctx).join("\n")}` ).runInNewContext() as (args: Argv) => Argv; const parse = async (args: string[]) => - yargs(args) - .exitProcess(false) - .fail((message, error) => { - throw error ?? new Error(message); - }) - .command(command, "", builder, () => {}) - .strict() - .parseAsync(); + commandParser(args, { + command: command, + builder, + handler() {}, + }).parse(); expect( await parse(["get", "consumer-1", "--queue", "queue-1"]) ).toMatchObject({ consumer: "consumer-1", queue: "queue-1" }); diff --git a/packages/cli/src/__tests__/generator/plugin/json-shape.test.ts b/packages/cli/src/__tests__/generator/plugin/json-shape.test.ts index 96d0712941..35d683f79e 100644 --- a/packages/cli/src/__tests__/generator/plugin/json-shape.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/json-shape.test.ts @@ -1,11 +1,12 @@ import { stripTypeScriptTypes } from "node:module"; import { Script } from "node:vm"; import { describe, expect, it } from "vite-plus/test"; -import yargs, { type CommandModule } from "yargs"; import { jsonShape } from "../../../../generator/plugin/json-shape.js"; import { generateFiles } from "../../helpers/cli-plugin.js"; +import { commandParser } from "../../helpers/command-parser.js"; import type { CommandMeta } from "../../../lib/command-meta.js"; import type { ObjectType, Type } from "@cloudflare/forge/plugin"; +import type { CommandModule } from "yargs"; describe("JSON parameter shapes", () => { const files = generateFiles({ @@ -141,7 +142,7 @@ describe("JSON parameter shapes", () => { (field) => field.name === "actions" )?.description ).toBe(description); - const help = await yargs(["create"]).command(command).wrap(null).getHelp(); + const help = await commandParser(["create"], command).getHelp(); expect(help).toContain(description); }); diff --git a/packages/cli/src/__tests__/generator/plugin/nested-array-flags.test.ts b/packages/cli/src/__tests__/generator/plugin/nested-array-flags.test.ts index 64f61fa50d..e0701ce119 100644 --- a/packages/cli/src/__tests__/generator/plugin/nested-array-flags.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/nested-array-flags.test.ts @@ -2,7 +2,6 @@ import { stripTypeScriptTypes } from "node:module"; import { Script } from "node:vm"; import { runInTempDir, seed } from "@cloudflare/workers-utils/test-helpers"; import { describe, expect, it, vi } from "vite-plus/test"; -import yargs, { type CommandModule } from "yargs"; import { compactBody, parseBody, @@ -12,7 +11,9 @@ import { } from "../../../lib/body-parser.js"; import { resolveFileToken } from "../../../lib/input-validation.js"; import { generateFiles } from "../../helpers/cli-plugin.js"; +import { commandParser } from "../../helpers/command-parser.js"; import type { CommandMeta } from "../../../lib/command-meta.js"; +import type { CommandModule } from "yargs"; function generate(typed: boolean) { const schema = { @@ -137,14 +138,7 @@ describe.each([true, false])( ) => run(), }) as CommandModule; const parse = async (flags: string[]) => - yargs([method, "--name", "thing", ...flags]) - .exitProcess(false) - .command(command) - .strict() - .fail((message, error) => { - throw error ?? new Error(message); - }) - .parseAsync(); + commandParser([method, "--name", "thing", ...flags], command).parse(); return { parse, send, requestApi, formatDryRun }; }; diff --git a/packages/cli/src/__tests__/generator/plugin/nested-body-overrides.test.ts b/packages/cli/src/__tests__/generator/plugin/nested-body-overrides.test.ts index ce15449bfb..41e6c62fd6 100644 --- a/packages/cli/src/__tests__/generator/plugin/nested-body-overrides.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/nested-body-overrides.test.ts @@ -2,7 +2,6 @@ import { stripTypeScriptTypes } from "node:module"; import { Script } from "node:vm"; import { runInTempDir, seed } from "@cloudflare/workers-utils/test-helpers"; import { describe, expect, it, vi } from "vite-plus/test"; -import yargs, { type CommandModule } from "yargs"; import { derive } from "../../../../generator/plugin/args.js"; import { compactBody, parseBody } from "../../../lib/body-parser.js"; import { resolveFileToken } from "../../../lib/input-validation.js"; @@ -13,8 +12,10 @@ import { method, operation, } from "../../helpers/cli-plugin.js"; +import { commandParser } from "../../helpers/command-parser.js"; import type { Method } from "../../../../generator/plugin/commands.js"; import type { CommandMeta } from "../../../lib/command-meta.js"; +import type { CommandModule } from "yargs"; describe("exact body-field overrides", () => { const op = operation("post", "/things", { @@ -227,14 +228,7 @@ describe("emitted nested overrides and metadata", () => { ) => run(), }) as CommandModule; const parse = async (flags: string[]) => - yargs(["create", "--dry-run", ...flags]) - .exitProcess(false) - .command(command) - .strict() - .fail((message, error) => { - throw error ?? new Error(message); - }) - .parseAsync(); + commandParser(["create", "--dry-run", ...flags], command).parse(); for (const [flag, value] of [ ["settings-label", "child"], ["settings-sibling", "sibling"], diff --git a/packages/cli/src/__tests__/generator/plugin/nested-unions.test.ts b/packages/cli/src/__tests__/generator/plugin/nested-unions.test.ts index 252460025f..fca901408e 100644 --- a/packages/cli/src/__tests__/generator/plugin/nested-unions.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/nested-unions.test.ts @@ -1,7 +1,6 @@ import { stripTypeScriptTypes } from "node:module"; import { Script } from "node:vm"; import { beforeAll, describe, expect, it, vi } from "vite-plus/test"; -import yargs, { type CommandModule } from "yargs"; import { compactBody, parseBody, @@ -10,6 +9,8 @@ import { import { validateBodyUnions } from "../../../lib/body-unions.js"; import { resolveFileToken } from "../../../lib/input-validation.js"; import { generateFiles } from "../../helpers/cli-plugin.js"; +import { commandParser } from "../../helpers/command-parser.js"; +import type { CommandModule } from "yargs"; type Json = Record; const id = "b07a1f7c-1b34-4fba-9c57-f8033b913973"; @@ -113,15 +114,7 @@ function command(code: string) { return { send, preview, - run: async (argv: string[]) => - yargs(argv) - .exitProcess(false) - .command(module) - .strict() - .fail((message, error) => { - throw error ?? new Error(message); - }) - .parseAsync(), + run: async (argv: string[]) => commandParser(argv, module).parse(), }; } diff --git a/packages/cli/src/__tests__/generator/plugin/oneof-body-flags.test.ts b/packages/cli/src/__tests__/generator/plugin/oneof-body-flags.test.ts index 6f8856e565..5b3538a9a8 100644 --- a/packages/cli/src/__tests__/generator/plugin/oneof-body-flags.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/oneof-body-flags.test.ts @@ -1,7 +1,6 @@ import { stripTypeScriptTypes } from "node:module"; import { Script } from "node:vm"; import { describe, expect, it, vi } from "vite-plus/test"; -import yargs, { type CommandModule } from "yargs"; import { compactBody, parseBody, @@ -9,6 +8,8 @@ import { } from "../../../lib/body-parser.js"; import { resolveFileToken } from "../../../lib/input-validation.js"; import { generateFiles } from "../../helpers/cli-plugin.js"; +import { commandParser } from "../../helpers/command-parser.js"; +import type { CommandModule } from "yargs"; const network = { type: "object", @@ -139,15 +140,7 @@ function setup(code: string, initialFlags: string[] = []) { ) => run(), }) as CommandModule; const parse = async (flags: string[]) => - yargs(["create", ...initialFlags, ...flags]) - .locale("en") - .exitProcess(false) - .command(command) - .strict() - .fail((message, error) => { - throw error ?? new Error(message); - }) - .parseAsync(); + commandParser(["create", ...initialFlags, ...flags], command).parse(); return { parse, requestBody, formatDryRun }; } diff --git a/packages/cli/src/__tests__/generator/plugin/query-array-flags.test.ts b/packages/cli/src/__tests__/generator/plugin/query-array-flags.test.ts index bb49c92793..a6fd9de411 100644 --- a/packages/cli/src/__tests__/generator/plugin/query-array-flags.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/query-array-flags.test.ts @@ -1,11 +1,12 @@ import { stripTypeScriptTypes } from "node:module"; import { Script } from "node:vm"; import { describe, expect, it } from "vite-plus/test"; -import yargs, { type CommandModule } from "yargs"; import { Client, type Operation } from "../../../api/client.js"; import { path } from "../../../api/path.js"; import { generateFiles } from "../../helpers/cli-plugin.js"; +import { commandParser } from "../../helpers/command-parser.js"; import type { CommandsMetadata } from "../../../lib/command-meta.js"; +import type { CommandModule } from "yargs"; const enumValues = ["001", "a/b &c", "literal,comma"]; const enumSchema = { type: "string", enum: enumValues }; @@ -122,14 +123,7 @@ describe.each( task: () => Promise ) => task(), }) as CommandModule; - const argv = await yargs(["list", ...flags]) - .exitProcess(false) - .command(command) - .strict() - .fail((message, error) => { - throw error ?? new Error(message); - }) - .parseAsync(); + const argv = await commandParser(["list", ...flags], command).parse(); return { argv, urls }; } diff --git a/packages/cli/src/__tests__/generator/plugin/required-raw-bodies.test.ts b/packages/cli/src/__tests__/generator/plugin/required-raw-bodies.test.ts index f29268858b..88464ce105 100644 --- a/packages/cli/src/__tests__/generator/plugin/required-raw-bodies.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/required-raw-bodies.test.ts @@ -2,12 +2,13 @@ import { stripTypeScriptTypes } from "node:module"; import { Script } from "node:vm"; import { runInTempDir, seed } from "@cloudflare/workers-utils/test-helpers"; import { describe, expect, it, vi } from "vite-plus/test"; -import yargs, { type CommandModule } from "yargs"; import { readFileForFlag, resolveFileToken, } from "../../../lib/input-validation.js"; import { generateFiles } from "../../helpers/cli-plugin.js"; +import { commandParser } from "../../helpers/command-parser.js"; +import type { CommandModule } from "yargs"; function setup(files: Map, name = "update") { const source = stripTypeScriptTypes(files.get(`things/${name}.ts`) ?? "") @@ -47,14 +48,7 @@ function setup(files: Map, name = "update") { ) => task(), }) as CommandModule; const run = (flags: string[] = []) => - yargs([name, ...flags]) - .exitProcess(false) - .command(command) - .strict() - .fail((message, error) => { - throw error ?? new Error(message); - }) - .parseAsync(); + commandParser([name, ...flags], command).parse(); return { run, client, diff --git a/packages/cli/src/__tests__/generator/plugin/scalar-union-positionals.test.ts b/packages/cli/src/__tests__/generator/plugin/scalar-union-positionals.test.ts index e699c81883..9fa42deb8f 100644 --- a/packages/cli/src/__tests__/generator/plugin/scalar-union-positionals.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/scalar-union-positionals.test.ts @@ -2,7 +2,6 @@ import { stripTypeScriptTypes } from "node:module"; import { Script } from "node:vm"; import { runInTempDir, seed } from "@cloudflare/workers-utils/test-helpers"; import { describe, expect, it, vi } from "vite-plus/test"; -import yargs, { type Argv } from "yargs"; import { builderLines } from "../../../../generator/plugin/emit/builder.js"; import { handler, imports } from "../../../../generator/plugin/emit/handler.js"; import { context as emitContext } from "../../../../generator/plugin/emit/index.js"; @@ -18,6 +17,8 @@ import { operation, wire, } from "../../helpers/cli-plugin.js"; +import { commandParser } from "../../helpers/command-parser.js"; +import type { Argv } from "yargs"; describe.each([true, false])( "scalar-union positionals (typed request: %s)", @@ -85,18 +86,10 @@ describe.each([true, false])( ) => task(), formatOutput: () => {}, }) as (argv: Record) => Promise; - const argv = await yargs([ - "create", - ...args, - ...(dryRun ? ["--dry-run"] : []), - ]) - .exitProcess(false) - .command(command, "", builder, () => {}) - .strict() - .fail((message, error) => { - throw error ?? new Error(message); - }) - .parseAsync(); + const argv = await commandParser( + ["create", ...args, ...(dryRun ? ["--dry-run"] : [])], + { command: command, builder, handler() {} } + ).parse(); await run(argv); if (dryRun) { expect(formatDryRun).toHaveBeenCalledWith( diff --git a/packages/cli/src/__tests__/helpers/command-parser.ts b/packages/cli/src/__tests__/helpers/command-parser.ts new file mode 100644 index 0000000000..1cd302cf19 --- /dev/null +++ b/packages/cli/src/__tests__/helpers/command-parser.ts @@ -0,0 +1,28 @@ +import type { CommandModule } from "yargs"; +import { createParser } from "#lib/stricli.js"; + +export function commandParser( + args: string[], + command: CommandModule +) { + let parsed: Record = {}; + const parser = createParser(args, [command as unknown as CommandModule], { + resolve() {}, + helpWidth: Infinity, + help: (text) => text, + shown() {}, + fail(message) { + throw new Error(message); + }, + async startup(argv) { + parsed = argv; + }, + }); + return { + getHelp: parser.getHelp, + async parse() { + await parser.parse(); + return parsed; + }, + }; +} diff --git a/packages/cli/src/__tests__/lib/hand-written-dry-run.test.ts b/packages/cli/src/__tests__/lib/hand-written-dry-run.test.ts index 560856d959..f2e1fcba7e 100644 --- a/packages/cli/src/__tests__/lib/hand-written-dry-run.test.ts +++ b/packages/cli/src/__tests__/lib/hand-written-dry-run.test.ts @@ -1,6 +1,6 @@ import { afterEach, describe, expect, it, vi } from "vite-plus/test"; -import yargs from "yargs"; import { withHandWrittenDryRun } from "../../lib/hand-written-dry-run.js"; +import { commandParser } from "../helpers/command-parser.js"; import { generateFiles } from "../helpers/forge-cli.js"; import { runCf } from "../helpers/run-cf.js"; import type { OptionMeta } from "../../lib/metadata.js"; @@ -38,11 +38,10 @@ describe("hand-written dry runs", () => { let error: unknown; try { - await yargs(["group", "delete", "item-1", "--dry-run"]) - .command(group) - .strict() - .exitProcess(false) - .parseAsync(); + await commandParser( + ["group", "delete", "item-1", "--dry-run"], + group + ).parse(); } catch (caught) { error = caught; } @@ -76,11 +75,10 @@ describe("hand-written dry runs", () => { ); await expect(async () => { - await yargs(["dev", "--dry-run", "--token", "secret-value"]) - .command(command) - .strict() - .exitProcess(false) - .parseAsync(); + await commandParser( + ["dev", "--dry-run", "--token", "secret-value"], + command + ).parse(); }).rejects.toMatchObject({ code: 0 }); expect(handler).not.toHaveBeenCalled(); expect(output).toHaveBeenCalledTimes(1); @@ -93,11 +91,7 @@ describe("hand-written dry runs", () => { { command: "deploy", describe: "Deploy", handler }, "native" ); - await yargs(["deploy", "--dry-run"]) - .command(command) - .strict() - .exitProcess(false) - .parseAsync(); + await commandParser(["deploy", "--dry-run"], command).parse(); expect(handler).toHaveBeenCalledWith( expect.objectContaining({ dryRun: true }) ); diff --git a/packages/cli/src/__tests__/lib/stricli.test.ts b/packages/cli/src/__tests__/lib/stricli.test.ts new file mode 100644 index 0000000000..edd2b5c5a4 --- /dev/null +++ b/packages/cli/src/__tests__/lib/stricli.test.ts @@ -0,0 +1,32 @@ +import { describe, expect, it, vi } from "vite-plus/test"; +import { commandParser } from "../helpers/command-parser.js"; +import type { CommandModule } from "yargs"; + +describe("Stricli command boundary", () => { + const handler = vi.fn(); + const command: CommandModule = { + command: "remove ", + builder: (args) => + args + .option("force", { type: "boolean", alias: "f" }) + .option("label", { type: "string" }), + handler, + }; + it("does not interpret an invalid confirmation as true", async () => { + handler.mockClear(); + await expect( + commandParser(["remove", "id", "--force=maybe"], command).parse() + ).rejects.toThrow("Expected true or false for --force"); + expect(handler).not.toHaveBeenCalled(); + }); + it("preserves grouped switches and an explicit dash-prefixed value", async () => { + await expect( + commandParser(["remove", "id", "-qf", "--label=--force"], command).parse() + ).resolves.toMatchObject({ + id: "id", + quiet: true, + force: true, + label: "--force", + }); + }); +}); diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 23affdc1d8..464b05deca 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -1,9 +1,7 @@ import { setTimeout as sleep } from "node:timers/promises"; -import yargs from "yargs"; -import { hideBin } from "yargs/helpers"; // Generated commands (each entry is a lazy CommandModule shell — the // actual product/group/leaf modules are dynamically imported on demand -// when yargs navigates into the command). +// when the parser selects the command). import { generatedCommands } from "./commands/_generated/index.js"; import { appendApiSchemaHelp } from "./commands/api-schema-help.js"; import { @@ -19,16 +17,13 @@ import { shouldApplyCloudflareDotEnv, } from "./lib/dotenv.js"; import { handleError } from "./lib/errors.js"; -import { - BUILTIN_OPTIONS, - GLOBAL_OPTIONS, - GLOBAL_OPTION_NAMES, -} from "./lib/global-options.js"; +import { BUILTIN_OPTIONS, GLOBAL_OPTIONS } from "./lib/global-options.js"; import { withHandWrittenDryRun } from "./lib/hand-written-dry-run.js"; import { lazyCommand, type LazyCommandImporter } from "./lib/lazy-command.js"; import { disposeLocalRuntime } from "./lib/local.js"; import { setProjectConfigMode } from "./lib/project-settings.js"; import { openSession, printActiveProfileLine } from "./lib/session.js"; +import { createParser } from "./lib/stricli.js"; import { allTelemetryDispatchesSettled, beginTelemetryRun, @@ -38,10 +33,7 @@ import { renderPromptIntro } from "./lib/ui/banner.js"; import { theme } from "./lib/ui/index.js"; import { VERSION as version } from "./version.js"; import type * as TelemetryModule from "./lib/telemetry/index.js"; -import type { - CommandResolutionFailure, - CommandResolutionFailureKind, -} from "./lib/telemetry/types.js"; +import type { CommandResolutionFailure } from "./lib/telemetry/types.js"; import type { UpdateNotice } from "./lib/update-check.js"; import type { Options } from "yargs"; @@ -59,8 +51,6 @@ function flagToken(name: string): string { return name.length === 1 ? `-${name}` : `--${name}`; } -const ROOT_OPTION_NAMES = new Set(GLOBAL_OPTION_NAMES); - const GLOBAL_FLAGS_LIST = Object.entries({ ...GLOBAL_OPTIONS, ...BUILTIN_OPTIONS, @@ -242,134 +232,10 @@ async function flushTelemetry(): Promise { } } -// yargs words this singularly or plurally depending on the token count. -const UNKNOWN_COMMAND_MESSAGE = /^Unknown commands?: /; -const SUGGESTED_COMMAND_MESSAGE = /^Did you mean (.+)\?$/; -const MISSING_COMMAND_MESSAGE = "You need to specify a command"; - -// Only the singular form has historically been bucketed as an unknown -// command; the plural keeps the resolved command name for continuity. function isUnknownCommandError(error: unknown): boolean { return error instanceof Error && error.message.startsWith("Unknown command:"); } -interface YargsResolutionState { - parsed?: false | { argv?: { _?: unknown } }; - getInternalMethods(): { - getContext(): { commands: unknown }; - getCommandInstance(): { getCommands(): unknown }; - }; -} - -/** - * Capture where command resolution stopped, read while yargs still holds the - * failing level's context (it resets after parsing). Returns the raw tokens; - * telemetry sanitises them before sending. - */ -function commandResolutionFailure( - yargsInstance: unknown, - message: string -): CommandResolutionFailure | undefined { - const suggestedCommand = SUGGESTED_COMMAND_MESSAGE.exec(message)?.[1]; - let kind: CommandResolutionFailureKind; - if (suggestedCommand !== undefined) { - kind = "suggested-command"; - } else if (UNKNOWN_COMMAND_MESSAGE.test(message)) { - kind = "unknown-subcommand"; - } else if (message === MISSING_COMMAND_MESSAGE) { - kind = "missing-command"; - } else { - return undefined; - } - - try { - const state = yargsInstance as YargsResolutionState; - const internals = state.getInternalMethods(); - const knownCommand = internals.getContext().commands; - const subcommands = internals.getCommandInstance().getCommands(); - const positionals = state.parsed ? state.parsed.argv?._ : undefined; - if ( - !Array.isArray(knownCommand) || - !knownCommand.every((command) => typeof command === "string") || - !Array.isArray(subcommands) - ) { - return undefined; - } - // A leaf has no subcommands, so yargs' strict-commands check reports any - // positional the leaf did not consume as an unknown command. - const knownCommandIsLeaf = - knownCommand.length > 0 && subcommands.length === 0; - return { - kind: - kind === "unknown-subcommand" && knownCommandIsLeaf - ? "surplus-positional" - : kind, - knownCommand, - knownCommandIsLeaf, - unknownTokens: Array.isArray(positionals) - ? positionals.slice(knownCommand.length).map(String) - : [], - ...(suggestedCommand === undefined ? {} : { suggestedCommand }), - }; - } catch { - return undefined; - } -} - -function resolvedCommandName(yargsInstance: unknown): string | undefined { - try { - const commands = ( - yargsInstance as { - getInternalMethods(): { - getContext(): { commands: unknown }; - }; - } - ) - .getInternalMethods() - .getContext().commands; - if ( - !Array.isArray(commands) || - commands.length === 0 || - !commands.every((command) => typeof command === "string") - ) { - return undefined; - } - return commands.join(" "); - } catch { - return undefined; - } -} - -// Automatic help skips strict validation, so account for declared positionals -// before treating the next parsed token as an unknown command. -function unresolvedHelpCommands(yargsInstance: unknown): string[] { - const instance = yargsInstance as { - parsed: false | { argv: { _: unknown[]; help?: unknown } }; - getInternalMethods(): { - getContext(): { commands: unknown; fullCommands: unknown }; - }; - }; - const parsed = instance.parsed; - if (!parsed || parsed.argv.help !== true) { - return []; - } - const { commands, fullCommands } = instance.getInternalMethods().getContext(); - if (!Array.isArray(commands) || !Array.isArray(fullCommands)) { - return []; - } - const currentSyntax = fullCommands.at(-1); - const positionals = - typeof currentSyntax === "string" - ? (currentSyntax.match(/(?:<[^>]+>|\[[^\]]+\])/g) ?? []) - : []; - if ( - positionals.some((positional) => positional.slice(1, -1).endsWith("..")) - ) { - return []; - } - return parsed.argv._.slice(commands.length + positionals.length).map(String); -} - class CliUsageError extends Error { constructor( message: string, @@ -415,7 +281,7 @@ async function reportParseErrorIfUnreported( } // Failures below the root keep the bucketing they had before resolution // detail was added, so existing per-command data stays comparable: only - // yargs' singular "Unknown command:" becomes an unknown command, while a + // The singular "Unknown command:" becomes an unknown command, while a // suggestion or several unknown words keep the resolved command's name. // Root failures had no command name and were dropped; they are now // reported as unknown commands. @@ -467,7 +333,7 @@ async function describeResolutionFailure(failure: CommandResolutionFailure) { await import("./lib/telemetry/command-resolution.js"); return sanitizeCommandResolution( failure, - hideBin(process.argv), + process.argv.slice(2), loadCommandVocabulary(Object.keys(GLOBAL_OPTIONS)) ); } @@ -618,36 +484,6 @@ async function prepareUpdateCheck(): Promise { }; } -/** - * Construct the yargs CLI and its invocation disposer for a given argv. - * Exposed so tests can build the CLI in isolation without triggering - * auto-parsing. - * - * Yargs renders all help / group-help / per-command help itself; cf - * only customises the section headings (brand-orange instead of the - * yargs default `Commands:` / `Options:` / `Positionals:`) and groups - * global flags into a `GLOBAL FLAGS` bucket so they don't intermix - * with per-command options. Wrangler does the same thing. - * - * ## Global flags (live) - * - * --help, -h Show help - * --version, -v Show plain version on stdout (banner on stderr) - * --quiet, -q Suppress non-essential output - * --zone, -z Zone ID or domain - * --profile Use a specific auth profile - * --mode, -m Mode used to evaluate project configuration - * --temporary-account Use a temporary preview account (hidden) - * --event-code Create the temporary account for an event (hidden) - * --local Route via a cf-spawned Miniflare session - * --persist-to Directory holding the local persisted state - * - * ## Reserved - * - * `FUTURE_OPTION_NAMES` and `flagOwnership` in `lib/global-options.ts` - * list the names cf reserves beyond these, and why. Reserve a new - * cross-cutting flag there before shipping it. - */ export function buildCli(rawArgs: string[], options: BuildCliOptions = {}) { const { onCommandResolved, @@ -656,7 +492,6 @@ export function buildCli(rawArgs: string[], options: BuildCliOptions = {}) { updateCheck, } = options; let restoreCloudflareDotEnv: (() => void) | undefined; - const orange = (s: string) => theme.brand(s); const delimiter = rawArgs.indexOf("--"); const cfArgs = delimiter === -1 ? rawArgs : rawArgs.slice(0, delimiter); const localWasSpecified = cfArgs.some( @@ -664,246 +499,101 @@ export function buildCli(rawArgs: string[], options: BuildCliOptions = {}) { arg === "--local" || arg === "--no-local" || arg.startsWith("--local=") ); - const cli = yargs(rawArgs) - .scriptName("cf") - .parserConfiguration({ "sort-commands": true }) - // Yargs caps help at 80 columns by default, even in wider terminals. - .wrap(process.stdout.columns || 80) - .usage("$0 [options]") - .usage("\nThe Cloudflare CLI - manage your Cloudflare resources") - // Brand the yargs section headers without rewriting the help - // renderer. Same approach as wrangler: `updateStrings` rewrites - // yargs's built-in labels in-place, so the rest of the help - // layout (alignment, wrapping, `[boolean]` annotations) stays. - .updateStrings({ - "Commands:": orange("Commands"), - "Options:": orange("Options"), - "Positionals:": orange("Positionals"), - "Examples:": orange("Examples"), - }) - .help("help", BUILTIN_OPTIONS.help.description) - .alias(BUILTIN_OPTIONS.help.alias, "help") - .options(GLOBAL_OPTIONS) - // Bucket the cross-cutting flags into one block so they don't - // intermix with per-command options on each --help screen. - .group( - [...Object.keys(GLOBAL_OPTIONS), ...Object.keys(BUILTIN_OPTIONS)], - orange("Global flags") - ); - - // Hand-written commands. `lazyCommand` narrows the return type so - // every registered command has its describe string surfaced eagerly - // at registration time (so yargs help renders without dynamically - // importing the underlying module). - for (const command of handWrittenRoots) { - cli.command(command); - } - - // Register every generated product. Hidden products (those with - // `hideCommand: true`, e.g. early-access kv/r2/d1 surfaces) are - // invokable but suppressed from `--help` by passing - // `describe: false` to yargs — same mechanism `tools` uses. - for (const gc of generatedCommands) { - if (gc.hideCommand) { - cli.command({ ...gc.command, describe: false }); - } else { - cli.command(gc.command); - } - } - - cli - .middleware(async (argv) => { - // Command middleware can suppress decoration before startup output. - maybeOpenSession(argv.quiet, updateCheck?.notice); - updateCheck?.start(); - const resolvedCommand = resolvedCommandName(cli); - if (resolvedCommand !== undefined) { - onCommandResolved?.(resolvedCommand); - } - try { - await maybeShowTelemetryNotice(argv.quiet); - } catch { - // Telemetry must not affect command behavior. - } - try { - await maybeShowCompletionsHint(argv.quiet); - } catch { - // Completion hints must not affect command behavior. - } - setProjectConfigMode(argv.mode); - const rootCommand = String(argv._[0] ?? ""); - const persistTo = argv.persistTo ?? argv["persist-to"]; - if ( - !argv.help && - ((rootCommand === "dev" && localWasSpecified) || - (argv.local && HAND_WRITTEN_ROOTS.has(rootCommand))) - ) { - throw new Error(`--local is not supported by cf ${rootCommand}.`); - } - - if (!argv.help && rootCommand === "dev" && persistTo !== undefined) { - throw new Error("--persist-to is not supported by cf dev."); - } - - if (persistTo === "") { - throw new Error("--persist-to requires a non-empty directory."); - } + const cli = createParser( + rawArgs, + [ + ...handWrittenRoots, + ...generatedCommands.map((gc) => + gc.hideCommand + ? { ...gc.command, describe: false as const } + : gc.command + ), + ], + { + resolve(command) { + onCommandResolved?.(command); + }, + help: decorateHelp, + shown(command) { + onHelpShown?.(command); + }, + fail(message, command, failure) { + maybeOpenSession(false, updateCheck?.notice); + updateCheck?.start(); + const error = new CliUsageError(message, helpCommandFor(command)); + if (failure) { + onCommandResolutionFailed?.(failure, error); + } + throw error; + }, + async startup(argv, resolvedCommand) { + // Command middleware can suppress decoration before startup output. + maybeOpenSession(argv.quiet, updateCheck?.notice); + updateCheck?.start(); + try { + await maybeShowTelemetryNotice(argv.quiet); + } catch { + // Telemetry must not affect command behavior. + } + try { + await maybeShowCompletionsHint(argv.quiet); + } catch { + // Completion hints must not affect command behavior. + } + setProjectConfigMode(argv.mode); + const rootCommand = String(argv._[0] ?? ""); + const persistTo = argv.persistTo ?? argv["persist-to"]; + if ( + !argv.help && + ((rootCommand === "dev" && localWasSpecified) || + (argv.local && HAND_WRITTEN_ROOTS.has(rootCommand))) + ) { + throw new Error(`--local is not supported by cf ${rootCommand}.`); + } - if (persistTo !== undefined && !argv.local) { - throw new Error("--persist-to can only be used with --local."); - } + if (!argv.help && rootCommand === "dev" && persistTo !== undefined) { + throw new Error("--persist-to is not supported by cf dev."); + } - if (argv["temporary-account"] && argv.local) { - throw new Error("--temporary-account cannot be used with --local."); - } - const eventCode = argv["event-code"]; - // Never silently ignore an event code when real credentials apply. - if (eventCode !== undefined && !argv["temporary-account"]) { - throw new Error("--event-code requires --temporary-account."); - } + if (persistTo === "") { + throw new Error("--persist-to requires a non-empty directory."); + } - if ( - resolvedCommand !== undefined && - shouldApplyCloudflareDotEnv(resolvedCommand, argv.local) - ) { - restoreCloudflareDotEnv = await applyCloudflareDotEnv(argv); - } + if (persistTo !== undefined && !argv.local) { + throw new Error("--persist-to can only be used with --local."); + } - // Local mode bypasses profile credentials, so resolving and displaying - // an active profile would be misleading. - if (!argv.local) { - const { resolveProfile, setTemporaryAccountRequested } = - await import("./lib/oauth/index.js"); - setTemporaryAccountRequested( - argv["temporary-account"], - eventCode === undefined ? undefined : { eventCode } - ); - const profile = resolveProfile(argv.profile); - printActiveProfileLine(profile); - } - }) - .demandCommand(1, "You need to specify a command") - // Keep these separate so runtime-schema commands can accept dynamic - // options without also accepting surplus positional arguments. - .strictCommands() - .strictOptions() - .recommendCommands() - .version("version", BUILTIN_OPTIONS.version.description, version) - .alias(BUILTIN_OPTIONS.version.alias, "version") - .epilogue("For more information, visit https://developers.cloudflare.com/") - // Don't call process.exit on parse failures — surface as a thrown - // error so callers (bin/cf, dev.ts, tests) can handle it. - .exitProcess(false) - .fail((msg, err, yargsInstance) => { - maybeOpenSession(false, updateCheck?.notice); - updateCheck?.start(); - const resolvedCommand = resolvedCommandName(cli); - if (resolvedCommand !== undefined) { - onCommandResolved?.(resolvedCommand); - } - if (err) { - throw err; - } - // Yargs checks the missing command before strict options. Let its - // next validation report an unknown global flag when one is present. - if (msg === "You need to specify a command" && cli.parsed) { - const hasUnknownOption = Object.keys(cli.parsed.argv).some( - (name) => - name !== "_" && - name !== "$0" && - !ROOT_OPTION_NAMES.has( - name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`) - ) - ); - if (hasUnknownOption) { - return; + if (argv["temporary-account"] && argv.local) { + throw new Error("--temporary-account cannot be used with --local."); } - } - // Yargs considers hidden commands when matching recommendations. - // Its usage list contains only commands visible at the current depth, - // so let parsing continue to the normal unknown-command failure when - // the recommendation is hidden. - const recommendation = SUGGESTED_COMMAND_MESSAGE.exec(msg)?.[1]; - if (recommendation) { - const visibleCommands = ( - yargsInstance as unknown as { - getCommands(): Array<[string, ...unknown[]]>; - } - ).getCommands(); - const isVisible = visibleCommands.some( - ([command]) => command.split(" ")[0] === recommendation - ); - if (!isVisible) { - return; + const eventCode = argv["event-code"]; + // Never silently ignore an event code when real credentials apply. + if (eventCode !== undefined && !argv["temporary-account"]) { + throw new Error("--event-code requires --temporary-account."); } - } - // A group invoked without a subcommand (e.g. `cf dns`, or a - // nested `cf r2 buckets`) fails its `.demandCommand(1, …)` - // with our distinct "Please specify a subcommand" message — - // both the hand-written groups and the generated index shells - // use it. Show the relevant `--help` instead of a bare error - // (same UX wrangler's `subHelp` provides), using - // `yargsInstance`'s rendered help so each group shows its own - // subcommand list. - if (msg === "Please specify a subcommand") { - if (resolvedCommand !== undefined) { - onHelpShown?.(resolvedCommand); + + if ( + resolvedCommand !== undefined && + shouldApplyCloudflareDotEnv(resolvedCommand, argv.local) + ) { + restoreCloudflareDotEnv = await applyCloudflareDotEnv(argv); } - yargsInstance.showHelp("log"); - return; - } - const error = new CliUsageError(msg, helpCommandFor(resolvedCommand)); - const resolutionFailure = - commandResolutionFailure(cli, msg) ?? - (resolvedCommand === undefined && /^Unknown arguments?:/.test(msg) - ? commandResolutionFailure(cli, MISSING_COMMAND_MESSAGE) - : undefined); - if (resolutionFailure) { - onCommandResolutionFailed?.(resolutionFailure, error); - } - throw error; - }); - // Every depth can replace `.usage()`, so add the notice at the point - // yargs emits help rather than relying on a root-level usage string. - const showHelp = cli.showHelp.bind(cli); - cli.showHelp = (level?: string | ((help: string) => void)) => { - // Runtime-schema handlers render their own help with showHelp("log"). - const unknownCommands = - typeof level === "function" ? unresolvedHelpCommands(cli) : []; - if (unknownCommands.length > 0) { - const error = new CliUsageError( - `Unknown command: ${unknownCommands[0]}`, - helpCommandFor(resolvedCommandName(cli)) - ); - const resolutionFailure = commandResolutionFailure(cli, error.message); - if (resolutionFailure) { - onCommandResolutionFailed?.( - { ...resolutionFailure, unknownTokens: unknownCommands }, - error - ); - } - throw error; + // Local mode bypasses profile credentials, so resolving and displaying + // an active profile would be misleading. + if (!argv.local) { + const { resolveProfile, setTemporaryAccountRequested } = + await import("./lib/oauth/index.js"); + setTemporaryAccountRequested( + argv["temporary-account"], + eventCode === undefined ? undefined : { eventCode } + ); + const profile = resolveProfile(argv.profile); + printActiveProfileLine(profile); + } + }, } - return showHelp((help) => { - const command = resolvedCommandName(cli); - if (command !== undefined) { - onCommandResolved?.(command); - } - onHelpShown?.(command ?? "cf"); - const message = decorateHelp(help, command); - if (typeof level === "function") { - level(message); - } else if (level === "log") { - console.log(message); - } else { - console.error(message); - } - }); - }; - const getHelp = cli.getHelp.bind(cli); - cli.getHelp = async () => - decorateHelp(await getHelp(), resolvedCommandName(cli)); + ); return { cli, @@ -931,13 +621,10 @@ export async function runMain(argv: string[]): Promise { } /** - * Entry point for the CLI. Reads `process.argv`, dispatches to the yargs + * Entry point for the CLI. Reads `process.argv`, dispatches to the lazy * command graph, and short-circuits via `CliExit` for early-exit paths * (--version, bare-cf splash). * - * Help / group-help / per-command help are rendered by yargs itself; - * cf only customises the section headings via `updateStrings`. - * * Tests stub `process.argv` (and optionally `process.stdin.isTTY`, env * vars, etc.) then await `main()`, catching any `CliExit`. Most tests * should prefer `runMain(argv)` instead. @@ -965,7 +652,7 @@ export async function main(): Promise { | { failure: CommandResolutionFailure; error: Error } | undefined; let helpShown: string | undefined; - const { cli, dispose } = buildCli(hideBin(process.argv), { + const { cli, dispose } = buildCli(process.argv.slice(2), { onCommandResolved: (command) => { resolvedCommand = command; }, @@ -978,7 +665,7 @@ export async function main(): Promise { updateCheck, }); // Help bypasses command middleware, so retain its startup decoration here. - const rawArgs = hideBin(process.argv); + const rawArgs = process.argv.slice(2); const separator = rawArgs.indexOf("--"); const args = separator === -1 ? rawArgs : rawArgs.slice(0, separator); if (args.includes("--help") || args.includes("-h")) { @@ -992,7 +679,7 @@ export async function main(): Promise { } // Central error handling: command handlers and validation alike - // throw uncaught; yargs `.fail()` rethrows; we render once here. + // throw uncaught; we render once here. // `handleError` is responsible for both rendering and producing the // value to rethrow — today that's the input unchanged so tests can // assert on the original shape (status, code, message), but routing @@ -1004,7 +691,7 @@ export async function main(): Promise { // flows through unchanged so explicit exit codes (e.g. from // `--help` early-exits) survive. try { - await cli.parse(hideBin(process.argv)); + await cli.parse(process.argv.slice(2)); await reportHelpShown(helpShown); } catch (err) { if (err instanceof CliExit) { @@ -1027,11 +714,7 @@ export async function main(): Promise { resolutionFailure !== undefined && resolutionFailure.error === err ? resolutionFailure.failure : undefined; - await reportParseErrorIfUnreported( - err, - resolvedCommand ?? resolvedCommandName(cli), - failure - ); + await reportParseErrorIfUnreported(err, resolvedCommand, failure); const handledError = handleError(err); if (err instanceof CliUsageError) { if ( diff --git a/packages/cli/src/lib/stricli.ts b/packages/cli/src/lib/stricli.ts new file mode 100644 index 0000000000..1b84dc754f --- /dev/null +++ b/packages/cli/src/lib/stricli.ts @@ -0,0 +1,782 @@ +import { + buildApplication, + buildCommand, + numberParser, + run, + text_en, + UnexpectedFlagError, + UnsatisfiedFlagError, + UnsatisfiedPositionalError, +} from "@stricli/core"; +import { BUILTIN_OPTIONS, GLOBAL_OPTIONS } from "./global-options.js"; +import { theme } from "./ui/theme.js"; +import type { CommonYargsOptions } from "./cli-types.js"; +import type { CommandResolutionFailure } from "./telemetry/types.js"; +import type { + Command, + CommandContext, + TypedCommandParameters, +} from "@stricli/core"; +import type { ArgumentsCamelCase, Argv, CommandModule, Options } from "yargs"; + +type Args = ArgumentsCamelCase; +type Module = CommandModule; +type Hook = (argv: Args) => unknown; +const list = (value: T | readonly T[] | undefined): readonly T[] => + value === undefined ? [] : Array.isArray(value) ? value : [value as T]; +const camel = (key: string) => + key.replace(/-([a-z])/g, (_, char: string) => char.toUpperCase()); +const words = (mod: Module) => list(mod.command)[0]?.split(" ") ?? []; + +class Definition { + flags = new Map(Object.entries(GLOBAL_OPTIONS)); + positions = new Map(); + children: Module[] = []; + checks: Hook[] = []; + before: Hook[] = []; + after: Hook[] = []; + config: Record = {}; + requireChild = false; + dynamic = false; + autoHelp = true; + heading = ""; + footer = ""; + examples: string[] = []; + constructor(readonly showHelp: () => void) {} + command(child: Module) { + this.children.push(child); + return this; + } + option(name: string, option: Options) { + this.flags.set(name, option); + return this; + } + options(options: Record) { + for (const [name, option] of Object.entries(options)) { + this.option(name, option); + } + return this; + } + positional(name: string, option: Options) { + this.positions.set(name, option); + return this; + } + usage(text: string) { + this.heading = text; + return this; + } + epilogue(text: string) { + this.footer = text; + return this; + } + example(input: string, description: string) { + this.examples.push(`${input} ${description}`); + return this; + } + hide(name: string) { + this.flags.set(name, { ...this.flags.get(name), hidden: true }); + return this; + } + group() { + return this; + } + demandCommand() { + this.requireChild = true; + return this; + } + strictOptions(enabled: boolean) { + this.dynamic = !enabled; + return this; + } + help(enabled: boolean) { + this.autoHelp = enabled; + return this; + } + parserConfiguration(config: Record) { + Object.assign(this.config, config); + return this; + } + middleware(hook: Hook, early = false) { + (early ? this.before : this.after).push(hook); + return this; + } + check(hook: Hook) { + this.checks.push(hook); + return this; + } + coerce(name: string, coerce: Options["coerce"]) { + const source = this.flags.has(name) ? this.flags : this.positions; + source.set(name, { ...source.get(name), coerce }); + return this; + } + conflicts(name: string, others: string | string[]) { + return this.check((argv) => { + for (const other of list(others)) { + if (argv[name] !== undefined && argv[other] !== undefined) { + throw new Error( + `Arguments ${name} and ${other} are mutually exclusive` + ); + } + } + }); + } + implies(name: string, others: string | string[]) { + return this.check((argv) => { + for (const other of list(others)) { + if (argv[name] !== undefined && argv[other] === undefined) { + throw new Error(`Missing dependent arguments: ${name} -> ${other}`); + } + } + }); + } +} + +function aliases(def: Definition) { + const names = new Map(); + for (const [key, option] of def.flags) { + for (const name of [key, ...list(option.alias)]) { + names.set(name, key); + names.set(camel(name), key); + } + } + return names; +} + +function wrapLine(text: string, width: number): string[] { + if (text.length <= width) { + return [text]; + } + const lines = [""]; + for (const word of text.split(/\s+/)) { + const index = lines.length - 1; + const line = lines[index]; + if (line && line.length + word.length + 1 > width) { + lines.push(word); + } else { + lines[index] = line ? `${line} ${word}` : word; + } + } + return lines; +} + +function renderHelp( + def: Definition, + path: string[], + mod: Module | undefined, + width: number +) { + const prefix = ["cf", ...path].join(" "); + const heading = def.heading + ? def.heading.replace(/^\$0/, "cf") + : mod + ? `${prefix}${words(mod) + .slice(1) + .map((word) => ` ${word}`) + .join("")}\n\n${mod.describe || ""}` + : "cf [options]\n\nThe Cloudflare CLI - manage your Cloudflare resources"; + const sections = [ + heading + .split("\n") + .flatMap((line) => wrapLine(line, width)) + .join("\n"), + ]; + const section = (title: string, rows: string[]) => { + if (rows.length) { + sections.push( + `${theme.brand(title)}\n${rows.map((row) => ` ${row}`).join("\n")}` + ); + } + }; + section( + "Commands", + def.children + .filter((child) => child.describe !== false) + .map( + (child) => + `${prefix} ${words(child).join(" ")} ${child.describe || ""}` + ) + .sort() + ); + const opts = (entries: [string, Options][], positional = false) => { + const flags = entries + .filter(([, opt]) => !opt.hidden) + .map(([key, opt]) => { + const names = [...list(opt.alias), key]; + const label = positional + ? key + : (names.some((name) => name.length === 1) ? "" : " ") + + names + .map((name) => (name.length === 1 ? `-${name}` : `--${name}`)) + .join(", "); + const description = opt.description ?? opt.describe ?? ""; + const metadata = [ + opt.type && `[${opt.type}]`, + opt.demandOption && "[required]", + opt.choices && `[choices: ${opt.choices.join(", ")}]`, + opt.default !== undefined && + `[default: ${JSON.stringify(opt.default)}]`, + ] + .filter(Boolean) + .join(" "); + return { label, description, metadata }; + }); + const column = Math.max(0, ...flags.map((flag) => flag.label.length)) + 2; + return flags.map(({ label, description, metadata }) => { + const lines = String(description) + .split("\n") + .flatMap((line) => wrapLine(line, width - column - 2)); + const last = lines.length - 1; + if (metadata) { + if ( + Number.isFinite(width) && + (lines[last]?.length ?? 0) + 1 + metadata.length > width - column - 2 + ) { + lines.push(""); + } + const end = lines.length - 1; + lines[end] = + (lines[end] ?? "").padEnd( + Number.isFinite(width) + ? width - column - 2 - metadata.length + : (lines[end]?.length ?? 0) + 1 + ) + metadata; + } + return lines + .map( + (line, index) => + (index ? " ".repeat(column + 2) : label.padEnd(column)) + line + ) + .join("\n"); + }); + }; + section("Positionals", opts([...def.positions], true)); + section( + "Global flags", + opts( + [...def.flags] + .filter(([key]) => Object.hasOwn(GLOBAL_OPTIONS, key)) + .concat( + Object.entries(BUILTIN_OPTIONS).map( + ([key, opt]): [string, Options] => [ + key, + { ...opt, type: "boolean" }, + ] + ) + ) + ) + ); + section( + "Options", + opts([...def.flags].filter(([key]) => !Object.hasOwn(GLOBAL_OPTIONS, key))) + ); + section("Examples", def.examples); + if (def.footer) { + sections.push(def.footer); + } + return sections.join("\n\n"); +} + +function closest(input: string, children: Module[]) { + let best = 4, + suggestion: string | undefined; + for (const child of children) { + const name = words(child)[0]; + if (!name || Math.abs(input.length - name.length) >= best) { + continue; + } + let prev = Array.from({ length: name.length + 1 }, (_, index) => index); + let previousRow = prev; + for (let offset = 0; offset < input.length; offset++) { + const char = input[offset]; + const next = [offset + 1]; + for (let idx = 0; idx < name.length; idx++) { + next.push( + Math.min( + (next[idx] ?? Infinity) + 1, + (prev[idx + 1] ?? Infinity) + 1, + (prev[idx] ?? Infinity) + Number(char !== name[idx]), + idx > 0 && + offset > 0 && + char === name[idx - 1] && + input[offset - 1] === name[idx] + ? (previousRow[idx - 1] ?? Infinity) + 1 + : Infinity + ) + ); + } + previousRow = prev; + prev = next; + } + const distance = prev[name.length] ?? Infinity; + if (distance < best) { + best = distance; + suggestion = child.describe === false ? undefined : name; + } + } + return suggestion; +} + +export function createParser( + rawArgs: string[], + roots: Module[], + hooks: { + resolve(command: string): void; + help(text: string, command?: string): string; + shown(command: string): void; + fail( + message: string, + command?: string, + resolution?: CommandResolutionFailure + ): never; + startup(argv: Args, command?: string): Promise; + helpWidth?: number; + } +) { + async function invoke(input: string[], helpOnly: boolean) { + const path: string[] = []; + let mod: Module | undefined; + const command = () => (path.length ? path.join(" ") : undefined); + const help = () => + hooks.help( + renderHelp( + def, + path, + mod, + hooks.helpWidth ?? (process.stdout.columns || 80) + ), + command() + ); + const showHelp = () => { + hooks.shown(command() ?? "cf"); + console.log(help()); + }; + let def = new Definition(showHelp); + def.children = roots; + def.requireChild = true; + const delimiter = input.indexOf("--"); + const args = delimiter < 0 ? [...input] : input.slice(0, delimiter); + const tail = delimiter < 0 ? [] : input.slice(delimiter + 1); + const fail = ( + msg: string, + kind?: CommandResolutionFailure["kind"], + unknownTokens: string[] = [], + suggestedCommand?: string + ): never => + hooks.fail( + msg, + command(), + kind + ? { + kind, + knownCommand: path, + knownCommandIsLeaf: !!mod && !def.children.length, + unknownTokens, + suggestedCommand, + } + : undefined + ); + while (def.children.length) { + const names = aliases(def); + const index = args.findIndex((token, offset) => { + if (token.startsWith("-")) { + return false; + } + const previous = args[offset - 1]; + if (!previous?.startsWith("-")) { + return true; + } + const key = names.get(previous.replace(/^--?/, "")); + return ( + !key || + (def.flags.get(key)?.type === "boolean" && + !["true", "false"].includes(token)) + ); + }); + if (index < 0) { + break; + } + const token = args[index]; + if (token === undefined) { + break; + } + const child = def.children.find((entry) => + [ + ...list(entry.command).map((name) => name.split(" ")[0]), + ...list(entry.aliases), + ].includes(token) + ); + if (!child) { + if (!def.requireChild) { + break; + } + const suggestion = closest(token, def.children); + const unknown = args.slice(index).filter((arg) => !arg.startsWith("-")); + return fail( + suggestion + ? `Did you mean ${suggestion}?` + : `Unknown command${unknown.length > 1 ? "s" : ""}: ${unknown.join(", ")}`, + suggestion ? "suggested-command" : "unknown-subcommand", + unknown, + suggestion + ); + } + mod = child; + path.push(token); + args.splice(index, 1); + hooks.resolve(path.join(" ")); + const parent = def; + def = new Definition(showHelp); + for (const [name, opt] of parent.flags) { + if (opt.global) { + def.flags.set(name, opt); + } + } + def.before.push(...parent.before); + def.after.push(...parent.after); + if (typeof child.builder === "function") { + await child.builder(def as unknown as Argv); + } else if (child.builder) { + def.options(child.builder); + } + } + const wantsHelp = + helpOnly || + (def.autoHelp && args.some((arg) => arg === "--help" || arg === "-h")); + const spec = mod + ? words(mod) + .slice(1) + .map((word) => ({ + key: word.slice(1, -1).replace(/\.{2,3}$/, ""), + required: word.startsWith("<"), + many: word.endsWith("..]") || word.endsWith("..>"), + })) + : []; + const names = aliases(def); + const params: NonNullable["parameters"]["flags"]> = + Object.create(null); + for (const [key, opt] of def.flags) { + params[key] = + opt.type === "boolean" + ? { + kind: "boolean", + brief: opt.description ?? "", + optional: true, + withNegated: def.config["boolean-negation"] !== false, + } + : { + kind: "parsed", + brief: opt.description ?? "", + parse: opt.type === "number" ? numberParser : String, + optional: true, + variadic: true, + inferEmpty: !opt.requiresArg && !opt.nargs, + }; + } + const parsedTokens: string[] = [], + positionals: string[] = [], + unknown: string[] = []; + for (let idx = 0; idx < args.length; idx++) { + const arg = args[idx]; + if (arg === undefined) { + break; + } + if (def.autoHelp && (arg === "--help" || arg === "-h")) { + continue; + } + if (!arg.startsWith("-") || arg === "-" || /^-\d/.test(arg)) { + positionals.push(arg); + continue; + } + if ( + def.config["short-option-groups"] !== false && + /^-[a-zA-Z]{2,}$/.test(arg) + ) { + const shortNames = arg.slice(1).split(""); + if ( + shortNames.every( + (name) => def.flags.get(names.get(name) ?? "")?.type === "boolean" + ) + ) { + args.splice(idx, 1, ...shortNames.map((name) => `-${name}`)); + idx--; + continue; + } + } + const [spelling = "", inline] = arg.replace(/^--?/, "").split(/=(.*)/s); + let key = names.get(spelling); + const negated = + !key && + spelling.startsWith("no-") && + def.config["boolean-negation"] !== false; + if (negated) { + key = names.get(spelling.slice(3)); + } + if (!key) { + if (def.config["unknown-options-as-args"]) { + positionals.push(arg); + continue; + } + if ( + !def.dynamic || + !/^--[a-z][\w.-]*$/i.test(arg.split("=")[0] ?? "") || + Object.hasOwn(Object.prototype, spelling) || + spelling === "prototype" + ) { + unknown.push(spelling); + if ( + inline === undefined && + args[idx + 1] && + !args[idx + 1]?.startsWith("-") + ) { + idx++; + } + continue; + } + key = spelling; + const hasValue = + inline !== undefined || + (args[idx + 1] !== undefined && !args[idx + 1]?.startsWith("-")); + def.flags.set(key, { type: hasValue ? "string" : "boolean" }); + names.set(key, key); + params[key] = hasValue + ? { + kind: "parsed", + brief: "", + parse: String, + optional: true, + variadic: true, + } + : { kind: "boolean", brief: "", optional: true }; + } + const opt = def.flags.get(key); + if (!opt) { + return fail(`Unknown argument: ${spelling}`); + } + if (negated && opt.type !== "boolean") { + opt.coerce?.(false); + unknown.push(spelling); + continue; + } + const flag = `--${key}`; + if (opt.type === "boolean") { + const value = + inline ?? + (!negated && ["true", "false"].includes(args[idx + 1] ?? "") + ? args[++idx] + : undefined); + if (value !== undefined && value !== "true" && value !== "false") { + return fail(`Expected true or false for --${key}`); + } + if (negated && inline !== undefined) { + return fail(`Cannot pass a value to --${spelling}`); + } + parsedTokens.push( + negated + ? `${flag}=false` + : value === undefined + ? flag + : `${flag}=${value}` + ); + continue; + } + const takesValue = () => + idx + 1 < args.length && + (!args[idx + 1]?.startsWith("-") || + /^-\d/.test(args[idx + 1] ?? "") || + args[idx + 1] === "-"); + let value = inline ?? (takesValue() ? args[++idx] : undefined); + if (value === undefined && (opt.requiresArg || opt.nargs)) { + return fail(`Not enough arguments following: ${key}`); + } + const pushValue = (literal: string) => { + if (literal.startsWith("-") && !/[\r\n\u2028\u2029]/.test(literal)) { + parsedTokens.push(`${flag}=${literal}`); + } else { + parsedTokens.push(flag, literal); + } + }; + pushValue(value ?? ""); + while ( + (opt.array || opt.type === "array") && + !opt.nargs && + takesValue() + ) { + value = args[++idx]; + pushValue(value ?? ""); + } + } + if (positionals.length > spec.length && !spec.at(-1)?.many) { + const surplus = positionals.slice(spec.length); + return fail( + `Unknown command${surplus.length > 1 ? "s" : ""}: ${surplus.join(", ")}`, + "surplus-positional", + surplus + ); + } + if (wantsHelp || (def.requireChild && mod)) { + if (!wantsHelp && unknown.length) { + return fail(`Unknown argument: ${unknown[0]}`); + } + if (helpOnly) { + return help(); + } + showHelp(); + return; + } + if (unknown.length) { + return fail( + `Unknown argument${unknown.length > 1 ? "s" : ""}: ${unknown.join(", ")}`, + mod ? undefined : "missing-command" + ); + } + if (!mod) { + return fail("You need to specify a command", "missing-command"); + } + const selected = mod; + const required = spec.filter((item) => item.required).length; + let result: Record | undefined; + let operands: string[] = []; + const leaf = buildCommand, string[]>({ + parameters: { + flags: params, + positional: { + kind: "array", + minimum: required, + parameter: { brief: "Arguments", parse: String }, + }, + } as TypedCommandParameters< + Record, + string[], + CommandContext + >, + docs: { brief: String(mod.describe || "") }, + func(flags, ...values) { + result = flags; + operands = values; + }, + }); + const app = buildApplication( + leaf, + { + name: "cf", + scanner: { allowArgumentEscapeSequence: true }, + localization: { + text: { + ...text_en, + exceptionWhileParsingArguments(error) { + if (error instanceof UnsatisfiedPositionalError) { + return fail( + `Not enough non-option arguments: got ${positionals.length}, need at least ${required}` + ); + } + if (error instanceof UnexpectedFlagError) { + const opt = def.flags.get(error.externalFlagName); + opt?.coerce?.([error.previousInput, error.input]); + return fail( + `--${error.externalFlagName} can only be specified once.` + ); + } + if (error instanceof UnsatisfiedFlagError) { + return fail( + `Missing required argument: ${error.externalFlagName}` + ); + } + return fail( + error instanceof Error ? error.message : "Invalid arguments" + ); + }, + }, + }, + }, + {} + ); + let diagnostic = ""; + const stream = { + write(text: string) { + diagnostic += text; + }, + }; + await run(app, [...parsedTokens, "--", ...positionals], { + process: { stdout: stream, stderr: stream }, + }); + if (!result) { + return fail(diagnostic.trim() || "Invalid arguments"); + } + const argv = Object.assign(Object.create(null), { + $0: "cf", + _: [...path, ...(def.config["populate--"] ? [] : tail)], + }) as Args; + if (def.config["populate--"] && tail.length) { + argv["--"] = tail; + } + const assign = (key: string, raw: unknown, opt: Options) => { + let value = raw ?? opt.default; + if (value === undefined) { + if (opt.demandOption) { + fail(`Missing required argument: ${key}`); + } + return; + } + if ( + def.flags.has(key) && + Array.isArray(value) && + !opt.array && + opt.type !== "array" && + value.length === 1 + ) { + value = value[0]; + } + if (opt.coerce) { + value = opt.coerce(value); + } + if ( + opt.choices && + !list(value).every((item) => + opt.choices?.some((choice) => choice === item) + ) + ) { + fail( + `Invalid values:\n Argument: ${key}, Given: ${JSON.stringify(value)}, Choices: ${opt.choices.map((choice) => JSON.stringify(choice)).join(", ")}` + ); + } + for (const name of [key, ...list(opt.alias)]) { + argv[name] = value; + if (def.config["camel-case-expansion"] !== false) { + argv[camel(name)] = value; + } + } + }; + for (const [key, opt] of def.flags) { + assign(key, result[key], opt); + } + for (const [idx, item] of spec.entries()) { + const opt = def.positions.get(item.key) ?? {}; + const value = item.many ? operands.slice(idx) : operands[idx]; + if (value !== undefined || opt.default !== undefined) { + assign( + item.key, + opt.type === "number" && value !== undefined ? Number(value) : value, + opt + ); + } + } + for (const check of def.checks) { + const value = await check(argv); + if (value === false || typeof value === "string") { + fail(typeof value === "string" ? value : "Argument validation failed"); + } + } + for (const hook of def.before) { + await hook(argv); + } + await hooks.startup(argv, command()); + for (const hook of def.after) { + await hook(argv); + } + await selected.handler(argv); + } + return { + parse: (args = rawArgs) => invoke(args, false), + getHelp: async () => String(await invoke(rawArgs, true)), + }; +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b884c28414..d882527456 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -315,6 +315,9 @@ importers: '@redocly/openapi-core': specifier: 2.82.0 version: 2.82.0 + '@stricli/core': + specifier: 1.3.0 + version: 1.3.0 '@types/node': specifier: 26.6.6 version: 26.6.6 @@ -378,9 +381,6 @@ importers: ws: specifier: 8.23.0 version: 8.23.0 - yargs: - specifier: 18.2.0 - version: 18.2.0 packages/wrangler-tests: devDependencies: @@ -2282,6 +2282,9 @@ packages: '@speed-highlight/core@1.2.17': resolution: {integrity: sha512-Z92FwKpCtfaW1V0jTU/fh3QzYEZN8wDwrzRIBoADCJfn4mJCNcJN/XegifX7BDrQ8/h9Xh/JnbyMchL0FqXrkg==} + '@stricli/core@1.3.0': + resolution: {integrity: sha512-LnBe2HntygaLDU5trtjiC3J4C/YkmIZuM0XB52IF4qaLqJH09kgD1fnZiS2gaYUnt0nAN2a+1b4PSOBcfPrN4Q==} + '@testing-library/dom@10.4.2': resolution: {integrity: sha512-yzr2S9HyAIdhz2/6qHgbs665Q7PKVcDF05vsOlHPxG1mo36gKVesdYVeDLnXgfjJ03CrKRk08knc6+E/9m8v2Q==} engines: {node: '>=18'} @@ -5613,6 +5616,8 @@ snapshots: '@speed-highlight/core@1.2.17': {} + '@stricli/core@1.3.0': {} + '@testing-library/dom@10.4.2': dependencies: '@babel/code-frame': 7.29.7 From 9b484f65c2004e81e76409c34cee5f6a97726017 Mon Sep 17 00:00:00 2001 From: Brendan Irvine-Broque Date: Tue, 24 Nov 2026 09:56:43 -0800 Subject: [PATCH 2/7] fix(cli): preserve parser output and compare every generated route --- .changeset/stricli-parser.md | 2 +- packages/cli/package.json | 1 + .../cli/src/__tests__/lib/stricli.test.ts | 30 +- packages/cli/src/lib/cliui.d.ts | 15 + packages/cli/src/lib/stricli.ts | 412 +++++++++++------- pnpm-lock.yaml | 3 + scripts/README.md | 2 + scripts/compare-cli-parity.mjs | 212 +++++++++ 8 files changed, 521 insertions(+), 156 deletions(-) create mode 100644 packages/cli/src/lib/cliui.d.ts create mode 100644 scripts/compare-cli-parity.mjs diff --git a/.changeset/stricli-parser.md b/.changeset/stricli-parser.md index 7e2b23545c..b06f7caecc 100644 --- a/.changeset/stricli-parser.md +++ b/.changeset/stricli-parser.md @@ -4,4 +4,4 @@ Parse CLI arguments with Stricli instead of yargs. -Keep the existing command names and flags. Explicit boolean values must be `true` or `false`; malformed values such as `--force=maybe` are rejected before the command runs. +Keep the existing command names, flags, and boolean coercion. Only an affirmative force switch bypasses destructive confirmation. diff --git a/packages/cli/package.json b/packages/cli/package.json index ea5922c01b..2a46346e49 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -97,6 +97,7 @@ "@types/yargs": "17.0.35", "chalk": "6.0.1", "ci-info": "^4.5.0", + "cliui": "9.0.1", "esbuild": "0.28.2", "figures": "6.1.0", "minimatch": "11.0.9", diff --git a/packages/cli/src/__tests__/lib/stricli.test.ts b/packages/cli/src/__tests__/lib/stricli.test.ts index edd2b5c5a4..753b642bb2 100644 --- a/packages/cli/src/__tests__/lib/stricli.test.ts +++ b/packages/cli/src/__tests__/lib/stricli.test.ts @@ -16,8 +16,10 @@ describe("Stricli command boundary", () => { handler.mockClear(); await expect( commandParser(["remove", "id", "--force=maybe"], command).parse() - ).rejects.toThrow("Expected true or false for --force"); - expect(handler).not.toHaveBeenCalled(); + ).resolves.toMatchObject({ force: false }); + expect(handler).toHaveBeenCalledWith( + expect.objectContaining({ force: false }) + ); }); it("preserves grouped switches and an explicit dash-prefixed value", async () => { await expect( @@ -29,4 +31,28 @@ describe("Stricli command boundary", () => { label: "--force", }); }); + it("binds camel-case command operands to the declared kebab-case positional", async () => { + await expect( + commandParser(["get", "example"], { + command: "get ", + builder: (args) => args.positional("resource-id", { type: "string" }), + handler, + }).parse() + ).resolves.toMatchObject({ + resourceId: "example", + "resource-id": "example", + }); + }); + it("distinguishes omitted, empty and malformed numeric values", async () => { + await expect( + commandParser( + ["--count", "2", "get", "--count", "--count=", "--count=bad"], + { + command: "get", + builder: (args) => args.option("count", { type: "number" }), + handler, + } + ).parse() + ).resolves.toMatchObject({ count: [2, undefined, 0, NaN] }); + }); }); diff --git a/packages/cli/src/lib/cliui.d.ts b/packages/cli/src/lib/cliui.d.ts new file mode 100644 index 0000000000..e2167744f8 --- /dev/null +++ b/packages/cli/src/lib/cliui.d.ts @@ -0,0 +1,15 @@ +declare module "cliui" { + type Column = + | string + | { + text: string; + width?: number; + padding?: [number, number, number, number]; + align?: "right"; + }; + export default function cliui(options: { width: number; wrap: boolean }): { + div(...columns: Column[]): void; + span(...columns: Column[]): void; + toString(): string; + }; +} diff --git a/packages/cli/src/lib/stricli.ts b/packages/cli/src/lib/stricli.ts index 1b84dc754f..9572fe241e 100644 --- a/packages/cli/src/lib/stricli.ts +++ b/packages/cli/src/lib/stricli.ts @@ -1,13 +1,14 @@ import { buildApplication, buildCommand, - numberParser, run, text_en, UnexpectedFlagError, UnsatisfiedFlagError, UnsatisfiedPositionalError, } from "@stricli/core"; +import cliui from "cliui"; +import stringWidth from "string-width"; import { BUILTIN_OPTIONS, GLOBAL_OPTIONS } from "./global-options.js"; import { theme } from "./ui/theme.js"; import type { CommonYargsOptions } from "./cli-types.js"; @@ -27,6 +28,16 @@ const list = (value: T | readonly T[] | undefined): readonly T[] => const camel = (key: string) => key.replace(/-([a-z])/g, (_, char: string) => char.toUpperCase()); const words = (mod: Module) => list(mod.command)[0]?.split(" ") ?? []; +const negativeNumber = /^-(?:\d|\.\d)/; +function parseLiteral(literal: string, opt: Options) { + if (literal === "!") { + return opt.type === "number" ? 0 : false; + } + if (opt.type === "number") { + return literal === "" ? undefined : Number(literal.slice(1)); + } + return literal.slice(1); +} class Definition { flags = new Map(Object.entries(GLOBAL_OPTIONS)); @@ -41,14 +52,21 @@ class Definition { autoHelp = true; heading = ""; footer = ""; - examples: string[] = []; + examples: [string, string][] = []; + groupedOptions = new Set(); constructor(readonly showHelp: () => void) {} command(child: Module) { this.children.push(child); return this; } option(name: string, option: Options) { - this.flags.set(name, option); + const previous = this.flags.get(name); + this.flags.set( + name, + previous?.choices && option.choices + ? { ...option, choices: [...previous.choices, ...option.choices] } + : option + ); return this; } options(options: Record) { @@ -70,14 +88,17 @@ class Definition { return this; } example(input: string, description: string) { - this.examples.push(`${input} ${description}`); + this.examples.push([input, description]); return this; } hide(name: string) { this.flags.set(name, { ...this.flags.get(name), hidden: true }); return this; } - group() { + group(names: string | string[]) { + for (const name of list(names)) { + this.groupedOptions.add(name); + } return this; } demandCommand() { @@ -142,23 +163,6 @@ function aliases(def: Definition) { return names; } -function wrapLine(text: string, width: number): string[] { - if (text.length <= width) { - return [text]; - } - const lines = [""]; - for (const word of text.split(/\s+/)) { - const index = lines.length - 1; - const line = lines[index]; - if (line && line.length + word.length + 1 > width) { - lines.push(word); - } else { - lines[index] = line ? `${line} ${word}` : word; - } - } - return lines; -} - function renderHelp( def: Definition, path: string[], @@ -166,114 +170,173 @@ function renderHelp( width: number ) { const prefix = ["cf", ...path].join(" "); - const heading = def.heading - ? def.heading.replace(/^\$0/, "cf") - : mod + const ui = cliui({ width, wrap: Number.isFinite(width) }); + const columnWidth = (labels: string[]) => + Math.min( + Math.floor(width / 2), + Math.max(0, ...labels.map((label) => stringWidth(label))) + ) + 4; + const section = (title: string) => ui.div(theme.brand(title)); + const endRow = (extra?: string) => + extra + ? ui.div({ text: extra, padding: [0, 0, 0, 2], align: "right" }) + : ui.div(); + const heading = + def.heading || + (mod ? `${prefix}${words(mod) .slice(1) .map((word) => ` ${word}`) - .join("")}\n\n${mod.describe || ""}` - : "cf [options]\n\nThe Cloudflare CLI - manage your Cloudflare resources"; - const sections = [ - heading - .split("\n") - .flatMap((line) => wrapLine(line, width)) - .join("\n"), - ]; - const section = (title: string, rows: string[]) => { - if (rows.length) { - sections.push( - `${theme.brand(title)}\n${rows.map((row) => ` ${row}`).join("\n")}` + .join("")}${mod.describe ? `\n\n${mod.describe}` : ""}` + : "cf [options]\n\nThe Cloudflare CLI - manage your Cloudflare resources"); + ui.div({ text: heading.replaceAll("$0", "cf") }); + ui.div(); + const children = def.children + .filter((child) => child.describe !== false) + .map((child) => ({ + label: `${prefix} ${words(child).join(" ")}`, + description: String(child.describe || ""), + aliases: [...list(child.command).slice(1), ...list(child.aliases)], + })) + .sort((left, right) => left.label.localeCompare(right.label)); + if (children.length) { + section("Commands"); + const column = columnWidth(children.map((child) => child.label)); + for (const child of children) { + ui.span( + { text: child.label, padding: [0, 2, 0, 2], width: column }, + { text: child.description } + ); + endRow( + child.aliases.length + ? `[aliases: ${child.aliases.join(", ")}]` + : undefined ); } - }; - section( - "Commands", - def.children - .filter((child) => child.describe !== false) - .map( - (child) => - `${prefix} ${words(child).join(" ")} ${child.describe || ""}` - ) - .sort() - ); - const opts = (entries: [string, Options][], positional = false) => { + ui.div(); + } + const opts = ( + title: string, + entries: [string, Options][], + positional = false + ) => { const flags = entries .filter(([, opt]) => !opt.hidden) .map(([key, opt]) => { - const names = [...list(opt.alias), key]; + const names = [key, ...list(opt.alias)]; const label = positional - ? key - : (names.some((name) => name.length === 1) ? "" : " ") + - names + ? names.join(", ") + : names + .sort( + (left, right) => + Number(left.length > 1) - Number(right.length > 1) + ) .map((name) => (name.length === 1 ? `-${name}` : `--${name}`)) .join(", "); - const description = opt.description ?? opt.describe ?? ""; - const metadata = [ - opt.type && `[${opt.type}]`, - opt.demandOption && "[required]", - opt.choices && `[choices: ${opt.choices.join(", ")}]`, - opt.default !== undefined && - `[default: ${JSON.stringify(opt.default)}]`, + const indent = !positional && label.startsWith("--") ? 4 : 0; + const variadic = + positional && + mod && + words(mod).some( + (word) => + word.slice(1, -1).replace(/\.{2,3}$/, "") === key && + /\.{2,3}[\]>]$/.test(word) + ); + const type = opt.array || variadic ? "array" : opt.type; + const defaultValue = opt.default ?? (variadic ? [] : undefined); + const extra = [ + type && `[${type}]`, + opt.demandOption && + (!positional || + !mod || + words(mod).some( + (word) => word.slice(1, -1).replace(/\.{2,3}$/, "") === key + )) && + "[required]", + opt.choices && + `[choices: ${opt.choices.map((value) => JSON.stringify(value)).join(", ")}]`, + defaultValue !== undefined && + `[default: ${opt.defaultDescription ?? JSON.stringify(defaultValue)}]`, ] .filter(Boolean) .join(" "); - return { label, description, metadata }; + return { + label, + indent, + extra, + description: String(opt.description ?? opt.describe ?? ""), + }; }); - const column = Math.max(0, ...flags.map((flag) => flag.label.length)) + 2; - return flags.map(({ label, description, metadata }) => { - const lines = String(description) - .split("\n") - .flatMap((line) => wrapLine(line, width - column - 2)); - const last = lines.length - 1; - if (metadata) { - if ( - Number.isFinite(width) && - (lines[last]?.length ?? 0) + 1 + metadata.length > width - column - 2 - ) { - lines.push(""); - } - const end = lines.length - 1; - lines[end] = - (lines[end] ?? "").padEnd( - Number.isFinite(width) - ? width - column - 2 - metadata.length - : (lines[end]?.length ?? 0) + 1 - ) + metadata; - } - return lines - .map( - (line, index) => - (index ? " ".repeat(column + 2) : label.padEnd(column)) + line - ) - .join("\n"); - }); + if (!flags.length) { + return; + } + section(title); + const column = columnWidth( + flags.map((flag) => " ".repeat(flag.indent) + flag.label) + ); + for (const flag of flags) { + ui.span( + { + text: flag.label, + width: column, + padding: [0, 2, 0, 2 + flag.indent], + }, + flag.description + ); + endRow(flag.extra); + } + ui.div(); }; - section("Positionals", opts([...def.positions], true)); - section( - "Global flags", - opts( - [...def.flags] - .filter(([key]) => Object.hasOwn(GLOBAL_OPTIONS, key)) - .concat( - Object.entries(BUILTIN_OPTIONS).map( - ([key, opt]): [string, Options] => [ - key, - { ...opt, type: "boolean" }, - ] - ) - ) - ) + const local = [...def.flags].filter( + ([key]) => + !Object.hasOwn(GLOBAL_OPTIONS, key) && + !Object.hasOwn(BUILTIN_OPTIONS, key) && + (!def.positions.has(key) || def.groupedOptions.has(key)) ); - section( - "Options", - opts([...def.flags].filter(([key]) => !Object.hasOwn(GLOBAL_OPTIONS, key))) + opts( + "Positionals", + [...def.positions].map(([key, opt]) => [ + key, + { ...opt, ...def.flags.get(key) }, + ]), + true ); - section("Examples", def.examples); + if (def.groupedOptions.size) { + opts("Options", local); + } + opts( + "Global flags", + [...def.flags] + .filter(([key]) => Object.hasOwn(GLOBAL_OPTIONS, key)) + .concat( + Object.entries(BUILTIN_OPTIONS).map(([key, opt]): [string, Options] => [ + key, + { type: "boolean", ...opt, ...def.flags.get(key) }, + ]) + ) + ); + if (!def.groupedOptions.size) { + opts("Options", local); + } + if (def.examples.length) { + section("Examples"); + const column = columnWidth(def.examples.map(([example]) => example)); + for (const [example, description] of def.examples) { + ui.div( + { + text: example.replaceAll("$0", "cf"), + width: column, + padding: [0, 2, 0, 2], + }, + { text: description } + ); + } + ui.div(); + } if (def.footer) { - sections.push(def.footer); + ui.div(`${def.footer.replaceAll("$0", "cf")}\n`); } - return sections.join("\n\n"); + return ui.toString().trimEnd(); } function closest(input: string, children: Module[]) { @@ -344,13 +407,15 @@ export function createParser( mod, hooks.helpWidth ?? (process.stdout.columns || 80) ), - command() + def.autoHelp || helpOnly ? command() : undefined ); const showHelp = () => { hooks.shown(command() ?? "cf"); console.log(help()); }; let def = new Definition(showHelp); + def.footer = + "For more information, visit https://developers.cloudflare.com/"; def.children = roots; def.requireChild = true; const delimiter = input.indexOf("--"); @@ -387,8 +452,11 @@ export function createParser( } const key = names.get(previous.replace(/^--?/, "")); return ( - !key || - (def.flags.get(key)?.type === "boolean" && + previous.includes("=") || + previous.startsWith("--no-") || + ["-h", "--help"].includes(previous) || + (!!key && + def.flags.get(key)?.type === "boolean" && !["true", "false"].includes(token)) ); }); @@ -427,7 +495,7 @@ export function createParser( const parent = def; def = new Definition(showHelp); for (const [name, opt] of parent.flags) { - if (opt.global) { + if (opt.global !== false) { def.flags.set(name, opt); } } @@ -466,7 +534,7 @@ export function createParser( : { kind: "parsed", brief: opt.description ?? "", - parse: opt.type === "number" ? numberParser : String, + parse: (literal: string) => parseLiteral(literal, opt), optional: true, variadic: true, inferEmpty: !opt.requiresArg && !opt.nargs, @@ -475,6 +543,29 @@ export function createParser( const parsedTokens: string[] = [], positionals: string[] = [], unknown: string[] = []; + const switches = new Map(); + const coercions = new Map(); + const trackCoercion = (opt: Options, value: unknown) => { + if (opt.coerce) { + const values = coercions.get(opt) ?? []; + values.push(value); + coercions.set(opt, values); + } + }; + const checkCoercions = () => { + for (const [opt, values] of coercions) { + opt.coerce?.(values.length === 1 ? values[0] : values); + } + }; + const addUnknown = (name: string) => { + for (const alias of def.config["camel-case-expansion"] === false + ? [name] + : [name, camel(name)]) { + if (!unknown.includes(alias)) { + unknown.push(alias); + } + } + }; for (let idx = 0; idx < args.length; idx++) { const arg = args[idx]; if (arg === undefined) { @@ -483,7 +574,7 @@ export function createParser( if (def.autoHelp && (arg === "--help" || arg === "-h")) { continue; } - if (!arg.startsWith("-") || arg === "-" || /^-\d/.test(arg)) { + if (!arg.startsWith("-") || arg === "-" || negativeNumber.test(arg)) { positionals.push(arg); continue; } @@ -493,9 +584,8 @@ export function createParser( ) { const shortNames = arg.slice(1).split(""); if ( - shortNames.every( - (name) => def.flags.get(names.get(name) ?? "")?.type === "boolean" - ) + !def.config["unknown-options-as-args"] || + shortNames.every((name) => names.has(name)) ) { args.splice(idx, 1, ...shortNames.map((name) => `-${name}`)); idx--; @@ -506,6 +596,7 @@ export function createParser( let key = names.get(spelling); const negated = !key && + inline === undefined && spelling.startsWith("no-") && def.config["boolean-negation"] !== false; if (negated) { @@ -522,7 +613,12 @@ export function createParser( Object.hasOwn(Object.prototype, spelling) || spelling === "prototype" ) { - unknown.push(spelling); + const unknownName = negated ? spelling.slice(3) : spelling; + addUnknown( + def.config["dot-notation"] === false + ? unknownName + : (unknownName.split(".")[0] ?? unknownName) + ); if ( inline === undefined && args[idx + 1] && @@ -542,7 +638,7 @@ export function createParser( ? { kind: "parsed", brief: "", - parse: String, + parse: (literal: string) => literal.slice(1), optional: true, variadic: true, } @@ -553,8 +649,8 @@ export function createParser( return fail(`Unknown argument: ${spelling}`); } if (negated && opt.type !== "boolean") { - opt.coerce?.(false); - unknown.push(spelling); + trackCoercion(opt, false); + parsedTokens.push(`--${key}`, "!"); continue; } const flag = `--${key}`; @@ -564,45 +660,35 @@ export function createParser( (!negated && ["true", "false"].includes(args[idx + 1] ?? "") ? args[++idx] : undefined); - if (value !== undefined && value !== "true" && value !== "false") { - return fail(`Expected true or false for --${key}`); - } - if (negated && inline !== undefined) { - return fail(`Cannot pass a value to --${spelling}`); - } - parsedTokens.push( - negated - ? `${flag}=false` - : value === undefined - ? flag - : `${flag}=${value}` + switches.set( + flag, + !negated && (value === undefined || value === "true") ); continue; } const takesValue = () => idx + 1 < args.length && (!args[idx + 1]?.startsWith("-") || - /^-\d/.test(args[idx + 1] ?? "") || + negativeNumber.test(args[idx + 1] ?? "") || args[idx + 1] === "-"); let value = inline ?? (takesValue() ? args[++idx] : undefined); - if (value === undefined && (opt.requiresArg || opt.nargs)) { + if (!wantsHelp && value === undefined && (opt.requiresArg || opt.nargs)) { return fail(`Not enough arguments following: ${key}`); } - const pushValue = (literal: string) => { - if (literal.startsWith("-") && !/[\r\n\u2028\u2029]/.test(literal)) { - parsedTokens.push(`${flag}=${literal}`); - } else { - parsedTokens.push(flag, literal); + const pushValue = (raw: string | undefined) => { + if (raw !== undefined || !opt.requiresArg) { + trackCoercion(opt, raw ?? ""); } + parsedTokens.push(flag, raw === undefined ? "" : `:${raw}`); }; - pushValue(value ?? ""); + pushValue(value); while ( (opt.array || opt.type === "array") && !opt.nargs && takesValue() ) { value = args[++idx]; - pushValue(value ?? ""); + pushValue(value); } } if (positionals.length > spec.length && !spec.at(-1)?.many) { @@ -614,16 +700,23 @@ export function createParser( ); } if (wantsHelp || (def.requireChild && mod)) { - if (!wantsHelp && unknown.length) { - return fail(`Unknown argument: ${unknown[0]}`); - } if (helpOnly) { return help(); } showHelp(); - return; + if (wantsHelp || !unknown.length) { + checkCoercions(); + return; + } } if (unknown.length) { + checkCoercions(); + const required = spec.filter((item) => item.required).length; + if (positionals.length < required) { + return fail( + `Not enough non-option arguments: got ${positionals.length}, need at least ${required}` + ); + } return fail( `Unknown argument${unknown.length > 1 ? "s" : ""}: ${unknown.join(", ")}`, mod ? undefined : "missing-command" @@ -696,9 +789,18 @@ export function createParser( diagnostic += text; }, }; - await run(app, [...parsedTokens, "--", ...positionals], { - process: { stdout: stream, stderr: stream }, - }); + await run( + app, + [ + ...parsedTokens, + ...Array.from(switches, ([flag, value]) => `${flag}=${value}`), + "--", + ...positionals, + ], + { + process: { stdout: stream, stderr: stream }, + } + ); if (!result) { return fail(diagnostic.trim() || "Invalid arguments"); } @@ -750,11 +852,15 @@ export function createParser( assign(key, result[key], opt); } for (const [idx, item] of spec.entries()) { - const opt = def.positions.get(item.key) ?? {}; + const key = def.positions.has(item.key) + ? item.key + : ([...def.positions.keys()].find((name) => camel(name) === item.key) ?? + item.key); + const opt = def.positions.get(key) ?? {}; const value = item.many ? operands.slice(idx) : operands[idx]; if (value !== undefined || opt.default !== undefined) { assign( - item.key, + key, opt.type === "number" && value !== undefined ? Number(value) : value, opt ); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d882527456..11485af4f9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -339,6 +339,9 @@ importers: ci-info: specifier: ^4.5.0 version: 4.5.0 + cliui: + specifier: 9.0.1 + version: 9.0.1 esbuild: specifier: 0.28.2 version: 0.28.2 diff --git a/scripts/README.md b/scripts/README.md index 3eeafec622..0e17a5ef77 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -1,5 +1,7 @@ # Forge and OpenAPI updates +To check parser compatibility, build both revisions with the same Node version and run `node scripts/compare-cli-parity.mjs `. The script compares exit status and exact stdout/stderr bytes for metadata-discovered help routes, generated HTTP dry runs and selected parser edge cases. It uses temporary homes, no credentials and a blocked fetch implementation; it does not exercise live services or interactive terminals. + The two generator inputs have independent update paths: | Automation | Update branch | Input it updates | diff --git a/scripts/compare-cli-parity.mjs b/scripts/compare-cli-parity.mjs new file mode 100644 index 0000000000..916a68f8eb --- /dev/null +++ b/scripts/compare-cli-parity.mjs @@ -0,0 +1,212 @@ +import assert from "node:assert/strict"; +import { spawnSync } from "node:child_process"; +import { createHash } from "node:crypto"; +import { mkdtempSync, readFileSync, rmSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join, resolve } from "node:path"; +import { mock } from "node:test"; +import { fileURLToPath, pathToFileURL } from "node:url"; + +const probes = [ + [], + ["--version"], + ["nonesuch"], + ["zons"], + ["kv", "namespaces", "typo", "--help"], + ["--wat"], + ["kv", "namespaces", "update"], + ["zones", "list", "extra"], + ["zones", "list", "--bad", "--dry-run"], + ["zones", "list", "--dry-run"], + ["--quiet", "zones", "list", "--per-page=2", "--dry-run"], + ["zones", "list", "--per-page", "oops", "--dry-run"], + ["zones", "list", "--name", "a", "--name=b", "--dry-run"], + ["zones", "list", "--quiet=yes", "--dry-run"], + ["zones", "list", "-q", "--no-quiet", "--dry-run"], + ["zones", "list", "--status", "typo", "--dry-run"], + ["zones", "list", "--page", "-2", "--dry-run"], + ["--per-page", "2", "zones", "list", "--dry-run"], + ["zones", "list", "--page", "--dry-run"], + ["zones", "list", "--page=", "--dry-run"], + ["zones", "list", "--page", "2", "--page", "--dry-run"], + ["zones", "list", "--bad-flag", "--dry-run"], + ["zones", "list", "--no-dry-run=true"], + ["zones", "list", "-qz", "example", "--dry-run"], + ["zones", "list", "--no-page", "--dry-run"], + ["zones", "list", "--name=a", "--no-name", "--dry-run"], + ["zones", "list", "--page", "-.5", "--dry-run"], + ["zones", "list", "-ab", "--dry-run"], + ["zones", "list", "--bad.one", "--dry-run"], + ["zones", "--dry-run", "list"], + ["--profile", "--help"], + ["zones", "list", "--zone", "--help"], + ["zones", "list", "--zone", "--bad"], + ["zones", "list", "-zabcd", "--dry-run"], + ["kv", "namespaces", "update", "--wat"], + ["o11y", "issues", "get", "parity-group", "--dry-run"], + ["dev", "--dry-run", "--", "--port", "1234"], + ["schema", "zones", "list"], + ["cli", "search", "List zones"], +]; + +async function capture(dist, cases) { + const { runMain, CliExit } = await import( + pathToFileURL(join(dist, "index.mjs")).href + ); + globalThis.fetch = () => { + throw new Error("Network access disabled during parity comparison"); + }; + const results = []; + for (const args of cases) { + const out = [], + err = []; + const stdout = mock.method(process.stdout, "write", (chunk) => { + out.push(Buffer.from(chunk)); + return true; + }); + const stderr = mock.method(process.stderr, "write", (chunk) => { + err.push(Buffer.from(chunk)); + return true; + }); + let code = 0; + try { + await runMain(args); + } catch (error) { + code = error instanceof CliExit ? error.code : 1; + } finally { + stdout.mock.restore(); + stderr.mock.restore(); + } + const summarize = (chunks) => + process.env.CF_PARITY_DETAIL + ? Buffer.concat(chunks).toString() + : createHash("sha256").update(Buffer.concat(chunks)).digest("hex"); + results.push([code, summarize(out), summarize(err)]); + } + return results; +} + +if (process.argv[2] === "--capture") { + console.log( + JSON.stringify( + await capture(process.argv[3], JSON.parse(readFileSync(0, "utf8"))) + ) + ); +} else { + const [reference, candidate] = process.argv + .slice(2) + .map((dir) => resolve(dir)); + assert( + reference && candidate, + "Usage: node scripts/compare-cli-parity.mjs " + ); + const paths = new Set([""]); + const operations = new Map(); + const handwritten = new Set(); + const sampleValue = (param) => + String( + param.enum?.[0] ?? { number: 2, boolean: true }[param.type] ?? "parity-id" + ); + for (const dist of [reference, candidate]) { + for (const file of ["commands", "hand-written-commands"]) { + const { commands } = JSON.parse( + readFileSync(join(dist, "_meta", `${file}.json`), "utf8") + ); + for (const command of commands) { + const { fullPath } = command; + for (let depth = 1; depth <= fullPath.length; depth++) { + paths.add(fullPath.slice(0, depth).join(" ")); + } + const route = fullPath.join(" "); + if (file === "hand-written-commands") { + handwritten.add(route); + } else if ( + command.httpMethod && + command.options.some((opt) => opt.name === "dry-run") + ) { + operations.set(route, [ + ...fullPath, + ...command.arguments + .filter((param) => param.required) + .map(sampleValue), + ...command.options + .filter((opt) => opt.required) + .map((opt) => `--${opt.name}=${sampleValue(opt)}`), + "--dry-run", + ]); + } + } + } + } + for (const route of handwritten) { + operations.delete(route); + } + const cases = [ + ...Array.from(paths, (route) => [ + ...route.split(" ").filter(Boolean), + "--help", + ]), + ...probes, + ...operations.values(), + ]; + const compare = (dist, selected, detail) => { + const home = mkdtempSync(join(tmpdir(), "cf-parser-parity-")); + try { + const result = spawnSync( + process.execPath, + [fileURLToPath(import.meta.url), "--capture", dist], + { + cwd: home, + env: { + PATH: process.env.PATH, + SystemRoot: process.env.SystemRoot, + HOME: home, + USERPROFILE: home, + XDG_CONFIG_HOME: home, + XDG_STATE_HOME: home, + CI: "1", + NO_COLOR: "1", + CF_SEND_TELEMETRY: "false", + CLOUDFLARE_ACCOUNT_ID: "00000000000000000000000000000001", + CLOUDFLARE_ZONE_ID: "00000000000000000000000000000002", + CF_PARITY_DETAIL: detail ? "1" : "", + }, + encoding: "utf8", + input: JSON.stringify(selected), + maxBuffer: 64 * 1024 * 1024, + } + ); + assert.equal(result.status, 0, result.error?.message ?? result.stderr); + return JSON.parse(result.stdout); + } finally { + rmSync(home, { recursive: true, force: true }); + } + }; + const before = compare(reference, cases, false), + after = compare(candidate, cases, false); + const mismatches = cases.filter( + (_, idx) => JSON.stringify(before[idx]) !== JSON.stringify(after[idx]) + ); + console.log( + `${cases.length - mismatches.length}/${cases.length} invocations matched (exit status, stdout and stderr).` + ); + console.log( + `${paths.size} help routes; ${probes.length} explicit probes; ${operations.size} generated dry runs (${before.slice(paths.size + probes.length).filter(([code]) => code === 0).length} successful on reference).` + ); + if (mismatches.length) { + console.log(JSON.stringify(mismatches)); + const sample = mismatches.slice(0, 3); + console.log( + JSON.stringify( + { + sample, + before: compare(reference, sample, true), + after: compare(candidate, sample, true), + }, + null, + 2 + ) + ); + process.exitCode = 1; + } +} From 1faf87844872795096355f1f4093380a714d07cf Mon Sep 17 00:00:00 2001 From: Brendan Irvine-Broque Date: Tue, 24 Nov 2026 10:27:53 -0800 Subject: [PATCH 3/7] refactor(cli): emit native Stricli commands and route maps --- docs/architecture.md | 6 +- packages/cli/AGENTS.md | 4 +- packages/cli/generator/plugin/emit/builder.ts | 194 +-- packages/cli/generator/plugin/emit/handler.ts | 6 +- packages/cli/generator/plugin/files.ts | 46 +- .../hand-written-leaf-commands.test.ts | 26 +- .../generator/plugin/body-description.test.ts | 5 +- .../generator/plugin/body-positionals.test.ts | 4 +- .../__tests__/generator/plugin/emit.test.ts | 67 +- .../generator/plugin/forge-model.test.ts | 61 +- .../plugin/hand-written-roots.test.ts | 4 +- .../generator/plugin/json-shape.test.ts | 5 +- .../plugin/metadata-defaults.test.ts | 10 +- .../generator/plugin/metadata-force.test.ts | 6 +- .../plugin/metadata-multipart.test.ts | 9 +- .../generator/plugin/metadata-text.test.ts | 7 +- .../generator/plugin/multipart-files.test.ts | 8 +- .../plugin/nested-array-flags.test.ts | 2 + .../plugin/nested-body-overrides.test.ts | 2 + .../generator/plugin/nested-unions.test.ts | 8 +- .../generator/plugin/normalization.test.ts | 6 +- .../generator/plugin/oneof-body-flags.test.ts | 2 + .../plugin/path-parameter-overrides.test.ts | 11 +- .../plugin/query-array-flags.test.ts | 10 +- .../plugin/required-raw-bodies.test.ts | 4 +- .../plugin/scalar-union-positionals.test.ts | 14 +- .../plugin/variant-descriptions.test.ts | 10 +- .../src/__tests__/helpers/command-parser.ts | 47 + .../cli/src/__tests__/lib/stricli.test.ts | 64 +- .../abuse-reports/appeals/eligibility.ts | 47 +- .../_generated/abuse-reports/appeals/index.ts | 15 +- .../_generated/abuse-reports/create.ts | 642 ++++---- .../_generated/abuse-reports/emails/index.ts | 17 +- .../abuse-reports/emails/list-submitted.ts | 67 +- .../_generated/abuse-reports/emails/list.ts | 66 +- .../_generated/abuse-reports/get-submitted.ts | 47 +- .../commands/_generated/abuse-reports/get.ts | 47 +- .../_generated/abuse-reports/index.ts | 29 +- .../abuse-reports/list-submitted.ts | 143 +- .../commands/_generated/abuse-reports/list.ts | 151 +- .../abuse-reports/mitigations/index.ts | 17 +- .../abuse-reports/mitigations/list.ts | 135 +- .../abuse-reports/mitigations/review.ts | 230 +-- .../src/commands/_generated/access/index.ts | 33 +- .../accounts/applications/create.ts | 129 +- .../accounts/applications/delete.ts | 51 +- .../_generated/accounts/applications/get.ts | 45 +- .../_generated/accounts/applications/index.ts | 27 +- .../_generated/accounts/applications/list.ts | 122 +- .../accounts/applications/lookup.ts | 92 +- .../accounts/applications/references.ts | 51 +- .../accounts/applications/update.ts | 107 +- .../accounts/billing/create-setup-intent.ts | 40 +- .../accounts/billing/get-bad-debt.ts | 40 +- .../accounts/billing/get-credits.ts | 40 +- .../accounts/billing/get-receipt-pdf.ts | 63 +- .../accounts/billing/get-unpaid-invoices.ts | 40 +- .../accounts/billing/history/index.ts | 13 +- .../accounts/billing/history/list.ts | 70 +- .../_generated/accounts/billing/index.ts | 31 +- .../accounts/billing/pay-invoice.ts | 77 +- .../billing/payment-methods/create.ts | 248 +-- .../billing/payment-methods/delete.ts | 57 +- .../accounts/billing/payment-methods/get.ts | 51 +- .../accounts/billing/payment-methods/index.ts | 25 +- .../accounts/billing/payment-methods/list.ts | 60 +- .../billing/payment-methods/set-default.ts | 51 +- .../billing/payment-methods/update.ts | 259 ++-- .../accounts/billing/toggle-pdf-invoices.ts | 55 +- .../_generated/accounts/categories/get.ts | 47 +- .../_generated/accounts/categories/index.ts | 17 +- .../_generated/accounts/categories/list.ts | 72 +- .../commands/_generated/accounts/create.ts | 97 +- .../commands/_generated/accounts/delete.ts | 46 +- .../_generated/accounts/entitlements/get.ts | 40 +- .../_generated/accounts/entitlements/index.ts | 13 +- .../src/commands/_generated/accounts/get.ts | 40 +- .../src/commands/_generated/accounts/index.ts | 49 +- .../src/commands/_generated/accounts/list.ts | 74 +- .../_generated/accounts/logs/audit/history.ts | 112 +- .../_generated/accounts/logs/audit/index.ts | 19 +- .../_generated/accounts/logs/audit/list.ts | 670 +++++---- .../accounts/logs/audit/product-categories.ts | 40 +- .../_generated/accounts/logs/index.ts | 15 +- .../_generated/accounts/members/create.ts | 98 +- .../_generated/accounts/members/delete.ts | 57 +- .../_generated/accounts/members/get.ts | 51 +- .../_generated/accounts/members/index.ts | 23 +- .../_generated/accounts/members/list.ts | 86 +- .../_generated/accounts/members/update.ts | 88 +- .../src/commands/_generated/accounts/move.ts | 62 +- .../accounts/organizations/index.ts | 13 +- .../_generated/accounts/organizations/list.ts | 40 +- .../_generated/accounts/profile/get.ts | 40 +- .../_generated/accounts/profile/index.ts | 17 +- .../_generated/accounts/profile/update.ts | 102 +- .../subscriptions/cancel-delayed-downgrade.ts | 62 +- .../subscriptions/create-cancel-reason.ts | 83 +- .../accounts/subscriptions/create.ts | 153 +- .../accounts/subscriptions/delete.ts | 57 +- .../subscriptions/get-by-identifier.ts | 51 +- .../subscriptions/get-cancel-reason.ts | 51 +- .../_generated/accounts/subscriptions/get.ts | 40 +- .../accounts/subscriptions/index.ts | 29 +- .../accounts/subscriptions/update.ts | 164 +- .../_generated/accounts/tokens/create.ts | 110 +- .../_generated/accounts/tokens/delete.ts | 53 +- .../_generated/accounts/tokens/get.ts | 47 +- .../_generated/accounts/tokens/index.ts | 29 +- .../_generated/accounts/tokens/list.ts | 77 +- .../tokens/permission-groups/index.ts | 13 +- .../accounts/tokens/permission-groups/list.ts | 62 +- .../_generated/accounts/tokens/roll.ts | 53 +- .../_generated/accounts/tokens/update.ts | 125 +- .../_generated/accounts/tokens/verify.ts | 37 +- .../accounts/transformations/index.ts | 13 +- .../accounts/transformations/list.ts | 40 +- .../commands/_generated/accounts/update.ts | 79 +- .../_generated/accounts/ut-billing/edit.ts | 60 +- .../_generated/accounts/ut-billing/get.ts | 40 +- .../_generated/accounts/ut-billing/index.ts | 17 +- .../acm/custom-trust-store/create.ts | 62 +- .../acm/custom-trust-store/delete.ts | 57 +- .../_generated/acm/custom-trust-store/get.ts | 51 +- .../acm/custom-trust-store/index.ts | 21 +- .../_generated/acm/custom-trust-store/list.ts | 77 +- .../cli/src/commands/_generated/acm/index.ts | 17 +- .../commands/_generated/acm/total-tls/edit.ts | 72 +- .../commands/_generated/acm/total-tls/get.ts | 37 +- .../_generated/acm/total-tls/index.ts | 17 +- .../address-maps/accounts/create.ts | 61 +- .../address-maps/accounts/delete.ts | 67 +- .../addressing/address-maps/accounts/index.ts | 17 +- .../addressing/address-maps/create.ts | 88 +- .../addressing/address-maps/delete.ts | 57 +- .../addressing/address-maps/edit.ts | 88 +- .../_generated/addressing/address-maps/get.ts | 51 +- .../addressing/address-maps/index.ts | 29 +- .../address-maps/ips/bulk-create.ts | 72 +- .../address-maps/ips/bulk-delete.ts | 78 +- .../addressing/address-maps/ips/create.ts | 61 +- .../addressing/address-maps/ips/delete.ts | 67 +- .../addressing/address-maps/ips/index.ts | 21 +- .../addressing/address-maps/list.ts | 40 +- .../address-maps/zones/bulk-create.ts | 72 +- .../address-maps/zones/bulk-delete.ts | 78 +- .../addressing/address-maps/zones/create.ts | 61 +- .../addressing/address-maps/zones/delete.ts | 67 +- .../addressing/address-maps/zones/index.ts | 21 +- .../commands/_generated/addressing/index.ts | 25 +- .../_generated/addressing/leases/index.ts | 13 +- .../_generated/addressing/leases/list.ts | 37 +- .../addressing/loa-documents/create.ts | 70 +- .../addressing/loa-documents/get.ts | 57 +- .../addressing/loa-documents/index.ts | 19 +- .../addressing/loa-documents/list.ts | 40 +- .../prefixes/advertisement-status/edit.ts | 68 +- .../prefixes/advertisement-status/get.ts | 51 +- .../prefixes/advertisement-status/index.ts | 17 +- .../prefixes/bgp-prefixes/create.ts | 71 +- .../prefixes/bgp-prefixes/delete.ts | 67 +- .../addressing/prefixes/bgp-prefixes/edit.ts | 97 +- .../addressing/prefixes/bgp-prefixes/get.ts | 61 +- .../addressing/prefixes/bgp-prefixes/index.ts | 23 +- .../addressing/prefixes/bgp-prefixes/list.ts | 50 +- .../_generated/addressing/prefixes/create.ts | 95 +- .../addressing/prefixes/delegations/create.ts | 83 +- .../addressing/prefixes/delegations/delete.ts | 67 +- .../addressing/prefixes/delegations/index.ts | 19 +- .../addressing/prefixes/delegations/list.ts | 50 +- .../_generated/addressing/prefixes/delete.ts | 57 +- .../_generated/addressing/prefixes/edit.ts | 71 +- .../_generated/addressing/prefixes/get.ts | 51 +- .../_generated/addressing/prefixes/index.ts | 33 +- .../_generated/addressing/prefixes/list.ts | 40 +- .../prefixes/service-bindings/create.ts | 83 +- .../prefixes/service-bindings/delete.ts | 67 +- .../prefixes/service-bindings/get.ts | 61 +- .../prefixes/service-bindings/index.ts | 21 +- .../prefixes/service-bindings/list.ts | 50 +- .../addressing/prefixes/validate/create.ts | 51 +- .../addressing/prefixes/validate/index.ts | 15 +- .../addressing/regional-hostnames/create.ts | 82 +- .../addressing/regional-hostnames/delete.ts | 59 +- .../addressing/regional-hostnames/edit.ts | 73 +- .../addressing/regional-hostnames/get.ts | 53 +- .../addressing/regional-hostnames/index.ts | 25 +- .../addressing/regional-hostnames/list.ts | 40 +- .../regional-hostnames/regions/index.ts | 13 +- .../regional-hostnames/regions/list.ts | 40 +- .../_generated/addressing/services/index.ts | 13 +- .../_generated/addressing/services/list.ts | 40 +- .../agent-memory/create-namespace.ts | 57 +- .../_generated/agent-memory/delete-memory.ts | 69 +- .../agent-memory/delete-namespace.ts | 53 +- .../_generated/agent-memory/delete-profile.ts | 63 +- .../_generated/agent-memory/delete-session.ts | 69 +- .../_generated/agent-memory/get-memory.ts | 62 +- .../_generated/agent-memory/get-namespace.ts | 47 +- .../commands/_generated/agent-memory/index.ts | 41 +- .../_generated/agent-memory/ingest.ts | 89 +- .../_generated/agent-memory/list-memories.ts | 94 +- .../agent-memory/list-namespaces.ts | 78 +- .../_generated/agent-memory/list-profiles.ts | 68 +- .../_generated/agent-memory/recall.ts | 115 +- .../_generated/agent-memory/remember.ts | 87 +- .../_generated/agent-memory/summary.ts | 77 +- .../src/commands/_generated/ai-audit/index.ts | 15 +- .../_generated/ai-audit/robots/bulk-get.ts | 52 +- .../_generated/ai-audit/robots/get.ts | 52 +- .../_generated/ai-audit/robots/index.ts | 17 +- .../ai-gateway/custom-domains/create.ts | 92 +- .../ai-gateway/custom-domains/delete.ts | 67 +- .../ai-gateway/custom-domains/get.ts | 61 +- .../ai-gateway/custom-domains/index.ts | 21 +- .../ai-gateway/custom-domains/list.ts | 73 +- .../ai-gateway/custom-providers/create.ts | 127 +- .../ai-gateway/custom-providers/delete.ts | 51 +- .../ai-gateway/custom-providers/get.ts | 45 +- .../ai-gateway/custom-providers/index.ts | 23 +- .../ai-gateway/custom-providers/list.ts | 59 +- .../ai-gateway/custom-providers/update.ts | 139 +- .../ai-gateway/dynamic-routing/create.ts | 74 +- .../ai-gateway/dynamic-routing/delete.ts | 57 +- .../dynamic-routing/deployments/create.ts | 71 +- .../dynamic-routing/deployments/index.ts | 17 +- .../dynamic-routing/deployments/list.ts | 65 +- .../ai-gateway/dynamic-routing/get.ts | 51 +- .../ai-gateway/dynamic-routing/index.ts | 27 +- .../ai-gateway/dynamic-routing/list.ts | 63 +- .../ai-gateway/dynamic-routing/update.ts | 68 +- .../dynamic-routing/versions/create.ts | 73 +- .../dynamic-routing/versions/get.ts | 53 +- .../dynamic-routing/versions/index.ts | 19 +- .../dynamic-routing/versions/list.ts | 65 +- .../_generated/ai-gateway/gateways/create.ts | 757 +++++----- .../_generated/ai-gateway/gateways/delete.ts | 57 +- .../_generated/ai-gateway/gateways/get-url.ts | 57 +- .../_generated/ai-gateway/gateways/get.ts | 51 +- .../_generated/ai-gateway/gateways/index.ts | 27 +- .../_generated/ai-gateway/gateways/list.ts | 56 +- .../ai-gateway/gateways/providers/create.ts | 123 +- .../ai-gateway/gateways/providers/delete.ts | 61 +- .../ai-gateway/gateways/providers/get.ts | 55 +- .../ai-gateway/gateways/providers/index.ts | 25 +- .../ai-gateway/gateways/providers/list.ts | 59 +- .../ai-gateway/gateways/providers/test.ts | 65 +- .../ai-gateway/gateways/providers/update.ts | 77 +- .../_generated/ai-gateway/gateways/update.ts | 757 +++++----- .../commands/_generated/ai-gateway/index.ts | 25 +- .../_generated/ai-gateway/logs/delete.ts | 89 +- .../_generated/ai-gateway/logs/get-request.ts | 55 +- .../ai-gateway/logs/get-response.ts | 55 +- .../_generated/ai-gateway/logs/get.ts | 55 +- .../_generated/ai-gateway/logs/index.ts | 25 +- .../_generated/ai-gateway/logs/list.ts | 264 ++-- .../_generated/ai-gateway/logs/update.ts | 91 +- .../ai-gateway/model-aliases/create.ts | 100 +- .../ai-gateway/model-aliases/delete.ts | 57 +- .../ai-gateway/model-aliases/get.ts | 51 +- .../ai-gateway/model-aliases/index.ts | 23 +- .../ai-gateway/model-aliases/list.ts | 55 +- .../ai-gateway/model-aliases/update.ts | 106 +- .../_generated/ai-search/chat-completions.ts | 314 ++-- .../commands/_generated/ai-search/create.ts | 763 +++++----- .../commands/_generated/ai-search/delete.ts | 66 +- .../src/commands/_generated/ai-search/get.ts | 62 +- .../commands/_generated/ai-search/index.ts | 45 +- .../_generated/ai-search/items/chunks.ts | 72 +- .../_generated/ai-search/items/delete.ts | 72 +- .../_generated/ai-search/items/download.ts | 72 +- .../_generated/ai-search/items/get.ts | 68 +- .../_generated/ai-search/items/index.ts | 31 +- .../_generated/ai-search/items/list.ts | 130 +- .../_generated/ai-search/items/logs.ts | 72 +- .../_generated/ai-search/items/sync.ts | 97 +- .../_generated/ai-search/items/upload.ts | 101 +- .../_generated/ai-search/items/upsert.ts | 101 +- .../_generated/ai-search/jobs/cancel.ts | 94 +- .../_generated/ai-search/jobs/create.ts | 82 +- .../commands/_generated/ai-search/jobs/get.ts | 68 +- .../_generated/ai-search/jobs/index.ts | 23 +- .../_generated/ai-search/jobs/list.ts | 70 +- .../_generated/ai-search/jobs/logs.ts | 77 +- .../src/commands/_generated/ai-search/list.ts | 103 +- .../src/commands/_generated/ai-search/move.ts | 82 +- .../ai-search/multi-chat-completions.ts | 315 ++-- .../_generated/ai-search/multi-search.ts | 314 ++-- .../_generated/ai-search/namespace/create.ts | 205 +-- .../_generated/ai-search/namespace/delete.ts | 53 +- .../_generated/ai-search/namespace/get.ts | 51 +- .../_generated/ai-search/namespace/index.ts | 23 +- .../_generated/ai-search/namespace/list.ts | 69 +- .../_generated/ai-search/namespace/update.ts | 201 +-- .../_generated/ai-search/purge-cache.ts | 62 +- .../commands/_generated/ai-search/search.ts | 312 ++-- .../commands/_generated/ai-search/stats.ts | 62 +- .../_generated/ai-search/tokens/create.ts | 87 +- .../_generated/ai-search/tokens/delete.ts | 57 +- .../_generated/ai-search/tokens/get.ts | 51 +- .../_generated/ai-search/tokens/index.ts | 23 +- .../_generated/ai-search/tokens/list.ts | 69 +- .../_generated/ai-search/tokens/update.ts | 96 +- .../commands/_generated/ai-search/update.ts | 778 +++++----- .../ai-security/custom-topics/get.ts | 40 +- .../ai-security/custom-topics/index.ts | 17 +- .../ai-security/custom-topics/update.ts | 66 +- .../commands/_generated/ai-security/get.ts | 40 +- .../commands/_generated/ai-security/index.ts | 19 +- .../commands/_generated/ai-security/update.ts | 65 +- .../commands/_generated/ai/authors/index.ts | 13 +- .../commands/_generated/ai/authors/list.ts | 40 +- .../_generated/ai/finetunes/assets/create.ts | 79 +- .../ai/finetunes/assets/download.ts | 51 +- .../_generated/ai/finetunes/assets/index.ts | 17 +- .../_generated/ai/finetunes/create.ts | 76 +- .../_generated/ai/finetunes/delete.ts | 53 +- .../commands/_generated/ai/finetunes/index.ts | 23 +- .../commands/_generated/ai/finetunes/list.ts | 40 +- .../_generated/ai/finetunes/public/index.ts | 13 +- .../_generated/ai/finetunes/public/list.ts | 64 +- .../_generated/ai/get-model-schema.ts | 51 +- .../cli/src/commands/_generated/ai/index.ts | 33 +- .../ai/list-markdown-supported-formats.ts | 40 +- .../commands/_generated/ai/models/index.ts | 13 +- .../src/commands/_generated/ai/models/list.ts | 99 +- .../src/commands/_generated/ai/tasks/index.ts | 13 +- .../src/commands/_generated/ai/tasks/list.ts | 40 +- .../src/commands/_generated/ai/to-markdown.ts | 76 +- .../src/commands/_generated/ai/websearch.ts | 90 +- .../alerting/available-alerts/index.ts | 13 +- .../alerting/available-alerts/list.ts | 40 +- .../alerting/destinations/eligible/get.ts | 40 +- .../alerting/destinations/eligible/index.ts | 13 +- .../_generated/alerting/destinations/index.ts | 19 +- .../alerting/destinations/pagerduty/create.ts | 40 +- .../alerting/destinations/pagerduty/delete.ts | 46 +- .../alerting/destinations/pagerduty/get.ts | 40 +- .../alerting/destinations/pagerduty/index.ts | 21 +- .../alerting/destinations/pagerduty/link.ts | 51 +- .../alerting/destinations/webhooks/create.ts | 82 +- .../alerting/destinations/webhooks/delete.ts | 57 +- .../alerting/destinations/webhooks/get.ts | 51 +- .../alerting/destinations/webhooks/index.ts | 23 +- .../alerting/destinations/webhooks/list.ts | 40 +- .../alerting/destinations/webhooks/update.ts | 73 +- .../_generated/alerting/history/index.ts | 13 +- .../_generated/alerting/history/list.ts | 82 +- .../src/commands/_generated/alerting/index.ts | 23 +- .../_generated/alerting/policies/create.ts | 688 +++++---- .../_generated/alerting/policies/delete.ts | 57 +- .../alerting/policies/email/details.ts | 63 +- .../alerting/policies/email/index.ts | 17 +- .../alerting/policies/email/unsubscribe.ts | 63 +- .../_generated/alerting/policies/get.ts | 51 +- .../_generated/alerting/policies/index.ts | 27 +- .../_generated/alerting/policies/list.ts | 40 +- .../_generated/alerting/policies/test.ts | 103 +- .../_generated/alerting/policies/update.ts | 703 +++++---- .../_generated/alerting/silences/create.ts | 49 +- .../_generated/alerting/silences/delete.ts | 51 +- .../_generated/alerting/silences/get.ts | 45 +- .../_generated/alerting/silences/index.ts | 23 +- .../_generated/alerting/silences/list.ts | 39 +- .../_generated/alerting/silences/update.ts | 50 +- .../_generated/analytics-engine/index.ts | 13 +- .../_generated/analytics-engine/sql/index.ts | 15 +- .../_generated/analytics-engine/sql/query.ts | 60 +- .../commands/_generated/analytics/index.ts | 17 +- .../_generated/analytics/latency/colos/get.ts | 40 +- .../analytics/latency/colos/index.ts | 13 +- .../_generated/analytics/latency/get.ts | 42 +- .../_generated/analytics/latency/index.ts | 17 +- .../data-security/content-findings/index.ts | 13 +- .../data-security/content-findings/top-n.ts | 92 +- .../query/data-security/findings/index.ts | 17 +- .../query/data-security/findings/summary.ts | 82 +- .../data-security/findings/timeseries.ts | 82 +- .../analytics/query/data-security/index.ts | 17 +- .../_generated/analytics/query/index.ts | 21 +- .../_generated/analytics/query/summary.ts | 119 +- .../_generated/analytics/query/timeseries.ts | 129 +- .../_generated/analytics/query/top-n.ts | 139 +- .../commands/_generated/api-security/index.ts | 21 +- .../api-security/schema-validation/index.ts | 17 +- .../schema-validation/schemas/create.ts | 90 +- .../schema-validation/schemas/delete.ts | 57 +- .../schema-validation/schemas/get.ts | 58 +- .../schema-validation/schemas/hosts/index.ts | 13 +- .../schema-validation/schemas/hosts/list.ts | 60 +- .../schema-validation/schemas/index.ts | 27 +- .../schema-validation/schemas/list.ts | 76 +- .../schemas/operations/index.ts | 13 +- .../schemas/operations/list.ts | 129 +- .../schemas/set-validation.ts | 66 +- .../schema-validation/settings/edit.ts | 82 +- .../schema-validation/settings/get.ts | 40 +- .../schema-validation/settings/index.ts | 21 +- .../settings/operations/bulk-edit.ts | 50 +- .../settings/operations/delete.ts | 57 +- .../settings/operations/get.ts | 51 +- .../settings/operations/index.ts | 23 +- .../settings/operations/list.ts | 60 +- .../settings/operations/update.ts | 74 +- .../schema-validation/settings/update.ts | 82 +- .../api-security/session-identifiers/get.ts | 47 +- .../api-security/session-identifiers/index.ts | 17 +- .../session-identifiers/update.ts | 67 +- .../token-validation/configurations/create.ts | 89 +- .../configurations/credentials/edit.ts | 75 +- .../configurations/credentials/index.ts | 17 +- .../configurations/credentials/update.ts | 75 +- .../token-validation/configurations/delete.ts | 57 +- .../token-validation/configurations/edit.ts | 78 +- .../token-validation/configurations/get.ts | 51 +- .../token-validation/configurations/index.ts | 25 +- .../token-validation/configurations/list.ts | 60 +- .../api-security/token-validation/index.ts | 17 +- .../token-validation/rules/bulk-create.ts | 50 +- .../token-validation/rules/bulk-edit.ts | 50 +- .../token-validation/rules/create.ts | 119 +- .../token-validation/rules/delete.ts | 57 +- .../token-validation/rules/edit.ts | 168 ++- .../token-validation/rules/get.ts | 51 +- .../token-validation/rules/index.ts | 27 +- .../token-validation/rules/list.ts | 130 +- .../credential-sets/create.ts | 57 +- .../credential-sets/credentials/create.ts | 99 +- .../credential-sets/credentials/delete.ts | 67 +- .../credential-sets/credentials/edit.ts | 110 +- .../credential-sets/credentials/get.ts | 61 +- .../credential-sets/credentials/index.ts | 25 +- .../credential-sets/credentials/list.ts | 70 +- .../credential-sets/credentials/update.ts | 110 +- .../credential-sets/delete.ts | 57 +- .../credential-sets/edit.ts | 70 +- .../credential-sets/get.ts | 51 +- .../credential-sets/index.ts | 27 +- .../credential-sets/list.ts | 60 +- .../credential-sets/update.ts | 68 +- .../vulnerability-scanner/index.ts | 19 +- .../vulnerability-scanner/scans/create.ts | 104 +- .../vulnerability-scanner/scans/delete.ts | 53 +- .../vulnerability-scanner/scans/get.ts | 47 +- .../vulnerability-scanner/scans/index.ts | 21 +- .../vulnerability-scanner/scans/list.ts | 60 +- .../target-environments/create.ts | 90 +- .../target-environments/delete.ts | 57 +- .../target-environments/edit.ts | 107 +- .../target-environments/get.ts | 51 +- .../target-environments/index.ts | 25 +- .../target-environments/list.ts | 60 +- .../target-environments/update.ts | 101 +- .../cli/src/commands/_generated/argo/index.ts | 17 +- .../count-zones-enabled-for-account.ts | 40 +- .../count-zones-enabled-for-user.ts | 40 +- .../_generated/argo/smart-routing/edit.ts | 60 +- .../_generated/argo/smart-routing/get.ts | 40 +- .../_generated/argo/smart-routing/index.ts | 21 +- .../_generated/argo/tiered-caching/edit.ts | 60 +- .../_generated/argo/tiered-caching/get.ts | 40 +- .../_generated/argo/tiered-caching/index.ts | 17 +- .../commands/_generated/artifacts/index.ts | 15 +- .../_generated/artifacts/namespaces/create.ts | 71 +- .../_generated/artifacts/namespaces/delete.ts | 57 +- .../_generated/artifacts/namespaces/get.ts | 51 +- .../_generated/artifacts/namespaces/index.ts | 25 +- .../_generated/artifacts/namespaces/list.ts | 44 +- .../artifacts/namespaces/repos/blobs/get.ts | 73 +- .../artifacts/namespaces/repos/blobs/index.ts | 13 +- .../artifacts/namespaces/repos/commits/get.ts | 67 +- .../namespaces/repos/commits/index.ts | 13 +- .../artifacts/namespaces/repos/create.ts | 95 +- .../artifacts/namespaces/repos/delete.ts | 61 +- .../artifacts/namespaces/repos/files/get.ts | 77 +- .../artifacts/namespaces/repos/files/index.ts | 13 +- .../artifacts/namespaces/repos/fork.ts | 89 +- .../artifacts/namespaces/repos/get.ts | 55 +- .../artifacts/namespaces/repos/import.ts | 96 +- .../artifacts/namespaces/repos/index.ts | 39 +- .../artifacts/namespaces/repos/list.ts | 74 +- .../artifacts/namespaces/repos/logs/get.ts | 69 +- .../artifacts/namespaces/repos/logs/index.ts | 13 +- .../artifacts/namespaces/repos/raw/get.ts | 83 +- .../artifacts/namespaces/repos/raw/index.ts | 13 +- .../namespaces/repos/tokens/index.ts | 13 +- .../artifacts/namespaces/repos/tokens/list.ts | 72 +- .../artifacts/namespaces/repos/trees/get.ts | 67 +- .../artifacts/namespaces/repos/trees/index.ts | 13 +- .../artifacts/namespaces/tokens/create.ts | 85 +- .../artifacts/namespaces/tokens/index.ts | 17 +- .../artifacts/namespaces/tokens/revoke.ts | 67 +- .../commands/_generated/audit-logs/index.ts | 13 +- .../commands/_generated/audit-logs/list.ts | 143 +- .../basin-catalog/credentials/create.ts | 71 +- .../basin-catalog/credentials/index.ts | 17 +- .../basin-catalog/credentials/status.ts | 51 +- .../_generated/basin-catalog/delete.ts | 66 +- .../_generated/basin-catalog/disable.ts | 57 +- .../_generated/basin-catalog/enable.ts | 73 +- .../commands/_generated/basin-catalog/get.ts | 51 +- .../_generated/basin-catalog/index.ts | 29 +- .../commands/_generated/basin-catalog/list.ts | 40 +- .../basin-catalog/maintenance-configs/get.ts | 51 +- .../maintenance-configs/index.ts | 17 +- .../maintenance-configs/update.ts | 126 +- .../basin-catalog/namespaces/index.ts | 17 +- .../basin-catalog/namespaces/list.ts | 96 +- .../basin-catalog/namespaces/tables/get.ts | 73 +- .../basin-catalog/namespaces/tables/index.ts | 21 +- .../basin-catalog/namespaces/tables/list.ts | 96 +- .../tables/maintenance-configs/get.ts | 69 +- .../tables/maintenance-configs/index.ts | 19 +- .../tables/maintenance-configs/queue.ts | 93 +- .../tables/maintenance-configs/update.ts | 142 +- .../tables/maintenance-runs/index.ts | 13 +- .../tables/maintenance-runs/list.ts | 76 +- .../_generated/billing/addresses/index.ts | 15 +- .../_generated/billing/addresses/validate.ts | 87 +- .../src/commands/_generated/billing/index.ts | 23 +- .../billing/profiles/create-payment-intent.ts | 40 +- .../_generated/billing/profiles/create.ts | 234 +-- .../_generated/billing/profiles/delete.ts | 46 +- .../_generated/billing/profiles/get.ts | 40 +- .../_generated/billing/profiles/index.ts | 25 +- .../billing/profiles/update-email.ts | 80 +- .../_generated/billing/profiles/update.ts | 234 +-- .../_generated/billing/rate-plans/get.ts | 51 +- .../_generated/billing/rate-plans/index.ts | 13 +- .../billing/spend-policies/activity/index.ts | 13 +- .../billing/spend-policies/activity/list.ts | 69 +- .../billing/spend-policies/audit/index.ts | 13 +- .../billing/spend-policies/audit/list.ts | 69 +- .../billing/spend-policies/create.ts | 113 +- .../billing/spend-policies/delete.ts | 67 +- .../_generated/billing/spend-policies/get.ts | 51 +- .../billing/spend-policies/index.ts | 27 +- .../_generated/billing/spend-policies/list.ts | 40 +- .../billing/spend-policies/update.ts | 134 +- .../usage/get-account-billable-metrics.ts | 62 +- .../billing/usage/get-account-usage-v2.ts | 62 +- .../_generated/billing/usage/get-info-v1.ts | 40 +- .../_generated/billing/usage/get-v1.ts | 62 +- .../_generated/billing/usage/index.ts | 23 +- .../_generated/billing/usage/query.ts | 139 +- .../bot-management/feedback/create.ts | 145 +- .../bot-management/feedback/index.ts | 17 +- .../bot-management/feedback/list.ts | 40 +- .../commands/_generated/bot-management/get.ts | 37 +- .../_generated/bot-management/index.ts | 19 +- .../_generated/bot-management/update.ts | 438 +++--- .../_generated/botnet-feed/asn/day-report.ts | 47 +- .../_generated/botnet-feed/asn/full-report.ts | 45 +- .../_generated/botnet-feed/asn/index.ts | 17 +- .../botnet-feed/configs/asn/delete.ts | 51 +- .../_generated/botnet-feed/configs/asn/get.ts | 40 +- .../botnet-feed/configs/asn/index.ts | 17 +- .../_generated/botnet-feed/configs/index.ts | 13 +- .../commands/_generated/botnet-feed/index.ts | 17 +- .../_generated/brand-protection/index.ts | 29 +- .../brand-protection/logo-matches/get.ts | 100 +- .../brand-protection/logo-matches/index.ts | 13 +- .../brand-protection/logos/create.ts | 86 +- .../brand-protection/logos/delete.ts | 53 +- .../_generated/brand-protection/logos/get.ts | 62 +- .../brand-protection/logos/index.ts | 19 +- .../brand-protection/matches/bulk-dismiss.ts | 82 +- .../brand-protection/matches/get.ts | 133 +- .../brand-protection/matches/index.ts | 17 +- .../brand-protection/queries/dismiss.ts | 63 +- .../brand-protection/queries/get.ts | 72 +- .../brand-protection/queries/index.ts | 19 +- .../brand-protection/queries/undismiss.ts | 63 +- .../_generated/brand-protection/submit.ts | 105 +- .../brand-protection/trial/create.ts | 57 +- .../brand-protection/trial/index.ts | 15 +- .../_generated/brand-protection/url-info.ts | 40 +- .../_generated/brand-protection/urls/get.ts | 54 +- .../_generated/brand-protection/urls/index.ts | 17 +- .../brand-protection/urls/submit.ts | 46 +- .../_generated/browser-run/crawl/create.ts | 60 +- .../_generated/browser-run/crawl/delete.ts | 57 +- .../_generated/browser-run/crawl/get.ts | 78 +- .../_generated/browser-run/crawl/index.ts | 19 +- .../browser-run/devtools/browser/create.ts | 112 +- .../browser-run/devtools/browser/delete.ts | 57 +- .../browser-run/devtools/browser/index.ts | 25 +- .../devtools/browser/live-view/create.ts | 106 +- .../devtools/browser/live-view/index.ts | 15 +- .../browser-run/devtools/browser/protocol.ts | 47 +- .../devtools/browser/targets/activate.ts | 61 +- .../devtools/browser/targets/close.ts | 57 +- .../devtools/browser/targets/create.ts | 61 +- .../devtools/browser/targets/get.ts | 55 +- .../devtools/browser/targets/index.ts | 23 +- .../devtools/browser/targets/list.ts | 62 +- .../browser-run/devtools/browser/version.ts | 47 +- .../_generated/browser-run/devtools/index.ts | 19 +- .../browser-run/devtools/json/get.ts | 59 +- .../browser-run/devtools/json/index.ts | 13 +- .../browser-run/devtools/session/get.ts | 47 +- .../browser-run/devtools/session/index.ts | 17 +- .../browser-run/devtools/session/list.ts | 44 +- .../commands/_generated/browser-run/index.ts | 23 +- .../quick-action/accessibility-tree.ts | 408 ++--- .../browser-run/quick-action/content.ts | 392 ++--- .../browser-run/quick-action/index.ts | 31 +- .../browser-run/quick-action/json.ts | 433 +++--- .../browser-run/quick-action/links.ts | 405 ++--- .../browser-run/quick-action/markdown.ts | 392 ++--- .../browser-run/quick-action/pdf.ts | 588 ++++---- .../browser-run/quick-action/scrape.ts | 402 ++--- .../browser-run/quick-action/screenshot.ts | 555 ++++--- .../browser-run/quick-action/snapshot.ts | 815 +++++----- .../_generated/browser-run/recording/get.ts | 47 +- .../_generated/browser-run/recording/index.ts | 17 +- .../browser-run/recording/network/get.ts | 67 +- .../browser-run/recording/network/index.ts | 13 +- .../_generated/browser-run/script/create.ts | 130 +- .../_generated/browser-run/script/execute.ts | 108 +- .../_generated/browser-run/script/index.ts | 17 +- .../src/commands/_generated/builds/cancel.ts | 48 +- .../src/commands/_generated/builds/create.ts | 148 +- .../_generated/builds/deploy-hooks/create.ts | 78 +- .../_generated/builds/deploy-hooks/delete.ts | 67 +- .../_generated/builds/deploy-hooks/get.ts | 61 +- .../_generated/builds/deploy-hooks/index.ts | 23 +- .../_generated/builds/deploy-hooks/list.ts | 50 +- .../_generated/builds/deploy-hooks/update.ts | 88 +- .../cli/src/commands/_generated/builds/get.ts | 51 +- .../src/commands/_generated/builds/index.ts | 39 +- .../commands/_generated/builds/limits/get.ts | 40 +- .../_generated/builds/limits/index.ts | 13 +- .../src/commands/_generated/builds/list.ts | 70 +- .../src/commands/_generated/builds/logs.ts | 61 +- .../builds/previews/create-build.ts | 154 +- .../_generated/builds/previews/get.ts | 57 +- .../_generated/builds/previews/index.ts | 23 +- .../_generated/builds/previews/list-builds.ts | 77 +- .../_generated/builds/previews/list.ts | 70 +- .../_generated/builds/previews/update.ts | 178 +-- .../builds/repos/config-autofill/get.ts | 90 +- .../builds/repos/config-autofill/index.ts | 13 +- .../builds/repos/connections/delete.ts | 57 +- .../builds/repos/connections/index.ts | 17 +- .../builds/repos/connections/replace.ts | 103 +- .../commands/_generated/builds/repos/index.ts | 17 +- .../src/commands/_generated/builds/retry.ts | 61 +- .../_generated/builds/tokens/create.ts | 77 +- .../_generated/builds/tokens/delete.ts | 57 +- .../_generated/builds/tokens/index.ts | 19 +- .../commands/_generated/builds/tokens/list.ts | 60 +- .../_generated/builds/versions/get.ts | 50 +- .../_generated/builds/versions/index.ts | 13 +- .../_generated/builds/workers/create.ts | 324 ++-- .../_generated/builds/workers/delete.ts | 57 +- .../_generated/builds/workers/edit.ts | 259 ++-- .../commands/_generated/builds/workers/get.ts | 51 +- .../_generated/builds/workers/index.ts | 25 +- .../builds/workers/migrate-to-previews.ts | 77 +- .../_generated/builds/workers/purge-cache.ts | 57 +- .../src/commands/_generated/cache/index.ts | 25 +- .../cache/invalidate-environment.ts | 67 +- .../commands/_generated/cache/invalidate.ts | 56 +- .../cache/origin-cloud-regions/bulk-delete.ts | 56 +- .../origin-cloud-regions/bulk-replace.ts | 50 +- .../cache/origin-cloud-regions/delete.ts | 57 +- .../cache/origin-cloud-regions/get.ts | 51 +- .../cache/origin-cloud-regions/index.ts | 27 +- .../cache/origin-cloud-regions/list.ts | 60 +- .../origin-cloud-regions/regions/index.ts | 15 +- .../regions/list-supported.ts | 40 +- .../cache/origin-cloud-regions/update.ts | 81 +- .../_generated/cache/purge-environment.ts | 67 +- .../src/commands/_generated/cache/purge.ts | 56 +- .../_generated/cache/settings/index.ts | 21 +- .../settings/regional-tiered-cache/edit.ts | 60 +- .../settings/regional-tiered-cache/get.ts | 40 +- .../settings/regional-tiered-cache/index.ts | 17 +- .../cache/settings/reserve/clear.ts | 46 +- .../_generated/cache/settings/reserve/edit.ts | 60 +- .../_generated/cache/settings/reserve/get.ts | 40 +- .../cache/settings/reserve/index.ts | 21 +- .../cache/settings/reserve/status.ts | 40 +- .../settings/smart-tiered-cache/create.ts | 60 +- .../settings/smart-tiered-cache/delete.ts | 46 +- .../cache/settings/smart-tiered-cache/edit.ts | 60 +- .../cache/settings/smart-tiered-cache/get.ts | 40 +- .../settings/smart-tiered-cache/index.ts | 21 +- .../cache/settings/variants/delete.ts | 46 +- .../cache/settings/variants/edit.ts | 184 +-- .../_generated/cache/settings/variants/get.ts | 40 +- .../cache/settings/variants/index.ts | 19 +- .../client-side-security/connections/get.ts | 47 +- .../client-side-security/connections/index.ts | 17 +- .../client-side-security/connections/list.ts | 159 +- .../client-side-security/cookies/get.ts | 45 +- .../client-side-security/cookies/index.ts | 17 +- .../client-side-security/cookies/list.ts | 182 +-- .../_generated/client-side-security/index.ts | 23 +- .../client-side-security/policies/create.ts | 99 +- .../client-side-security/policies/delete.ts | 51 +- .../client-side-security/policies/get.ts | 45 +- .../client-side-security/policies/index.ts | 23 +- .../client-side-security/policies/list.ts | 40 +- .../client-side-security/policies/update.ts | 104 +- .../client-side-security/scripts/get.ts | 45 +- .../client-side-security/scripts/index.ts | 17 +- .../client-side-security/scripts/list.ts | 169 ++- .../client-side-security/settings/get.ts | 40 +- .../client-side-security/settings/index.ts | 17 +- .../client-side-security/settings/update.ts | 75 +- .../_generated/cloud-connector/index.ts | 15 +- .../_generated/cloud-connector/rules/index.ts | 17 +- .../_generated/cloud-connector/rules/list.ts | 40 +- .../cloud-connector/rules/update.ts | 50 +- .../cloudforce-one/binary-storage/create.ts | 60 +- .../cloudforce-one/binary-storage/get.ts | 47 +- .../cloudforce-one/binary-storage/index.ts | 17 +- .../credential-monitor/domains/create.ts | 60 +- .../credential-monitor/domains/delete.ts | 51 +- .../credential-monitor/domains/index.ts | 19 +- .../credential-monitor/domains/list.ts | 54 +- .../credential-monitor/index.ts | 17 +- .../credential-monitor/matches/index.ts | 13 +- .../credential-monitor/matches/list.ts | 74 +- .../_generated/cloudforce-one/index.ts | 29 +- .../priority-intelligence/constants/get.ts | 40 +- .../priority-intelligence/constants/index.ts | 13 +- .../priority-intelligence/create.ts | 1307 ++++++++-------- .../priority-intelligence/delete.ts | 53 +- .../priority-intelligence/filters/generate.ts | 60 +- .../priority-intelligence/filters/index.ts | 15 +- .../priority-intelligence/get.ts | 47 +- .../priority-intelligence/index.ts | 39 +- .../interests/backtests/create.ts | 141 +- .../interests/backtests/get.ts | 47 +- .../interests/backtests/index.ts | 17 +- .../priority-intelligence/interests/create.ts | 75 +- .../priority-intelligence/interests/delete.ts | 53 +- .../interests/evaluations/create.ts | 130 +- .../interests/evaluations/get.ts | 47 +- .../interests/evaluations/index.ts | 17 +- .../priority-intelligence/interests/index.ts | 25 +- .../priority-intelligence/interests/list.ts | 56 +- .../priority-intelligence/interests/update.ts | 62 +- .../priority-intelligence/list.ts | 49 +- .../matches/aggregate-all.ts | 92 +- .../matches/aggregate.ts | 97 +- .../priority-intelligence/matches/index.ts | 23 +- .../priority-intelligence/matches/list.ts | 72 +- .../priority-intelligence/matches/series.ts | 89 +- .../priority-intelligence/matches/update.ts | 80 +- .../priority-intelligence/profile/delete.ts | 46 +- .../priority-intelligence/profile/get.ts | 40 +- .../priority-intelligence/profile/index.ts | 19 +- .../priority-intelligence/profile/update.ts | 50 +- .../priority-intelligence/quota/create.ts | 40 +- .../priority-intelligence/quota/index.ts | 15 +- .../priority-intelligence/resolve.ts | 664 +++++---- .../priority-intelligence/topics/index.ts | 13 +- .../priority-intelligence/topics/list.ts | 40 +- .../priority-intelligence/update.ts | 1325 +++++++++-------- .../requests/assets/download.ts | 67 +- .../cloudforce-one/requests/assets/index.ts | 19 +- .../cloudforce-one/requests/assets/list.ts | 58 +- .../cloudforce-one/requests/assets/upload.ts | 107 +- .../cloudforce-one/requests/constants/get.ts | 47 +- .../requests/constants/index.ts | 13 +- .../cloudforce-one/requests/create.ts | 139 +- .../_generated/cloudforce-one/requests/get.ts | 57 +- .../cloudforce-one/requests/index.ts | 37 +- .../requests/legal-response/access-check.ts | 40 +- .../requests/legal-response/index.ts | 15 +- .../cloudforce-one/requests/list.ts | 151 +- .../requests/messages/create.ts | 124 +- .../cloudforce-one/requests/messages/get.ts | 57 +- .../cloudforce-one/requests/messages/index.ts | 21 +- .../cloudforce-one/requests/messages/list.ts | 61 +- .../requests/messages/update.ts | 108 +- .../cloudforce-one/requests/metadata/index.ts | 13 +- .../cloudforce-one/requests/metadata/list.ts | 68 +- .../cloudforce-one/requests/quota/get.ts | 47 +- .../cloudforce-one/requests/quota/index.ts | 13 +- .../cloudforce-one/requests/types/index.ts | 13 +- .../cloudforce-one/requests/types/list.ts | 46 +- .../cloudforce-one/requests/update.ts | 141 +- .../cloudforce-one/requests/user/get.ts | 47 +- .../cloudforce-one/requests/user/index.ts | 13 +- .../cloudforce-one/rules/approvals/cancel.ts | 51 +- .../cloudforce-one/rules/approvals/get.ts | 51 +- .../cloudforce-one/rules/approvals/index.ts | 21 +- .../cloudforce-one/rules/approvals/list.ts | 97 +- .../rules/approvals/resubmit.ts | 105 +- .../_generated/cloudforce-one/rules/create.ts | 134 +- .../cloudforce-one/rules/delete-all.ts | 46 +- .../_generated/cloudforce-one/rules/delete.ts | 74 +- .../rules/email/approvals/index.ts | 17 +- .../rules/email/approvals/replace.ts | 161 +- .../rules/email/approvals/resubmit.ts | 166 ++- .../cloudforce-one/rules/email/create.ts | 144 +- .../cloudforce-one/rules/email/delete.ts | 57 +- .../cloudforce-one/rules/email/get.ts | 51 +- .../cloudforce-one/rules/email/index.ts | 31 +- .../cloudforce-one/rules/email/list.ts | 46 +- .../cloudforce-one/rules/email/schema/get.ts | 40 +- .../rules/email/schema/index.ts | 13 +- .../cloudforce-one/rules/email/test.ts | 71 +- .../cloudforce-one/rules/email/update.ts | 154 +- .../cloudforce-one/rules/email/validate.ts | 154 +- .../cloudforce-one/rules/exemptions/create.ts | 86 +- .../cloudforce-one/rules/exemptions/delete.ts | 92 +- .../cloudforce-one/rules/exemptions/get.ts | 40 +- .../cloudforce-one/rules/exemptions/index.ts | 21 +- .../cloudforce-one/rules/exemptions/update.ts | 82 +- .../_generated/cloudforce-one/rules/get.ts | 48 +- .../_generated/cloudforce-one/rules/index.ts | 41 +- .../_generated/cloudforce-one/rules/list.ts | 86 +- .../cloudforce-one/rules/managed/get.ts | 40 +- .../cloudforce-one/rules/managed/index.ts | 13 +- .../_generated/cloudforce-one/rules/search.ts | 118 +- .../cloudforce-one/rules/stats/get.ts | 40 +- .../cloudforce-one/rules/stats/index.ts | 13 +- .../cloudforce-one/rules/tree/get.ts | 40 +- .../cloudforce-one/rules/tree/index.ts | 13 +- .../_generated/cloudforce-one/rules/update.ts | 140 +- .../cloudforce-one/rules/validate.ts | 93 +- .../cloudforce-one/scans/config/create.ts | 87 +- .../cloudforce-one/scans/config/delete.ts | 57 +- .../cloudforce-one/scans/config/edit.ts | 98 +- .../cloudforce-one/scans/config/index.ts | 21 +- .../cloudforce-one/scans/config/list.ts | 40 +- .../_generated/cloudforce-one/scans/index.ts | 17 +- .../scans/results/get-banners.ts | 51 +- .../cloudforce-one/scans/results/get.ts | 51 +- .../cloudforce-one/scans/results/index.ts | 17 +- .../datasets/access/groups/create.ts | 67 +- .../datasets/access/groups/delete.ts | 51 +- .../datasets/access/groups/get.ts | 45 +- .../datasets/access/groups/index.ts | 25 +- .../datasets/access/groups/list.ts | 40 +- .../datasets/access/groups/members/create.ts | 75 +- .../datasets/access/groups/members/delete.ts | 57 +- .../datasets/access/groups/members/index.ts | 19 +- .../datasets/access/groups/members/list.ts | 46 +- .../datasets/access/groups/update.ts | 72 +- .../threat-intel/datasets/access/index.ts | 17 +- .../datasets/access/permissions/create.ts | 92 +- .../datasets/access/permissions/delete.ts | 57 +- .../datasets/access/permissions/index.ts | 21 +- .../datasets/access/permissions/list.ts | 46 +- .../datasets/access/permissions/update.ts | 71 +- .../threat-intel/datasets/create.ts | 67 +- .../threat-intel/datasets/delete.ts | 53 +- .../threat-intel/datasets/get.ts | 47 +- .../threat-intel/datasets/index.ts | 29 +- .../threat-intel/datasets/list.ts | 47 +- .../threat-intel/datasets/populate.ts | 40 +- .../datasets/preferences/delete.ts | 57 +- .../threat-intel/datasets/preferences/get.ts | 40 +- .../datasets/preferences/index.ts | 19 +- .../datasets/preferences/update.ts | 72 +- .../threat-intel/datasets/update.ts | 74 +- .../threat-intel/events/aggregate.ts | 101 +- .../threat-intel/events/attackers/index.ts | 13 +- .../threat-intel/events/attackers/list.ts | 54 +- .../threat-intel/events/bulk-create.ts | 77 +- .../threat-intel/events/bulk-update.ts | 214 +-- .../events/categories/catalog/index.ts | 13 +- .../events/categories/catalog/list.ts | 40 +- .../threat-intel/events/categories/create.ts | 98 +- .../threat-intel/events/categories/delete.ts | 53 +- .../threat-intel/events/categories/get.ts | 47 +- .../threat-intel/events/categories/index.ts | 25 +- .../threat-intel/events/categories/list.ts | 54 +- .../threat-intel/events/categories/update.ts | 105 +- .../threat-intel/events/copy.ts | 86 +- .../threat-intel/events/countries/index.ts | 13 +- .../threat-intel/events/countries/list.ts | 40 +- .../threat-intel/events/create.ts | 260 ++-- .../threat-intel/events/delete.ts | 65 +- .../cloudforce-one/threat-intel/events/get.ts | 51 +- .../threat-intel/events/graphql.ts | 40 +- .../threat-intel/events/index.ts | 53 +- .../threat-intel/events/legacy/get.ts | 45 +- .../threat-intel/events/legacy/graphql.ts | 40 +- .../threat-intel/events/legacy/index.ts | 23 +- .../threat-intel/events/legacy/raw/get.ts | 53 +- .../threat-intel/events/legacy/raw/index.ts | 17 +- .../threat-intel/events/legacy/raw/update.ts | 89 +- .../events/legacy/references/create.ts | 67 +- .../events/legacy/references/delete.ts | 73 +- .../events/legacy/references/index.ts | 17 +- .../threat-intel/events/legacy/tags/create.ts | 67 +- .../threat-intel/events/legacy/tags/delete.ts | 73 +- .../threat-intel/events/legacy/tags/index.ts | 17 +- .../threat-intel/events/list.ts | 146 +- .../threat-intel/events/move.ts | 86 +- .../threat-intel/events/queries/create.ts | 102 +- .../threat-intel/events/queries/delete.ts | 53 +- .../threat-intel/events/queries/get.ts | 47 +- .../threat-intel/events/queries/index.ts | 23 +- .../threat-intel/events/queries/list.ts | 40 +- .../threat-intel/events/queries/update.ts | 112 +- .../threat-intel/events/raw/get.ts | 51 +- .../threat-intel/events/raw/index.ts | 13 +- .../events/relationships/create.ts | 96 +- .../events/relationships/index.ts | 17 +- .../threat-intel/events/relationships/list.ts | 115 +- .../threat-intel/events/search.ts | 147 +- .../events/target-industries/catalog/index.ts | 13 +- .../events/target-industries/catalog/list.ts | 40 +- .../events/target-industries/index.ts | 17 +- .../events/target-industries/list.ts | 54 +- .../threat-intel/events/update.ts | 193 ++- .../cloudforce-one/threat-intel/index.ts | 23 +- .../threat-intel/indicators/bulk-create.ts | 73 +- .../threat-intel/indicators/bulk-delete.ts | 64 +- .../threat-intel/indicators/create.ts | 101 +- .../threat-intel/indicators/delete.ts | 59 +- .../threat-intel/indicators/get.ts | 53 +- .../threat-intel/indicators/index.ts | 33 +- .../threat-intel/indicators/list.ts | 204 +-- .../indicators/relationships/create.ts | 112 +- .../indicators/relationships/delete.ts | 65 +- .../indicators/relationships/index.ts | 21 +- .../indicators/relationships/list.ts | 99 +- .../indicators/relationships/update.ts | 101 +- .../threat-intel/indicators/tags/index.ts | 13 +- .../threat-intel/indicators/tags/list.ts | 46 +- .../threat-intel/indicators/types/create.ts | 79 +- .../threat-intel/indicators/types/index.ts | 17 +- .../threat-intel/indicators/types/list.ts | 54 +- .../threat-intel/indicators/update.ts | 102 +- .../cloudforce-one/threat-intel/search.ts | 89 +- .../threat-intel/tags/actors/index.ts | 13 +- .../threat-intel/tags/actors/list.ts | 73 +- .../threat-intel/tags/categories/create.ts | 79 +- .../threat-intel/tags/categories/delete.ts | 57 +- .../threat-intel/tags/categories/get.ts | 51 +- .../threat-intel/tags/categories/index.ts | 23 +- .../threat-intel/tags/categories/list.ts | 42 +- .../threat-intel/tags/categories/update.ts | 90 +- .../threat-intel/tags/create.ts | 200 +-- .../threat-intel/tags/delete.ts | 51 +- .../cloudforce-one/threat-intel/tags/get.ts | 45 +- .../cloudforce-one/threat-intel/tags/index.ts | 31 +- .../threat-intel/tags/indicators/index.ts | 13 +- .../threat-intel/tags/indicators/list.ts | 112 +- .../cloudforce-one/threat-intel/tags/list.ts | 87 +- .../threat-intel/tags/relationships/create.ts | 114 +- .../threat-intel/tags/relationships/delete.ts | 69 +- .../threat-intel/tags/relationships/index.ts | 21 +- .../threat-intel/tags/relationships/list.ts | 105 +- .../threat-intel/tags/relationships/update.ts | 105 +- .../threat-intel/tags/update.ts | 206 +-- .../articles/aggregate-relevance.ts | 67 +- .../articles/aggregate-severity.ts | 88 +- .../threat-signals/articles/bulk-mark-read.ts | 67 +- .../threat-signals/articles/get-content.ts | 60 +- .../threat-signals/articles/get.ts | 51 +- .../threat-signals/articles/index.ts | 33 +- .../threat-signals/articles/list.ts | 272 ++-- .../threat-signals/articles/mark-read.ts | 66 +- .../threat-signals/articles/reprocess.ts | 61 +- .../articles/skills/get-output.ts | 63 +- .../threat-signals/articles/skills/index.ts | 19 +- .../threat-signals/articles/skills/list.ts | 50 +- .../threat-signals/articles/skills/run.ts | 73 +- .../threat-signals/articles/tags/add.ts | 73 +- .../threat-signals/articles/tags/generate.ts | 51 +- .../threat-signals/articles/tags/index.ts | 19 +- .../threat-signals/articles/tags/remove.ts | 67 +- .../threat-signals/categories/index.ts | 13 +- .../threat-signals/categories/list.ts | 40 +- .../threat-signals/feeds/create.ts | 129 +- .../threat-signals/feeds/delete.ts | 57 +- .../threat-signals/feeds/get-raw.ts | 60 +- .../threat-signals/feeds/index.ts | 27 +- .../threat-signals/feeds/list.ts | 118 +- .../threat-signals/feeds/poll.ts | 52 +- .../threat-signals/feeds/skills/get.ts | 51 +- .../threat-signals/feeds/skills/index.ts | 17 +- .../threat-signals/feeds/skills/update.ts | 75 +- .../threat-signals/feeds/update.ts | 122 +- .../cloudforce-one/threat-signals/index.ts | 25 +- .../threat-signals/indicators/index.ts | 13 +- .../threat-signals/indicators/list.ts | 107 +- .../cloudforce-one/threat-signals/search.ts | 72 +- .../threat-signals/skills/create.ts | 92 +- .../threat-signals/skills/delete.ts | 57 +- .../threat-signals/skills/get.ts | 51 +- .../threat-signals/skills/index.ts | 25 +- .../threat-signals/skills/list.ts | 60 +- .../skills/tag-categories/get.ts | 53 +- .../skills/tag-categories/index.ts | 17 +- .../skills/tag-categories/update.ts | 77 +- .../threat-signals/skills/update.ts | 110 +- .../_generated/connector-interrupts/create.ts | 80 +- .../_generated/connector-interrupts/index.ts | 17 +- .../_generated/connector-interrupts/list.ts | 46 +- .../connector-telemetry-events/get.ts | 57 +- .../connector-telemetry-events/index.ts | 17 +- .../connector-telemetry-events/list.ts | 61 +- .../connector-telemetry-snapshots/get.ts | 51 +- .../connector-telemetry-snapshots/index.ts | 17 +- .../connector-telemetry-snapshots/list.ts | 54 +- .../commands/_generated/connectors/create.ts | 139 +- .../commands/_generated/connectors/delete.ts | 53 +- .../commands/_generated/connectors/edit.ts | 130 +- .../src/commands/_generated/connectors/get.ts | 44 +- .../commands/_generated/connectors/index.ts | 25 +- .../commands/_generated/connectors/list.ts | 44 +- .../commands/_generated/connectors/update.ts | 130 +- .../containers/applications/create.ts | 365 +++-- .../containers/applications/delete.ts | 58 +- .../containers/applications/edit.ts | 140 +- .../_generated/containers/applications/get.ts | 52 +- .../containers/applications/index.ts | 29 +- .../containers/applications/instances/get.ts | 64 +- .../applications/instances/index.ts | 17 +- .../containers/applications/instances/list.ts | 92 +- .../containers/applications/list.ts | 83 +- .../applications/rollouts/create.ts | 204 +-- .../containers/applications/rollouts/index.ts | 15 +- .../containers/applications/versions/index.ts | 13 +- .../containers/applications/versions/list.ts | 51 +- .../_generated/containers/images/index.ts | 23 +- .../_generated/containers/images/prepare.ts | 59 +- .../commands/_generated/containers/index.ts | 33 +- .../containers/registries/create.ts | 109 +- .../registries/credentials/generate.ts | 85 +- .../registries/credentials/index.ts | 15 +- .../containers/registries/delete.ts | 53 +- .../_generated/containers/registries/index.ts | 21 +- .../_generated/containers/registries/list.ts | 40 +- .../commands/_generated/containers/usage.ts | 40 +- .../content-scan/expressions/create.ts | 50 +- .../content-scan/expressions/delete.ts | 59 +- .../content-scan/expressions/index.ts | 21 +- .../content-scan/expressions/list.ts | 40 +- .../content-scan/expressions/update.ts | 75 +- .../commands/_generated/content-scan/get.ts | 40 +- .../commands/_generated/content-scan/index.ts | 19 +- .../_generated/content-scan/update.ts | 68 +- .../cli/src/commands/_generated/cps/get.ts | 40 +- .../cli/src/commands/_generated/cps/index.ts | 17 +- .../cli/src/commands/_generated/cps/update.ts | 73 +- .../commands/_generated/csam-scanner/edit.ts | 98 +- .../commands/_generated/csam-scanner/get.ts | 40 +- .../commands/_generated/csam-scanner/index.ts | 17 +- .../commands/_generated/custom-csrs/create.ts | 150 +- .../commands/_generated/custom-csrs/delete.ts | 57 +- .../commands/_generated/custom-csrs/get.ts | 51 +- .../commands/_generated/custom-csrs/index.ts | 21 +- .../commands/_generated/custom-csrs/list.ts | 78 +- .../certificate-pack/certificates/delete.ts | 77 +- .../certificate-pack/certificates/index.ts | 17 +- .../certificate-pack/certificates/update.ts | 101 +- .../certificate-pack/index.ts | 15 +- .../_generated/custom-hostnames/create.ts | 276 ++-- .../_generated/custom-hostnames/delete.ts | 57 +- .../_generated/custom-hostnames/edit.ts | 276 ++-- .../fallback-origin/delete.ts | 46 +- .../custom-hostnames/fallback-origin/get.ts | 40 +- .../custom-hostnames/fallback-origin/index.ts | 19 +- .../fallback-origin/update.ts | 62 +- .../_generated/custom-hostnames/get.ts | 51 +- .../_generated/custom-hostnames/index.ts | 29 +- .../_generated/custom-hostnames/list.ts | 195 +-- .../_generated/custom-hostnames/quota/get.ts | 40 +- .../custom-hostnames/quota/index.ts | 13 +- .../_generated/custom-nameservers/create.ts | 71 +- .../_generated/custom-nameservers/delete.ts | 57 +- .../_generated/custom-nameservers/get.ts | 40 +- .../_generated/custom-nameservers/index.ts | 19 +- .../custom-pages/account-assets/create.ts | 82 +- .../custom-pages/account-assets/delete.ts | 59 +- .../custom-pages/account-assets/get.ts | 53 +- .../custom-pages/account-assets/index.ts | 23 +- .../custom-pages/account-assets/list.ts | 60 +- .../custom-pages/account-assets/update.ts | 83 +- .../custom-pages/account-custom-pages/get.ts | 47 +- .../account-custom-pages/index.ts | 21 +- .../custom-pages/account-custom-pages/list.ts | 40 +- .../preview-tokens/create.ts | 82 +- .../preview-tokens/index.ts | 15 +- .../account-custom-pages/update.ts | 77 +- .../commands/_generated/custom-pages/index.ts | 17 +- .../cli/src/commands/_generated/d1/create.ts | 97 +- .../cli/src/commands/_generated/d1/delete.ts | 54 +- .../cli/src/commands/_generated/d1/edit.ts | 74 +- .../cli/src/commands/_generated/d1/get.ts | 62 +- .../cli/src/commands/_generated/d1/index.ts | 37 +- .../_generated/d1/insights/databases.ts | 98 +- .../commands/_generated/d1/insights/index.ts | 17 +- .../_generated/d1/insights/queries.ts | 89 +- .../cli/src/commands/_generated/d1/list.ts | 67 +- .../cli/src/commands/_generated/d1/query.ts | 105 +- .../cli/src/commands/_generated/d1/raw.ts | 105 +- .../_generated/d1/time-travel/get-bookmark.ts | 63 +- .../_generated/d1/time-travel/index.ts | 17 +- .../_generated/d1/time-travel/restore.ts | 77 +- .../src/commands/_generated/d1/undelete.ts | 77 +- .../endpoint-healthchecks/create.ts | 83 +- .../endpoint-healthchecks/delete.ts | 51 +- .../diagnostics/endpoint-healthchecks/get.ts | 45 +- .../endpoint-healthchecks/index.ts | 23 +- .../diagnostics/endpoint-healthchecks/list.ts | 40 +- .../endpoint-healthchecks/update.ts | 87 +- .../commands/_generated/diagnostics/index.ts | 17 +- .../diagnostics/traceroutes/create.ts | 125 +- .../diagnostics/traceroutes/index.ts | 15 +- .../cli/src/commands/_generated/dls/index.ts | 17 +- .../_generated/dls/regional-services/index.ts | 15 +- .../prefix-bindings/create.ts | 80 +- .../prefix-bindings/delete.ts | 57 +- .../regional-services/prefix-bindings/edit.ts | 71 +- .../regional-services/prefix-bindings/get.ts | 51 +- .../prefix-bindings/index.ts | 23 +- .../regional-services/prefix-bindings/list.ts | 59 +- .../commands/_generated/dls/regions/get.ts | 53 +- .../commands/_generated/dls/regions/index.ts | 17 +- .../commands/_generated/dls/regions/list.ts | 66 +- .../_generated/dns-firewall/create.ts | 167 ++- .../_generated/dns-firewall/delete.ts | 53 +- .../commands/_generated/dns-firewall/edit.ts | 163 +- .../commands/_generated/dns-firewall/get.ts | 47 +- .../commands/_generated/dns-firewall/index.ts | 25 +- .../commands/_generated/dns-firewall/list.ts | 57 +- .../dns-firewall/reverse-dns/edit.ts | 69 +- .../dns-firewall/reverse-dns/get.ts | 47 +- .../dns-firewall/reverse-dns/index.ts | 17 +- .../commands/_generated/dns/dnssec/delete.ts | 43 +- .../commands/_generated/dns/dnssec/edit.ts | 84 +- .../src/commands/_generated/dns/dnssec/get.ts | 39 +- .../commands/_generated/dns/dnssec/index.ts | 21 +- .../_generated/dns/dnssec/zsks/index.ts | 13 +- .../_generated/dns/dnssec/zsks/list.ts | 40 +- .../cli/src/commands/_generated/dns/index.ts | 25 +- .../_generated/dns/records/bulk-apply.ts | 97 +- .../commands/_generated/dns/records/create.ts | 57 +- .../commands/_generated/dns/records/delete.ts | 53 +- .../commands/_generated/dns/records/edit.ts | 64 +- .../commands/_generated/dns/records/export.ts | 368 +++-- .../commands/_generated/dns/records/get.ts | 54 +- .../commands/_generated/dns/records/import.ts | 72 +- .../commands/_generated/dns/records/index.ts | 39 +- .../commands/_generated/dns/records/list.ts | 421 +++--- .../_generated/dns/records/scan-list.ts | 40 +- .../_generated/dns/records/scan-review.ts | 72 +- .../_generated/dns/records/scan-trigger.ts | 40 +- .../commands/_generated/dns/records/scan.ts | 40 +- .../commands/_generated/dns/records/update.ts | 64 +- .../_generated/dns/settings/account/edit.ts | 205 +-- .../_generated/dns/settings/account/get.ts | 40 +- .../_generated/dns/settings/account/index.ts | 19 +- .../account/nameserver-sets/create.ts | 87 +- .../account/nameserver-sets/delete.ts | 57 +- .../settings/account/nameserver-sets/edit.ts | 73 +- .../settings/account/nameserver-sets/get.ts | 51 +- .../settings/account/nameserver-sets/index.ts | 23 +- .../settings/account/nameserver-sets/list.ts | 60 +- .../commands/_generated/dns/settings/index.ts | 15 +- .../_generated/dns/usage/account/get.ts | 40 +- .../_generated/dns/usage/account/index.ts | 13 +- .../commands/_generated/dns/usage/index.ts | 15 +- .../commands/_generated/dns/views/create.ts | 66 +- .../commands/_generated/dns/views/delete.ts | 51 +- .../src/commands/_generated/dns/views/edit.ts | 73 +- .../src/commands/_generated/dns/views/get.ts | 42 +- .../commands/_generated/dns/views/index.ts | 23 +- .../src/commands/_generated/dns/views/list.ts | 158 +- .../dns/zone-transfers/acls/create.ts | 66 +- .../dns/zone-transfers/acls/delete.ts | 48 +- .../_generated/dns/zone-transfers/acls/get.ts | 42 +- .../dns/zone-transfers/acls/index.ts | 23 +- .../dns/zone-transfers/acls/list.ts | 37 +- .../dns/zone-transfers/acls/update.ts | 71 +- .../dns/zone-transfers/force-axfr.ts | 40 +- .../dns/zone-transfers/incoming/create.ts | 82 +- .../dns/zone-transfers/incoming/delete.ts | 46 +- .../dns/zone-transfers/incoming/get.ts | 40 +- .../dns/zone-transfers/incoming/index.ts | 21 +- .../dns/zone-transfers/incoming/update.ts | 81 +- .../_generated/dns/zone-transfers/index.ts | 25 +- .../dns/zone-transfers/outgoing/create.ts | 69 +- .../dns/zone-transfers/outgoing/delete.ts | 46 +- .../dns/zone-transfers/outgoing/disable.ts | 46 +- .../dns/zone-transfers/outgoing/enable.ts | 40 +- .../zone-transfers/outgoing/force-notify.ts | 40 +- .../dns/zone-transfers/outgoing/get.ts | 40 +- .../dns/zone-transfers/outgoing/index.ts | 29 +- .../dns/zone-transfers/outgoing/status.ts | 40 +- .../dns/zone-transfers/outgoing/update.ts | 69 +- .../dns/zone-transfers/peers/create.ts | 54 +- .../dns/zone-transfers/peers/delete.ts | 48 +- .../dns/zone-transfers/peers/get.ts | 42 +- .../dns/zone-transfers/peers/index.ts | 23 +- .../dns/zone-transfers/peers/list.ts | 37 +- .../dns/zone-transfers/peers/update.ts | 96 +- .../dns/zone-transfers/tsigs/create.ts | 68 +- .../dns/zone-transfers/tsigs/delete.ts | 48 +- .../dns/zone-transfers/tsigs/get.ts | 42 +- .../dns/zone-transfers/tsigs/index.ts | 23 +- .../dns/zone-transfers/tsigs/list.ts | 37 +- .../dns/zone-transfers/tsigs/update.ts | 73 +- .../_generated/durable-objects/index.ts | 15 +- .../durable-objects/namespaces/index.ts | 17 +- .../durable-objects/namespaces/list.ts | 54 +- .../namespaces/objects/index.ts | 13 +- .../namespaces/objects/list.ts | 68 +- .../email-auth/dmarc-reports/edit.ts | 64 +- .../email-auth/dmarc-reports/get.ts | 40 +- .../email-auth/dmarc-reports/index.ts | 17 +- .../commands/_generated/email-auth/index.ts | 17 +- .../_generated/email-auth/spf/index.ts | 15 +- .../_generated/email-auth/spf/inspect.ts | 50 +- .../email-routing/addresses/create.ts | 60 +- .../email-routing/addresses/delete.ts | 57 +- .../email-routing/addresses/edit.ts | 71 +- .../_generated/email-routing/addresses/get.ts | 51 +- .../email-routing/addresses/index.ts | 23 +- .../email-routing/addresses/list.ts | 78 +- .../_generated/email-routing/disable.ts | 63 +- .../_generated/email-routing/dns/get.ts | 52 +- .../_generated/email-routing/dns/index.ts | 17 +- .../_generated/email-routing/dns/unlock.ts | 57 +- .../_generated/email-routing/enable.ts | 57 +- .../_generated/email-routing/index.ts | 25 +- .../email-routing/rules/catch-all/get.ts | 40 +- .../email-routing/rules/catch-all/index.ts | 17 +- .../email-routing/rules/catch-all/update.ts | 99 +- .../_generated/email-routing/rules/create.ts | 115 +- .../_generated/email-routing/rules/delete.ts | 57 +- .../_generated/email-routing/rules/get.ts | 51 +- .../_generated/email-routing/rules/index.ts | 27 +- .../email-routing/rules/list-account.ts | 67 +- .../_generated/email-routing/rules/plan.ts | 82 +- .../_generated/email-routing/rules/update.ts | 120 +- .../_generated/email-routing/settings/edit.ts | 76 +- .../_generated/email-routing/settings/get.ts | 40 +- .../email-routing/settings/index.ts | 19 +- .../email-routing/settings/replace.ts | 76 +- .../allow-policies/bulk-apply.ts | 96 +- .../email-security/allow-policies/create.ts | 159 +- .../email-security/allow-policies/delete.ts | 57 +- .../email-security/allow-policies/edit.ts | 170 ++- .../email-security/allow-policies/get.ts | 51 +- .../email-security/allow-policies/index.ts | 27 +- .../email-security/allow-policies/list.ts | 156 +- .../email-security/allow-policies/update.ts | 170 ++- .../email-security/analytics/index.ts | 15 +- .../analytics/monthly-report/get.ts | 40 +- .../analytics/monthly-report/index.ts | 13 +- .../block-senders/bulk-apply.ts | 96 +- .../email-security/block-senders/create.ts | 99 +- .../email-security/block-senders/delete.ts | 57 +- .../email-security/block-senders/edit.ts | 110 +- .../email-security/block-senders/get.ts | 51 +- .../email-security/block-senders/index.ts | 27 +- .../email-security/block-senders/list.ts | 120 +- .../email-security/block-senders/update.ts | 110 +- .../email-security/bulk-actions/cancel.ts | 51 +- .../email-security/bulk-actions/create.ts | 291 ++-- .../email-security/bulk-actions/delete.ts | 57 +- .../email-security/bulk-actions/get.ts | 51 +- .../email-security/bulk-actions/index.ts | 25 +- .../email-security/bulk-actions/list.ts | 80 +- .../bulk-actions/messages/index.ts | 13 +- .../bulk-actions/messages/list.ts | 79 +- .../content-policies/bulk-apply.ts | 96 +- .../email-security/content-policies/create.ts | 109 +- .../email-security/content-policies/delete.ts | 57 +- .../email-security/content-policies/edit.ts | 120 +- .../email-security/content-policies/get.ts | 51 +- .../email-security/content-policies/index.ts | 25 +- .../email-security/content-policies/list.ts | 118 +- .../email-security/domains/bulk-apply.ts | 96 +- .../email-security/domains/create.ts | 166 ++- .../email-security/domains/delete.ts | 53 +- .../_generated/email-security/domains/edit.ts | 163 +- .../_generated/email-security/domains/get.ts | 47 +- .../email-security/domains/index.ts | 29 +- .../_generated/email-security/domains/list.ts | 143 +- .../email-security/domains/update.ts | 165 +- .../domains/verification/get.ts | 47 +- .../domains/verification/index.ts | 13 +- .../impersonation-registry/create.ts | 131 +- .../impersonation-registry/delete.ts | 57 +- .../impersonation-registry/edit.ts | 142 +- .../impersonation-registry/get.ts | 51 +- .../impersonation-registry/index.ts | 23 +- .../impersonation-registry/list.ts | 101 +- .../_generated/email-security/index.ts | 39 +- .../investigate/action-log/index.ts | 13 +- .../investigate/action-log/list.ts | 71 +- .../investigate/detections/get.ts | 52 +- .../investigate/detections/index.ts | 13 +- .../email-security/investigate/get.ts | 59 +- .../email-security/investigate/index.ts | 31 +- .../email-security/investigate/list.ts | 218 +-- .../email-security/investigate/move.ts | 102 +- .../investigate/preview/generate.ts | 61 +- .../email-security/investigate/preview/get.ts | 52 +- .../investigate/preview/index.ts | 17 +- .../email-security/investigate/raw/get.ts | 52 +- .../email-security/investigate/raw/index.ts | 13 +- .../email-security/investigate/release.ts | 63 +- .../email-security/investigate/trace/get.ts | 52 +- .../email-security/investigate/trace/index.ts | 13 +- .../email-security/phishguard/index.ts | 15 +- .../phishguard/reports/index.ts | 13 +- .../email-security/phishguard/reports/list.ts | 104 +- .../sending-domain-restrictions/create.ts | 79 +- .../sending-domain-restrictions/delete.ts | 57 +- .../sending-domain-restrictions/edit.ts | 90 +- .../sending-domain-restrictions/get.ts | 51 +- .../sending-domain-restrictions/index.ts | 23 +- .../sending-domain-restrictions/list.ts | 88 +- .../email-security/submissions/create.ts | 70 +- .../email-security/submissions/index.ts | 17 +- .../email-security/submissions/list.ts | 183 +-- .../trusted-domains/bulk-apply.ts | 96 +- .../email-security/trusted-domains/create.ts | 92 +- .../email-security/trusted-domains/delete.ts | 57 +- .../email-security/trusted-domains/edit.ts | 103 +- .../email-security/trusted-domains/get.ts | 51 +- .../email-security/trusted-domains/index.ts | 27 +- .../email-security/trusted-domains/list.ts | 115 +- .../email-security/trusted-domains/update.ts | 103 +- .../url-ignore-patterns/bulk-apply.ts | 96 +- .../url-ignore-patterns/create.ts | 74 +- .../url-ignore-patterns/delete.ts | 57 +- .../url-ignore-patterns/edit.ts | 85 +- .../email-security/url-ignore-patterns/get.ts | 51 +- .../url-ignore-patterns/index.ts | 25 +- .../url-ignore-patterns/list.ts | 60 +- .../commands/_generated/email-sending/get.ts | 45 +- .../_generated/email-sending/index.ts | 27 +- .../_generated/email-sending/limits/get.ts | 40 +- .../_generated/email-sending/limits/index.ts | 13 +- .../email-sending/reputation/get.ts | 40 +- .../email-sending/reputation/index.ts | 13 +- .../_generated/email-sending/send-raw.ts | 81 +- .../commands/_generated/email-sending/send.ts | 211 +-- .../email-sending/subdomains/create.ts | 62 +- .../email-sending/subdomains/delete.ts | 57 +- .../email-sending/subdomains/dns/fix.ts | 51 +- .../email-sending/subdomains/dns/get.ts | 51 +- .../email-sending/subdomains/dns/index.ts | 19 +- .../email-sending/subdomains/dns/status.ts | 51 +- .../email-sending/subdomains/get.ts | 51 +- .../email-sending/subdomains/index.ts | 29 +- .../email-sending/subdomains/list.ts | 40 +- .../email-sending/subdomains/preview.ts | 62 +- .../subdomains/reputation/get-complaints.ts | 63 +- .../subdomains/reputation/index.ts | 15 +- .../email-sending/subdomains/update.ts | 79 +- .../email-sending/suppressions/create.ts | 139 +- .../email-sending/suppressions/delete.ts | 57 +- .../email-sending/suppressions/edit.ts | 93 +- .../email-sending/suppressions/get.ts | 51 +- .../email-sending/suppressions/import.ts | 62 +- .../email-sending/suppressions/index.ts | 25 +- .../email-sending/suppressions/list.ts | 110 +- .../commands/_generated/feedback/diagnose.ts | 40 +- .../src/commands/_generated/feedback/index.ts | 17 +- .../src/commands/_generated/feedback/send.ts | 570 ++++--- .../_generated/field-extractors/delete.ts | 53 +- .../_generated/field-extractors/get.ts | 47 +- .../_generated/field-extractors/index.ts | 19 +- .../_generated/field-extractors/update.ts | 70 +- .../firewall/access-rules/create.ts | 97 +- .../firewall/access-rules/delete.ts | 57 +- .../_generated/firewall/access-rules/edit.ts | 109 +- .../_generated/firewall/access-rules/get.ts | 51 +- .../_generated/firewall/access-rules/index.ts | 23 +- .../_generated/firewall/access-rules/list.ts | 134 +- .../src/commands/_generated/firewall/index.ts | 21 +- .../_generated/firewall/lockdowns/create.ts | 96 +- .../_generated/firewall/lockdowns/delete.ts | 57 +- .../_generated/firewall/lockdowns/get.ts | 51 +- .../_generated/firewall/lockdowns/index.ts | 23 +- .../_generated/firewall/lockdowns/list.ts | 154 +- .../_generated/firewall/lockdowns/update.ts | 85 +- .../firewall/payload-logging/delete.ts | 46 +- .../firewall/payload-logging/get.ts | 40 +- .../firewall/payload-logging/index.ts | 19 +- .../firewall/payload-logging/update.ts | 62 +- .../_generated/firewall/ua-rules/create.ts | 107 +- .../_generated/firewall/ua-rules/delete.ts | 57 +- .../_generated/firewall/ua-rules/get.ts | 51 +- .../_generated/firewall/ua-rules/index.ts | 23 +- .../_generated/firewall/ua-rules/list.ts | 88 +- .../_generated/firewall/ua-rules/update.ts | 118 +- .../_generated/flagship/apps/create.ts | 62 +- .../flagship/apps/definitions/get.ts | 61 +- .../flagship/apps/definitions/index.ts | 13 +- .../_generated/flagship/apps/delete.ts | 57 +- .../_generated/flagship/apps/evaluate/get.ts | 73 +- .../flagship/apps/evaluate/index.ts | 13 +- .../flagship/apps/flags/changelog/index.ts | 13 +- .../flagship/apps/flags/changelog/list.ts | 80 +- .../_generated/flagship/apps/flags/create.ts | 140 +- .../_generated/flagship/apps/flags/delete.ts | 67 +- .../flagship/apps/flags/evaluate.ts | 83 +- .../_generated/flagship/apps/flags/get.ts | 61 +- .../_generated/flagship/apps/flags/index.ts | 29 +- .../_generated/flagship/apps/flags/list.ts | 70 +- .../_generated/flagship/apps/flags/patch.ts | 108 +- .../_generated/flagship/apps/flags/update.ts | 150 +- .../commands/_generated/flagship/apps/get.ts | 51 +- .../_generated/flagship/apps/index.ts | 29 +- .../commands/_generated/flagship/apps/list.ts | 40 +- .../_generated/flagship/apps/update.ts | 73 +- .../src/commands/_generated/flagship/index.ts | 13 +- .../cli/src/commands/_generated/fraud/get.ts | 37 +- .../src/commands/_generated/fraud/index.ts | 17 +- .../src/commands/_generated/fraud/update.ts | 153 +- .../google-tag-gateway/config/get.ts | 40 +- .../google-tag-gateway/config/index.ts | 17 +- .../google-tag-gateway/config/update.ts | 95 +- .../_generated/google-tag-gateway/index.ts | 15 +- .../_generated/healthchecks/create.ts | 270 ++-- .../_generated/healthchecks/delete.ts | 50 +- .../commands/_generated/healthchecks/edit.ts | 277 ++-- .../commands/_generated/healthchecks/get.ts | 47 +- .../commands/_generated/healthchecks/index.ts | 27 +- .../commands/_generated/healthchecks/list.ts | 58 +- .../healthchecks/previews/create.ts | 273 ++-- .../healthchecks/previews/delete.ts | 53 +- .../_generated/healthchecks/previews/get.ts | 47 +- .../_generated/healthchecks/previews/index.ts | 19 +- .../_generated/healthchecks/update.ts | 277 ++-- .../commands/_generated/hyperdrive/create.ts | 389 ++--- .../commands/_generated/hyperdrive/delete.ts | 57 +- .../commands/_generated/hyperdrive/edit.ts | 144 +- .../src/commands/_generated/hyperdrive/get.ts | 51 +- .../commands/_generated/hyperdrive/index.ts | 29 +- .../hyperdrive/integration/index.ts | 15 +- .../integration/planetscale/index.ts | 15 +- .../integration/planetscale/signature.ts | 40 +- .../commands/_generated/hyperdrive/list.ts | 57 +- .../commands/_generated/hyperdrive/replace.ts | 268 ++-- .../commands/_generated/hyperdrive/restart.ts | 51 +- .../cli/src/commands/_generated/iam/index.ts | 25 +- .../_generated/iam/oauth-clients/create.ts | 199 +-- .../oauth-clients/delete-rotated-secret.ts | 57 +- .../_generated/iam/oauth-clients/delete.ts | 57 +- .../_generated/iam/oauth-clients/get.ts | 51 +- .../_generated/iam/oauth-clients/index.ts | 27 +- .../_generated/iam/oauth-clients/list.ts | 39 +- .../iam/oauth-clients/rotate-secret.ts | 51 +- .../_generated/iam/oauth-clients/update.ts | 224 +-- .../_generated/iam/oauth-scopes/index.ts | 13 +- .../_generated/iam/oauth-scopes/list.ts | 40 +- .../_generated/iam/permission-groups/get.ts | 51 +- .../_generated/iam/permission-groups/index.ts | 17 +- .../_generated/iam/permission-groups/list.ts | 90 +- .../_generated/iam/resource-groups/create.ts | 72 +- .../_generated/iam/resource-groups/delete.ts | 57 +- .../_generated/iam/resource-groups/get.ts | 51 +- .../_generated/iam/resource-groups/index.ts | 23 +- .../_generated/iam/resource-groups/list.ts | 60 +- .../_generated/iam/resource-groups/update.ts | 83 +- .../_generated/iam/sso/begin-verification.ts | 51 +- .../src/commands/_generated/iam/sso/create.ts | 74 +- .../src/commands/_generated/iam/sso/delete.ts | 57 +- .../src/commands/_generated/iam/sso/get.ts | 51 +- .../src/commands/_generated/iam/sso/index.ts | 25 +- .../src/commands/_generated/iam/sso/list.ts | 40 +- .../src/commands/_generated/iam/sso/update.ts | 77 +- .../_generated/iam/user-groups/create.ts | 69 +- .../_generated/iam/user-groups/delete.ts | 57 +- .../_generated/iam/user-groups/get.ts | 51 +- .../_generated/iam/user-groups/index.ts | 25 +- .../_generated/iam/user-groups/list.ts | 98 +- .../iam/user-groups/members/create.ts | 61 +- .../iam/user-groups/members/delete.ts | 67 +- .../_generated/iam/user-groups/members/get.ts | 61 +- .../iam/user-groups/members/index.ts | 23 +- .../iam/user-groups/members/list.ts | 88 +- .../iam/user-groups/members/update.ts | 61 +- .../_generated/iam/user-groups/update.ts | 80 +- .../commands/_generated/images/config/edit.ts | 66 +- .../commands/_generated/images/config/get.ts | 40 +- .../_generated/images/config/index.ts | 17 +- .../src/commands/_generated/images/create.ts | 111 +- .../src/commands/_generated/images/delete.ts | 57 +- .../_generated/images/direct-upload.ts | 111 +- .../src/commands/_generated/images/edit.ts | 88 +- .../commands/_generated/images/flows/get.ts | 40 +- .../commands/_generated/images/flows/index.ts | 17 +- .../_generated/images/flows/update.ts | 79 +- .../commands/_generated/images/get-blob.ts | 57 +- .../cli/src/commands/_generated/images/get.ts | 48 +- .../_generated/images/import/abort.ts | 51 +- .../_generated/images/import/create.ts | 108 +- .../_generated/images/import/delete.ts | 57 +- .../commands/_generated/images/import/get.ts | 51 +- .../_generated/images/import/index.ts | 31 +- .../commands/_generated/images/import/list.ts | 57 +- .../commands/_generated/images/import/logs.ts | 71 +- .../_generated/images/import/progress.ts | 51 +- .../_generated/images/import/sources/check.ts | 51 +- .../images/import/sources/create.ts | 101 +- .../images/import/sources/delete.ts | 57 +- .../_generated/images/import/sources/get.ts | 51 +- .../_generated/images/import/sources/index.ts | 27 +- .../_generated/images/import/sources/list.ts | 70 +- .../images/import/sources/pre-check.ts | 101 +- .../images/import/sources/update.ts | 71 +- .../_generated/images/import/start.ts | 51 +- .../src/commands/_generated/images/index.ts | 39 +- .../commands/_generated/images/keys/create.ts | 51 +- .../commands/_generated/images/keys/delete.ts | 57 +- .../commands/_generated/images/keys/index.ts | 19 +- .../commands/_generated/images/keys/list.ts | 37 +- .../src/commands/_generated/images/list.ts | 79 +- .../src/commands/_generated/images/stats.ts | 40 +- .../_generated/images/variants/create.ts | 112 +- .../_generated/images/variants/delete.ts | 51 +- .../_generated/images/variants/edit.ts | 111 +- .../_generated/images/variants/get.ts | 45 +- .../_generated/images/variants/index.ts | 23 +- .../_generated/images/variants/list.ts | 37 +- .../src/commands/_generated/intel/asn/get.ts | 45 +- .../commands/_generated/intel/asn/index.ts | 17 +- .../_generated/intel/asn/subnets/index.ts | 13 +- .../_generated/intel/asn/subnets/list.ts | 39 +- .../intel/attack-surface-report/index.ts | 15 +- .../attack-surface-report/issue-types/get.ts | 40 +- .../issue-types/index.ts | 13 +- .../commands/_generated/intel/dns/index.ts | 13 +- .../src/commands/_generated/intel/dns/list.ts | 72 +- .../_generated/intel/domain-history/get.ts | 42 +- .../_generated/intel/domain-history/index.ts | 13 +- .../_generated/intel/domains/bulks/get.ts | 77 +- .../_generated/intel/domains/bulks/index.ts | 13 +- .../commands/_generated/intel/domains/get.ts | 58 +- .../_generated/intel/domains/index.ts | 17 +- .../src/commands/_generated/intel/index.ts | 37 +- .../intel/indicator-feeds/create.ts | 70 +- .../_generated/intel/indicator-feeds/data.ts | 47 +- .../intel/indicator-feeds/downloads/get.ts | 47 +- .../intel/indicator-feeds/downloads/index.ts | 13 +- .../_generated/intel/indicator-feeds/get.ts | 47 +- .../_generated/intel/indicator-feeds/index.ts | 33 +- .../_generated/intel/indicator-feeds/list.ts | 40 +- .../indicator-feeds/permissions/grant.ts | 72 +- .../indicator-feeds/permissions/index.ts | 19 +- .../intel/indicator-feeds/permissions/list.ts | 40 +- .../indicator-feeds/permissions/revoke.ts | 76 +- .../intel/indicator-feeds/providers/create.ts | 69 +- .../intel/indicator-feeds/providers/index.ts | 15 +- .../intel/indicator-feeds/snapshots/index.ts | 15 +- .../intel/indicator-feeds/snapshots/update.ts | 91 +- .../intel/indicator-feeds/update.ts | 97 +- .../intel/indicator-feeds/uploads/get.ts | 51 +- .../intel/indicator-feeds/uploads/index.ts | 13 +- .../_generated/intel/ip-lists/index.ts | 13 +- .../_generated/intel/ip-lists/list.ts | 40 +- .../src/commands/_generated/intel/ips/get.ts | 44 +- .../commands/_generated/intel/ips/index.ts | 13 +- .../intel/miscategorizations/create.ts | 131 +- .../intel/miscategorizations/index.ts | 15 +- .../_generated/intel/sinkholes/create.ts | 92 +- .../_generated/intel/sinkholes/delete.ts | 57 +- .../_generated/intel/sinkholes/get.ts | 51 +- .../_generated/intel/sinkholes/index.ts | 25 +- .../intel/sinkholes/ingresses/create.ts | 73 +- .../intel/sinkholes/ingresses/delete.ts | 67 +- .../intel/sinkholes/ingresses/get.ts | 61 +- .../intel/sinkholes/ingresses/index.ts | 23 +- .../intel/sinkholes/ingresses/list.ts | 50 +- .../intel/sinkholes/ingresses/update.ts | 83 +- .../_generated/intel/sinkholes/list.ts | 40 +- .../_generated/intel/sinkholes/update.ts | 103 +- .../src/commands/_generated/intel/urls/get.ts | 46 +- .../commands/_generated/intel/urls/index.ts | 13 +- .../commands/_generated/intel/whois/get.ts | 42 +- .../commands/_generated/intel/whois/index.ts | 13 +- .../cli/src/commands/_generated/ips/index.ts | 13 +- .../cli/src/commands/_generated/ips/list.ts | 52 +- .../cli/src/commands/_generated/k2/index.ts | 15 +- .../commands/_generated/k2/streams/create.ts | 112 +- .../commands/_generated/k2/streams/delete.ts | 57 +- .../src/commands/_generated/k2/streams/get.ts | 48 +- .../commands/_generated/k2/streams/index.ts | 25 +- .../commands/_generated/k2/streams/list.ts | 57 +- .../k2/streams/subscriptions/index.ts | 13 +- .../k2/streams/subscriptions/list.ts | 50 +- .../commands/_generated/k2/streams/update.ts | 112 +- .../cli/src/commands/_generated/kv/index.ts | 19 +- .../_generated/kv/keys/bulk-delete.ts | 66 +- .../commands/_generated/kv/keys/bulk-get.ts | 91 +- .../commands/_generated/kv/keys/bulk-put.ts | 60 +- .../src/commands/_generated/kv/keys/delete.ts | 69 +- .../src/commands/_generated/kv/keys/get.ts | 69 +- .../src/commands/_generated/kv/keys/index.ts | 27 +- .../src/commands/_generated/kv/keys/list.ts | 82 +- .../src/commands/_generated/kv/keys/put.ts | 115 +- .../commands/_generated/kv/metadata/get.ts | 63 +- .../commands/_generated/kv/metadata/index.ts | 13 +- .../_generated/kv/namespaces/create.ts | 88 +- .../_generated/kv/namespaces/delete.ts | 57 +- .../commands/_generated/kv/namespaces/get.ts | 51 +- .../_generated/kv/namespaces/index.ts | 23 +- .../commands/_generated/kv/namespaces/list.ts | 80 +- .../_generated/kv/namespaces/update.ts | 71 +- .../detections/create.ts | 72 +- .../detections/delete.ts | 57 +- .../detections/get.ts | 51 +- .../detections/index.ts | 23 +- .../detections/list.ts | 40 +- .../detections/update.ts | 83 +- .../leaked-credential-checks/get.ts | 40 +- .../leaked-credential-checks/index.ts | 19 +- .../leaked-credential-checks/update.ts | 66 +- .../load-balancers/account/create.ts | 363 +++-- .../load-balancers/account/delete.ts | 57 +- .../_generated/load-balancers/account/edit.ts | 374 ++--- .../_generated/load-balancers/account/get.ts | 51 +- .../load-balancers/account/index.ts | 27 +- .../_generated/load-balancers/account/list.ts | 40 +- .../load-balancers/account/update.ts | 374 ++--- .../load-balancers/account/usage/index.ts | 13 +- .../load-balancers/account/usage/list.ts | 40 +- .../_generated/load-balancers/index.ts | 27 +- .../load-balancers/monitor-groups/create.ts | 72 +- .../load-balancers/monitor-groups/delete.ts | 57 +- .../load-balancers/monitor-groups/edit.ts | 83 +- .../load-balancers/monitor-groups/get.ts | 51 +- .../load-balancers/monitor-groups/index.ts | 27 +- .../load-balancers/monitor-groups/list.ts | 40 +- .../monitor-groups/references/index.ts | 13 +- .../monitor-groups/references/list.ts | 50 +- .../load-balancers/monitor-groups/update.ts | 83 +- .../load-balancers/monitors/create.ts | 203 +-- .../load-balancers/monitors/delete.ts | 51 +- .../load-balancers/monitors/edit.ts | 213 +-- .../_generated/load-balancers/monitors/get.ts | 45 +- .../load-balancers/monitors/index.ts | 29 +- .../load-balancers/monitors/list.ts | 40 +- .../monitors/previews/create.ts | 211 +-- .../load-balancers/monitors/previews/index.ts | 15 +- .../monitors/references/index.ts | 13 +- .../monitors/references/list.ts | 46 +- .../load-balancers/monitors/update.ts | 213 +-- .../load-balancers/pools/bulk-edit.ts | 62 +- .../_generated/load-balancers/pools/create.ts | 279 ++-- .../_generated/load-balancers/pools/delete.ts | 51 +- .../_generated/load-balancers/pools/edit.ts | 289 ++-- .../_generated/load-balancers/pools/get.ts | 45 +- .../load-balancers/pools/health/create.ts | 211 +-- .../load-balancers/pools/health/get.ts | 45 +- .../load-balancers/pools/health/index.ts | 17 +- .../_generated/load-balancers/pools/index.ts | 31 +- .../_generated/load-balancers/pools/list.ts | 49 +- .../load-balancers/pools/references/index.ts | 13 +- .../load-balancers/pools/references/list.ts | 46 +- .../_generated/load-balancers/pools/update.ts | 289 ++-- .../_generated/load-balancers/previews/get.ts | 45 +- .../load-balancers/previews/index.ts | 13 +- .../_generated/load-balancers/regions/get.ts | 53 +- .../load-balancers/regions/index.ts | 17 +- .../_generated/load-balancers/regions/list.ts | 67 +- .../load-balancers/searches/index.ts | 13 +- .../load-balancers/searches/list.ts | 65 +- .../logpush/account-datasets/fields/get.ts | 53 +- .../logpush/account-datasets/fields/index.ts | 13 +- .../logpush/account-datasets/index.ts | 17 +- .../logpush/account-datasets/jobs/get.ts | 53 +- .../logpush/account-datasets/jobs/index.ts | 13 +- .../_generated/logpush/account-jobs/create.ts | 325 ++-- .../_generated/logpush/account-jobs/delete.ts | 53 +- .../_generated/logpush/account-jobs/get.ts | 47 +- .../_generated/logpush/account-jobs/index.ts | 23 +- .../_generated/logpush/account-jobs/list.ts | 40 +- .../_generated/logpush/account-jobs/update.ts | 319 ++-- .../logpush/account-ownership/create.ts | 62 +- .../logpush/account-ownership/index.ts | 17 +- .../account-ownership/validate/create.ts | 72 +- .../account-ownership/validate/index.ts | 15 +- .../destination-exists-delete.ts | 62 +- .../account-validate/destination/delete.ts | 62 +- .../account-validate/destination/index.ts | 15 +- .../logpush/account-validate/index.ts | 19 +- .../logpush/account-validate/origin/create.ts | 62 +- .../logpush/account-validate/origin/index.ts | 15 +- .../_generated/logpush/edge/create.ts | 81 +- .../commands/_generated/logpush/edge/get.ts | 37 +- .../commands/_generated/logpush/edge/index.ts | 17 +- .../src/commands/_generated/logpush/index.ts | 25 +- .../logpush/transformers/content/get.ts | 63 +- .../logpush/transformers/content/index.ts | 13 +- .../_generated/logpush/transformers/create.ts | 82 +- .../_generated/logpush/transformers/delete.ts | 57 +- .../_generated/logpush/transformers/get.ts | 51 +- .../_generated/logpush/transformers/index.ts | 29 +- .../_generated/logpush/transformers/list.ts | 40 +- .../logpush/transformers/preview.ts | 72 +- .../_generated/logpush/transformers/update.ts | 93 +- .../logpush/transformers/versions/index.ts | 13 +- .../logpush/transformers/versions/list.ts | 60 +- .../_generated/logs/datasets/available.ts | 40 +- .../_generated/logs/datasets/create.ts | 87 +- .../_generated/logs/datasets/delete.ts | 57 +- .../commands/_generated/logs/datasets/get.ts | 51 +- .../_generated/logs/datasets/index.ts | 25 +- .../commands/_generated/logs/datasets/list.ts | 47 +- .../_generated/logs/datasets/update.ts | 106 +- .../cli/src/commands/_generated/logs/index.ts | 25 +- .../src/commands/_generated/logs/list/get.ts | 106 +- .../commands/_generated/logs/list/index.ts | 13 +- .../cli/src/commands/_generated/logs/query.ts | 60 +- .../src/commands/_generated/logs/rayid/get.ts | 66 +- .../commands/_generated/logs/rayid/index.ts | 13 +- .../_generated/logs/received/fields/get.ts | 40 +- .../_generated/logs/received/fields/index.ts | 13 +- .../commands/_generated/logs/received/get.ts | 99 +- .../_generated/logs/received/index.ts | 17 +- .../commands/_generated/logs/retrieve/get.ts | 96 +- .../_generated/logs/retrieve/index.ts | 13 +- .../configs/create.ts | 92 +- .../configs/delete.ts | 46 +- .../magic-network-monitoring/configs/edit.ts | 91 +- .../configs/full/get.ts | 40 +- .../configs/full/index.ts | 13 +- .../magic-network-monitoring/configs/get.ts | 40 +- .../magic-network-monitoring/configs/index.ts | 25 +- .../configs/update.ts | 91 +- .../magic-network-monitoring/index.ts | 19 +- .../rules/advertisements/edit.ts | 51 +- .../rules/advertisements/index.ts | 13 +- .../rules/bulk/create.ts | 50 +- .../rules/bulk/index.ts | 17 +- .../rules/bulk/update.ts | 50 +- .../magic-network-monitoring/rules/create.ts | 169 ++- .../magic-network-monitoring/rules/delete.ts | 57 +- .../magic-network-monitoring/rules/edit.ts | 179 +-- .../magic-network-monitoring/rules/get.ts | 51 +- .../magic-network-monitoring/rules/index.ts | 29 +- .../magic-network-monitoring/rules/list.ts | 40 +- .../magic-network-monitoring/rules/update.ts | 168 ++- .../vpc-flows/index.ts | 15 +- .../vpc-flows/tokens/create.ts | 40 +- .../vpc-flows/tokens/index.ts | 15 +- .../configs/dns/index.ts | 15 +- .../configs/dns/protection/index.ts | 15 +- .../dns/protection/rules/bulk-delete.ts | 46 +- .../configs/dns/protection/rules/create.ts | 120 +- .../configs/dns/protection/rules/delete.ts | 57 +- .../configs/dns/protection/rules/get.ts | 51 +- .../configs/dns/protection/rules/index.ts | 25 +- .../configs/dns/protection/rules/list.ts | 83 +- .../configs/dns/protection/rules/update.ts | 109 +- .../advanced-dns-protection/configs/index.ts | 13 +- .../advanced-dns-protection/index.ts | 15 +- .../configs/allowlist/bulk-delete.ts | 46 +- .../configs/allowlist/create.ts | 75 +- .../configs/allowlist/index.ts | 21 +- .../configs/allowlist/list.ts | 83 +- .../configs/allowlist/prefix/delete.ts | 57 +- .../configs/allowlist/prefix/get.ts | 51 +- .../configs/allowlist/prefix/index.ts | 19 +- .../configs/allowlist/prefix/update.ts | 77 +- .../advanced-tcp-protection/configs/index.ts | 21 +- .../configs/prefixes/bulk-delete.ts | 46 +- .../configs/prefixes/bulk/create.ts | 50 +- .../configs/prefixes/bulk/index.ts | 15 +- .../configs/prefixes/create.ts | 75 +- .../configs/prefixes/delete.ts | 57 +- .../configs/prefixes/get.ts | 51 +- .../configs/prefixes/index.ts | 27 +- .../configs/prefixes/list.ts | 83 +- .../configs/prefixes/update.ts | 76 +- .../configs/syn/index.ts | 15 +- .../syn/protection/filters/bulk-delete.ts | 46 +- .../configs/syn/protection/filters/create.ts | 72 +- .../configs/syn/protection/filters/delete.ts | 57 +- .../configs/syn/protection/filters/get.ts | 51 +- .../configs/syn/protection/filters/index.ts | 25 +- .../configs/syn/protection/filters/list.ts | 93 +- .../configs/syn/protection/filters/update.ts | 83 +- .../configs/syn/protection/index.ts | 17 +- .../syn/protection/rules/bulk-delete.ts | 46 +- .../configs/syn/protection/rules/create.ts | 114 +- .../configs/syn/protection/rules/delete.ts | 57 +- .../configs/syn/protection/rules/get.ts | 51 +- .../configs/syn/protection/rules/index.ts | 25 +- .../configs/syn/protection/rules/list.ts | 83 +- .../configs/syn/protection/rules/update.ts | 103 +- .../configs/tcp/flow/index.ts | 15 +- .../flow/protection/filters/bulk-delete.ts | 46 +- .../tcp/flow/protection/filters/create.ts | 72 +- .../tcp/flow/protection/filters/delete.ts | 57 +- .../tcp/flow/protection/filters/get.ts | 51 +- .../tcp/flow/protection/filters/index.ts | 25 +- .../tcp/flow/protection/filters/list.ts | 93 +- .../tcp/flow/protection/filters/update.ts | 83 +- .../configs/tcp/flow/protection/index.ts | 17 +- .../tcp/flow/protection/rules/bulk-delete.ts | 46 +- .../tcp/flow/protection/rules/create.ts | 104 +- .../tcp/flow/protection/rules/delete.ts | 57 +- .../configs/tcp/flow/protection/rules/get.ts | 51 +- .../tcp/flow/protection/rules/index.ts | 25 +- .../configs/tcp/flow/protection/rules/list.ts | 83 +- .../tcp/flow/protection/rules/update.ts | 93 +- .../configs/tcp/index.ts | 17 +- .../configs/tcp/protection/index.ts | 15 +- .../configs/tcp/protection/status/get.ts | 40 +- .../configs/tcp/protection/status/index.ts | 17 +- .../configs/tcp/protection/status/update.ts | 55 +- .../advanced-tcp-protection/index.ts | 15 +- .../_generated/magic-transit/apps/create.ts | 76 +- .../_generated/magic-transit/apps/delete.ts | 53 +- .../_generated/magic-transit/apps/index.ts | 21 +- .../_generated/magic-transit/apps/list.ts | 39 +- .../_generated/magic-transit/apps/update.ts | 86 +- .../bgp-filter-profiles/create.ts | 94 +- .../bgp-filter-profiles/delete.ts | 51 +- .../magic-transit/bgp-filter-profiles/get.ts | 45 +- .../bgp-filter-profiles/index.ts | 23 +- .../magic-transit/bgp-filter-profiles/list.ts | 40 +- .../bgp-filter-profiles/update.ts | 102 +- .../magic-transit/bgp-settings/get.ts | 40 +- .../magic-transit/bgp-settings/index.ts | 17 +- .../magic-transit/bgp-settings/update.ts | 67 +- .../cf-interconnects/bulk-update.ts | 62 +- .../magic-transit/cf-interconnects/get.ts | 59 +- .../magic-transit/cf-interconnects/index.ts | 21 +- .../magic-transit/cf-interconnects/list.ts | 52 +- .../magic-transit/cf-interconnects/update.ts | 290 ++-- .../magic-transit/cf1-sites/create.ts | 50 +- .../magic-transit/cf1-sites/delete.ts | 53 +- .../_generated/magic-transit/cf1-sites/get.ts | 47 +- .../magic-transit/cf1-sites/index.ts | 25 +- .../magic-transit/cf1-sites/list.ts | 40 +- .../magic-transit/cf1-sites/ramps/create.ts | 57 +- .../magic-transit/cf1-sites/ramps/delete.ts | 57 +- .../magic-transit/cf1-sites/ramps/get.ts | 51 +- .../magic-transit/cf1-sites/ramps/index.ts | 21 +- .../magic-transit/cf1-sites/ramps/list.ts | 46 +- .../magic-transit/cf1-sites/update.ts | 109 +- .../magic-transit/gre-tunnels/bulk-update.ts | 62 +- .../magic-transit/gre-tunnels/create.ts | 269 ++-- .../magic-transit/gre-tunnels/delete.ts | 63 +- .../magic-transit/gre-tunnels/get.ts | 59 +- .../magic-transit/gre-tunnels/index.ts | 25 +- .../magic-transit/gre-tunnels/list.ts | 52 +- .../magic-transit/gre-tunnels/update.ts | 219 +-- .../_generated/magic-transit/index.ts | 39 +- .../ipsec-tunnels/bulk-update.ts | 62 +- .../magic-transit/ipsec-tunnels/create.ts | 274 ++-- .../magic-transit/ipsec-tunnels/delete.ts | 63 +- .../magic-transit/ipsec-tunnels/get.ts | 59 +- .../magic-transit/ipsec-tunnels/index.ts | 29 +- .../magic-transit/ipsec-tunnels/list.ts | 52 +- .../ipsec-tunnels/psk-generate.ts | 47 +- .../magic-transit/ipsec-tunnels/psk-set.ts | 67 +- .../magic-transit/ipsec-tunnels/update.ts | 283 ++-- .../_generated/magic-transit/pcaps/create.ts | 50 +- .../magic-transit/pcaps/download/get.ts | 51 +- .../magic-transit/pcaps/download/index.ts | 13 +- .../_generated/magic-transit/pcaps/get.ts | 45 +- .../_generated/magic-transit/pcaps/index.ts | 25 +- .../_generated/magic-transit/pcaps/list.ts | 40 +- .../magic-transit/pcaps/ownership/create.ts | 62 +- .../magic-transit/pcaps/ownership/delete.ts | 53 +- .../magic-transit/pcaps/ownership/get.ts | 40 +- .../magic-transit/pcaps/ownership/index.ts | 21 +- .../magic-transit/pcaps/ownership/validate.ts | 72 +- .../_generated/magic-transit/pcaps/stop.ts | 48 +- .../magic-transit/redundancy-groups/create.ts | 81 +- .../magic-transit/redundancy-groups/delete.ts | 53 +- .../magic-transit/redundancy-groups/get.ts | 47 +- .../magic-transit/redundancy-groups/index.ts | 23 +- .../magic-transit/redundancy-groups/list.ts | 40 +- .../magic-transit/redundancy-groups/update.ts | 89 +- .../magic-transit/routes/bulk-update.ts | 62 +- .../_generated/magic-transit/routes/create.ts | 125 +- .../_generated/magic-transit/routes/delete.ts | 51 +- .../_generated/magic-transit/routes/empty.ts | 66 +- .../_generated/magic-transit/routes/get.ts | 45 +- .../_generated/magic-transit/routes/index.ts | 27 +- .../_generated/magic-transit/routes/list.ts | 37 +- .../_generated/magic-transit/routes/update.ts | 130 +- .../magic-transit/sites/acls/create.ts | 188 +-- .../magic-transit/sites/acls/delete.ts | 57 +- .../magic-transit/sites/acls/edit.ts | 202 +-- .../magic-transit/sites/acls/get.ts | 50 +- .../magic-transit/sites/acls/index.ts | 25 +- .../magic-transit/sites/acls/list.ts | 46 +- .../magic-transit/sites/acls/update.ts | 202 +-- .../sites/app-configuration/create.ts | 84 +- .../sites/app-configuration/delete.ts | 59 +- .../sites/app-configuration/index.ts | 21 +- .../sites/app-configuration/list.ts | 46 +- .../sites/app-configuration/update.ts | 112 +- .../_generated/magic-transit/sites/create.ts | 105 +- .../_generated/magic-transit/sites/delete.ts | 48 +- .../_generated/magic-transit/sites/edit.ts | 110 +- .../_generated/magic-transit/sites/get.ts | 54 +- .../_generated/magic-transit/sites/index.ts | 35 +- .../magic-transit/sites/lans/create.ts | 251 ++-- .../magic-transit/sites/lans/delete.ts | 57 +- .../magic-transit/sites/lans/edit.ts | 257 ++-- .../magic-transit/sites/lans/get.ts | 50 +- .../magic-transit/sites/lans/index.ts | 25 +- .../magic-transit/sites/lans/list.ts | 46 +- .../magic-transit/sites/lans/update.ts | 257 ++-- .../_generated/magic-transit/sites/list.ts | 47 +- .../sites/netflow-config/create.ts | 105 +- .../sites/netflow-config/delete.ts | 51 +- .../sites/netflow-config/edit.ts | 105 +- .../magic-transit/sites/netflow-config/get.ts | 45 +- .../sites/netflow-config/index.ts | 23 +- .../sites/netflow-config/update.ts | 105 +- .../_generated/magic-transit/sites/update.ts | 110 +- .../magic-transit/sites/wans/create.ts | 172 ++- .../magic-transit/sites/wans/delete.ts | 57 +- .../magic-transit/sites/wans/edit.ts | 175 ++- .../magic-transit/sites/wans/get.ts | 50 +- .../magic-transit/sites/wans/index.ts | 25 +- .../magic-transit/sites/wans/list.ts | 46 +- .../magic-transit/sites/wans/update.ts | 175 ++- .../_generated/managed-defense/index.ts | 15 +- .../vulnerability-discovery/index.ts | 19 +- .../vulnerability-discovery/reports/get.ts | 51 +- .../vulnerability-discovery/reports/index.ts | 13 +- .../repositories/create-token.ts | 45 +- .../repositories/create.ts | 79 +- .../repositories/get.ts | 59 +- .../repositories/index.ts | 21 +- .../repositories/list.ts | 44 +- .../vulnerability-discovery/scans/create.ts | 96 +- .../scans/get-report.ts | 45 +- .../vulnerability-discovery/scans/get.ts | 45 +- .../vulnerability-discovery/scans/index.ts | 21 +- .../vulnerability-discovery/scans/list.ts | 56 +- .../_generated/managed-transforms/delete.ts | 43 +- .../_generated/managed-transforms/index.ts | 19 +- .../_generated/managed-transforms/list.ts | 40 +- .../_generated/managed-transforms/update.ts | 72 +- .../cli/src/commands/_generated/mcp/index.ts | 17 +- .../portals/account-tool-call-analytics.ts | 83 +- .../commands/_generated/mcp/portals/create.ts | 129 +- .../commands/_generated/mcp/portals/delete.ts | 57 +- .../commands/_generated/mcp/portals/index.ts | 27 +- .../commands/_generated/mcp/portals/list.ts | 59 +- .../commands/_generated/mcp/portals/read.ts | 51 +- .../mcp/portals/tool-call-analytics.ts | 88 +- .../commands/_generated/mcp/portals/update.ts | 128 +- .../commands/_generated/mcp/servers/create.ts | 158 +- .../commands/_generated/mcp/servers/delete.ts | 57 +- .../commands/_generated/mcp/servers/index.ts | 27 +- .../commands/_generated/mcp/servers/list.ts | 56 +- .../commands/_generated/mcp/servers/read.ts | 51 +- .../commands/_generated/mcp/servers/sync.ts | 51 +- .../mcp/servers/tool-call-analytics.ts | 88 +- .../commands/_generated/mcp/servers/update.ts | 137 +- .../cli/src/commands/_generated/mesh/index.ts | 15 +- .../mesh/nodes/configurations/get.ts | 47 +- .../mesh/nodes/configurations/index.ts | 17 +- .../mesh/nodes/configurations/update.ts | 109 +- .../mesh/nodes/connections/index.ts | 13 +- .../_generated/mesh/nodes/connections/list.ts | 46 +- .../_generated/mesh/nodes/connectors/get.ts | 57 +- .../_generated/mesh/nodes/connectors/index.ts | 13 +- .../commands/_generated/mesh/nodes/create.ts | 64 +- .../commands/_generated/mesh/nodes/delete.ts | 53 +- .../commands/_generated/mesh/nodes/edit.ts | 76 +- .../_generated/mesh/nodes/failover.ts | 73 +- .../src/commands/_generated/mesh/nodes/get.ts | 44 +- .../commands/_generated/mesh/nodes/index.ts | 33 +- .../commands/_generated/mesh/nodes/list.ts | 133 +- .../_generated/mesh/nodes/token/get.ts | 47 +- .../_generated/mesh/nodes/token/index.ts | 13 +- .../monetization/account-eligibility/check.ts | 57 +- .../monetization/account-eligibility/get.ts | 40 +- .../monetization/account-eligibility/index.ts | 17 +- .../commands/_generated/monetization/index.ts | 17 +- .../monetization/rules/delete-all.ts | 46 +- .../_generated/monetization/rules/delete.ts | 57 +- .../_generated/monetization/rules/edit.ts | 113 +- .../_generated/monetization/rules/get.ts | 51 +- .../_generated/monetization/rules/index.ts | 25 +- .../_generated/monetization/rules/list.ts | 40 +- .../_generated/monetization/rules/update.ts | 62 +- .../network-interconnects/cnis/create.ts | 132 +- .../network-interconnects/cnis/delete.ts | 57 +- .../network-interconnects/cnis/get.ts | 51 +- .../network-interconnects/cnis/index.ts | 23 +- .../network-interconnects/cnis/list.ts | 67 +- .../network-interconnects/cnis/update.ts | 178 ++- .../_generated/network-interconnects/index.ts | 21 +- .../interconnects/create.ts | 117 +- .../interconnects/delete.ts | 57 +- .../interconnects/get.ts | 51 +- .../interconnects/index.ts | 27 +- .../interconnects/list.ts | 67 +- .../interconnects/loa-default-name.ts | 51 +- .../interconnects/loa.ts | 63 +- .../interconnects/status.ts | 51 +- .../network-interconnects/settings/get.ts | 40 +- .../network-interconnects/settings/index.ts | 17 +- .../network-interconnects/settings/update.ts | 60 +- .../network-interconnects/slots/get.ts | 45 +- .../network-interconnects/slots/index.ts | 17 +- .../network-interconnects/slots/list.ts | 81 +- .../src/commands/_generated/network/index.ts | 19 +- .../_generated/network/routes/cidr/create.ts | 81 +- .../_generated/network/routes/cidr/delete.ts | 53 +- .../_generated/network/routes/cidr/edit.ts | 89 +- .../_generated/network/routes/cidr/get.ts | 47 +- .../_generated/network/routes/cidr/index.ts | 23 +- .../_generated/network/routes/cidr/list.ts | 147 +- .../network/routes/hostname/create.ts | 75 +- .../network/routes/hostname/delete.ts | 57 +- .../network/routes/hostname/edit.ts | 88 +- .../_generated/network/routes/hostname/get.ts | 51 +- .../network/routes/hostname/index.ts | 23 +- .../network/routes/hostname/list.ts | 114 +- .../_generated/network/routes/index.ts | 19 +- .../_generated/network/routes/resolve.ts | 62 +- .../network/subnets/cloudflare-source/edit.ts | 93 +- .../network/subnets/cloudflare-source/get.ts | 51 +- .../subnets/cloudflare-source/index.ts | 17 +- .../_generated/network/subnets/index.ts | 21 +- .../subnets/initial-resolved-ip/get.ts | 51 +- .../subnets/initial-resolved-ip/index.ts | 17 +- .../subnets/initial-resolved-ip/replace.ts | 93 +- .../_generated/network/subnets/list.ts | 149 +- .../_generated/network/subnets/warp/create.ts | 85 +- .../_generated/network/subnets/warp/delete.ts | 57 +- .../_generated/network/subnets/warp/edit.ts | 88 +- .../_generated/network/subnets/warp/get.ts | 51 +- .../_generated/network/subnets/warp/index.ts | 21 +- .../network/virtual-networks/create.ts | 86 +- .../network/virtual-networks/delete.ts | 57 +- .../network/virtual-networks/edit.ts | 87 +- .../network/virtual-networks/get.ts | 51 +- .../network/virtual-networks/index.ts | 23 +- .../network/virtual-networks/list.ts | 106 +- .../commands/_generated/o11y/agents/index.ts | 15 +- .../_generated/o11y/agents/traces/events.ts | 94 +- .../_generated/o11y/agents/traces/get.ts | 74 +- .../_generated/o11y/agents/traces/index.ts | 19 +- .../_generated/o11y/agents/traces/list.ts | 102 +- .../_generated/o11y/destinations/create.ts | 116 +- .../_generated/o11y/destinations/delete.ts | 51 +- .../_generated/o11y/destinations/index.ts | 21 +- .../_generated/o11y/destinations/list.ts | 67 +- .../_generated/o11y/destinations/update.ts | 103 +- .../cli/src/commands/_generated/o11y/index.ts | 31 +- .../commands/_generated/o11y/issues/add.ts | 67 +- .../o11y/issues/automations/create.ts | 89 +- .../o11y/issues/automations/delete.ts | 53 +- .../_generated/o11y/issues/automations/get.ts | 47 +- .../o11y/issues/automations/index.ts | 23 +- .../o11y/issues/automations/list.ts | 47 +- .../o11y/issues/automations/update.ts | 96 +- .../commands/_generated/o11y/issues/get.ts | 42 +- .../commands/_generated/o11y/issues/group.ts | 69 +- .../commands/_generated/o11y/issues/index.ts | 35 +- .../commands/_generated/o11y/issues/list.ts | 88 +- .../commands/_generated/o11y/issues/notify.ts | 62 +- .../_generated/o11y/issues/occurrences.ts | 68 +- .../commands/_generated/o11y/issues/remove.ts | 57 +- .../_generated/o11y/issues/summary.ts | 47 +- .../_generated/o11y/issues/ungroup.ts | 51 +- .../commands/_generated/o11y/issues/update.ts | 72 +- .../_generated/o11y/metrics-export/index.ts | 17 +- .../_generated/o11y/metrics-export/list.ts | 40 +- .../_generated/o11y/metrics-export/upsert.ts | 83 +- .../_generated/o11y/queries/create.ts | 187 ++- .../_generated/o11y/queries/delete.ts | 48 +- .../commands/_generated/o11y/queries/edit.ts | 192 +-- .../commands/_generated/o11y/queries/get.ts | 42 +- .../commands/_generated/o11y/queries/index.ts | 23 +- .../commands/_generated/o11y/queries/list.ts | 64 +- .../_generated/o11y/shared-queries/create.ts | 332 +++-- .../_generated/o11y/shared-queries/get.ts | 60 +- .../_generated/o11y/shared-queries/index.ts | 17 +- .../_generated/o11y/telemetry/index.ts | 19 +- .../_generated/o11y/telemetry/keys.ts | 130 +- .../_generated/o11y/telemetry/query.ts | 329 ++-- .../_generated/o11y/telemetry/values.ts | 137 +- .../commands/_generated/o11y/tracing/index.ts | 17 +- .../_generated/o11y/tracing/rules/delete.ts | 46 +- .../_generated/o11y/tracing/rules/get.ts | 40 +- .../_generated/o11y/tracing/rules/index.ts | 19 +- .../_generated/o11y/tracing/rules/update.ts | 62 +- .../o11y/tracing/settings/delete.ts | 46 +- .../_generated/o11y/tracing/settings/get.ts | 40 +- .../_generated/o11y/tracing/settings/index.ts | 19 +- .../o11y/tracing/settings/update.ts | 112 +- .../cli/src/commands/_generated/o11y/usage.ts | 72 +- .../_generated/observability/index.ts | 19 +- .../observability/usage-limit/get.ts | 40 +- .../observability/usage-limit/index.ts | 13 +- .../ohttp-gateway/enablement/create.ts | 40 +- .../ohttp-gateway/enablement/delete.ts | 46 +- .../ohttp-gateway/enablement/get.ts | 40 +- .../ohttp-gateway/enablement/index.ts | 19 +- .../_generated/ohttp-gateway/index.ts | 15 +- .../organizations/accounts/index.ts | 13 +- .../_generated/organizations/accounts/list.ts | 210 +-- .../_generated/organizations/billing/index.ts | 15 +- .../organizations/billing/usage/get.ts | 73 +- .../organizations/billing/usage/index.ts | 13 +- .../_generated/organizations/create.ts | 117 +- .../_generated/organizations/delete.ts | 57 +- .../commands/_generated/organizations/get.ts | 51 +- .../_generated/organizations/index.ts | 37 +- .../_generated/organizations/invites/index.ts | 15 +- .../organizations/invites/update.ts | 83 +- .../commands/_generated/organizations/list.ts | 182 ++- .../organizations/logs/audit/get.ts | 573 +++---- .../organizations/logs/audit/history.ts | 122 +- .../organizations/logs/audit/index.ts | 17 +- .../_generated/organizations/logs/index.ts | 15 +- .../organizations/members/batch/create.ts | 69 +- .../organizations/members/batch/index.ts | 15 +- .../organizations/members/create.ts | 67 +- .../organizations/members/delete.ts | 67 +- .../_generated/organizations/members/get.ts | 61 +- .../_generated/organizations/members/index.ts | 23 +- .../_generated/organizations/members/list.ts | 128 +- .../_generated/organizations/profile/get.ts | 51 +- .../_generated/organizations/profile/index.ts | 17 +- .../organizations/profile/update.ts | 109 +- .../_generated/organizations/shares/index.ts | 13 +- .../_generated/organizations/shares/list.ts | 98 +- .../_generated/organizations/update.ts | 83 +- .../commands/_generated/page-rules/create.ts | 89 +- .../commands/_generated/page-rules/delete.ts | 52 +- .../commands/_generated/page-rules/edit.ts | 97 +- .../src/commands/_generated/page-rules/get.ts | 47 +- .../commands/_generated/page-rules/index.ts | 25 +- .../commands/_generated/page-rules/list.ts | 79 +- .../commands/_generated/page-rules/update.ts | 97 +- .../_generated/pages/build-cache/index.ts | 15 +- .../_generated/pages/build-cache/purge.ts | 59 +- .../src/commands/_generated/pages/create.ts | 762 ++++++---- .../src/commands/_generated/pages/delete.ts | 59 +- .../_generated/pages/deployments/create.ts | 199 +-- .../_generated/pages/deployments/delete.ts | 78 +- .../_generated/pages/deployments/get.ts | 65 +- .../pages/deployments/history/index.ts | 13 +- .../pages/deployments/history/logs/get.ts | 65 +- .../pages/deployments/history/logs/index.ts | 13 +- .../_generated/pages/deployments/index.ts | 27 +- .../_generated/pages/deployments/list.ts | 79 +- .../_generated/pages/deployments/retry.ts | 65 +- .../_generated/pages/deployments/rollback.ts | 69 +- .../_generated/pages/domains/create.ts | 75 +- .../_generated/pages/domains/delete.ts | 69 +- .../commands/_generated/pages/domains/get.ts | 65 +- .../_generated/pages/domains/index.ts | 23 +- .../commands/_generated/pages/domains/list.ts | 72 +- .../pages/domains/validation/index.ts | 15 +- .../pages/domains/validation/retry.ts | 65 +- .../cli/src/commands/_generated/pages/edit.ts | 775 ++++++---- .../cli/src/commands/_generated/pages/get.ts | 53 +- .../src/commands/_generated/pages/index.ts | 35 +- .../cli/src/commands/_generated/pages/list.ts | 57 +- .../_generated/pages/source/connect.ts | 221 +-- .../_generated/pages/source/disconnect.ts | 59 +- .../commands/_generated/pages/source/index.ts | 17 +- .../_generated/pay-per-crawl/config/create.ts | 71 +- .../_generated/pay-per-crawl/config/edit.ts | 70 +- .../_generated/pay-per-crawl/config/get.ts | 40 +- .../_generated/pay-per-crawl/config/index.ts | 19 +- .../_generated/pay-per-crawl/crawler/index.ts | 15 +- .../pay-per-crawl/crawler/stripe/create.ts | 40 +- .../pay-per-crawl/crawler/stripe/delete.ts | 46 +- .../pay-per-crawl/crawler/stripe/get.ts | 40 +- .../pay-per-crawl/crawler/stripe/index.ts | 19 +- .../pay-per-crawl/crawlers/index.ts | 13 +- .../_generated/pay-per-crawl/crawlers/list.ts | 40 +- .../_generated/pay-per-crawl/index.ts | 25 +- .../pay-per-crawl/publisher/index.ts | 15 +- .../pay-per-crawl/publisher/stripe/create.ts | 40 +- .../pay-per-crawl/publisher/stripe/delete.ts | 46 +- .../pay-per-crawl/publisher/stripe/get.ts | 40 +- .../pay-per-crawl/publisher/stripe/index.ts | 19 +- .../pay-per-crawl/terms/get-signature-link.ts | 40 +- .../pay-per-crawl/terms/get-signature.ts | 45 +- .../_generated/pay-per-crawl/terms/get.ts | 40 +- .../_generated/pay-per-crawl/terms/index.ts | 21 +- .../terms/send-signature-event.ts | 57 +- .../pay-per-crawl/zones/get-can-be-enabled.ts | 40 +- .../_generated/pay-per-crawl/zones/index.ts | 19 +- .../zones/query-can-be-enabled.ts | 62 +- .../pay-per-crawl/zones/set-can-be-enabled.ts | 62 +- .../pay-per-use/agreements/create.ts | 72 +- .../pay-per-use/agreements/index.ts | 17 +- .../_generated/pay-per-use/agreements/list.ts | 54 +- .../pay-per-use/enabled-domains/index.ts | 13 +- .../pay-per-use/enabled-domains/list.ts | 62 +- .../pay-per-use/enabled-publishers/index.ts | 13 +- .../pay-per-use/enabled-publishers/list.ts | 62 +- .../commands/_generated/pay-per-use/index.ts | 31 +- .../pay-per-use/operator/get-configuration.ts | 40 +- .../_generated/pay-per-use/operator/index.ts | 19 +- .../pay-per-use/operator/set-configuration.ts | 67 +- .../operator/update-configuration.ts | 67 +- .../_generated/pay-per-use/pricing/index.ts | 19 +- .../pay-per-use/pricing/list-operators.ts | 54 +- .../pricing/opt-out-operator-price.ts | 57 +- .../pay-per-use/pricing/set-operator-price.ts | 81 +- .../pay-per-use/proposals/decide.ts | 70 +- .../_generated/pay-per-use/proposals/index.ts | 17 +- .../_generated/pay-per-use/proposals/list.ts | 54 +- .../pay-per-use/usage-reports/index.ts | 15 +- .../pay-per-use/usage-reports/submit.ts | 60 +- .../pay-per-use/usage-stats/get-account.ts | 76 +- .../pay-per-use/usage-stats/index.ts | 15 +- .../pay-per-use/zones/get-can-be-enabled.ts | 40 +- .../pay-per-use/zones/get-configuration.ts | 40 +- .../_generated/pay-per-use/zones/index.ts | 21 +- .../pay-per-use/zones/set-can-be-enabled.ts | 62 +- .../pay-per-use/zones/update-configuration.ts | 48 +- .../commands/_generated/pipelines/create.ts | 67 +- .../commands/_generated/pipelines/delete.ts | 54 +- .../src/commands/_generated/pipelines/get.ts | 48 +- .../commands/_generated/pipelines/index.ts | 39 +- .../_generated/pipelines/legacy-create.ts | 217 +-- .../_generated/pipelines/legacy-delete.ts | 57 +- .../_generated/pipelines/legacy-get.ts | 51 +- .../_generated/pipelines/legacy-list.ts | 70 +- .../_generated/pipelines/legacy-update.ts | 228 +-- .../src/commands/_generated/pipelines/list.ts | 56 +- .../_generated/pipelines/sinks/create.ts | 432 +++--- .../_generated/pipelines/sinks/delete.ts | 54 +- .../_generated/pipelines/sinks/get.ts | 48 +- .../_generated/pipelines/sinks/index.ts | 23 +- .../_generated/pipelines/sinks/list.ts | 81 +- .../_generated/pipelines/sinks/update.ts | 61 +- .../_generated/pipelines/streams/create.ts | 220 +-- .../_generated/pipelines/streams/delete.ts | 56 +- .../_generated/pipelines/streams/get.ts | 48 +- .../_generated/pipelines/streams/index.ts | 23 +- .../_generated/pipelines/streams/list.ts | 84 +- .../_generated/pipelines/streams/update.ts | 100 +- .../_generated/pipelines/update-tables.ts | 51 +- .../_generated/pipelines/validate-sql.ts | 60 +- .../src/commands/_generated/precursor/get.ts | 50 +- .../commands/_generated/precursor/index.ts | 17 +- .../commands/_generated/precursor/update.ts | 92 +- .../commands/_generated/previews/delete.ts | 75 +- .../src/commands/_generated/previews/index.ts | 19 +- .../_generated/queues/consumers/create.ts | 162 +- .../_generated/queues/consumers/delete.ts | 67 +- .../_generated/queues/consumers/get.ts | 61 +- .../_generated/queues/consumers/index.ts | 23 +- .../_generated/queues/consumers/list.ts | 50 +- .../_generated/queues/consumers/update.ts | 176 ++- .../src/commands/_generated/queues/create.ts | 70 +- .../src/commands/_generated/queues/delete.ts | 50 +- .../src/commands/_generated/queues/edit.ts | 110 +- .../cli/src/commands/_generated/queues/get.ts | 46 +- .../src/commands/_generated/queues/index.ts | 33 +- .../src/commands/_generated/queues/list.ts | 59 +- .../_generated/queues/messages/ack.ts | 79 +- .../_generated/queues/messages/bulk-push.ts | 82 +- .../queues/messages/extend-leases.ts | 79 +- .../_generated/queues/messages/index.ts | 27 +- .../_generated/queues/messages/peek.ts | 67 +- .../_generated/queues/messages/pull.ts | 79 +- .../_generated/queues/messages/purge.ts | 73 +- .../_generated/queues/messages/push.ts | 66 +- .../commands/_generated/queues/metrics/get.ts | 47 +- .../_generated/queues/metrics/index.ts | 13 +- .../commands/_generated/queues/purge/index.ts | 17 +- .../commands/_generated/queues/purge/start.ts | 72 +- .../_generated/queues/purge/status.ts | 47 +- .../_generated/queues/subscriptions/create.ts | 159 +- .../_generated/queues/subscriptions/delete.ts | 57 +- .../_generated/queues/subscriptions/edit.ts | 116 +- .../_generated/queues/subscriptions/get.ts | 51 +- .../_generated/queues/subscriptions/index.ts | 23 +- .../_generated/queues/subscriptions/list.ts | 88 +- .../_generated/r2/buckets/cors/delete.ts | 63 +- .../_generated/r2/buckets/cors/get.ts | 59 +- .../_generated/r2/buckets/cors/index.ts | 19 +- .../_generated/r2/buckets/cors/update.ts | 83 +- .../commands/_generated/r2/buckets/create.ts | 96 +- .../commands/_generated/r2/buckets/delete.ts | 63 +- .../r2/buckets/domains/custom/create.ts | 118 +- .../r2/buckets/domains/custom/delete.ts | 77 +- .../r2/buckets/domains/custom/get.ts | 73 +- .../r2/buckets/domains/custom/index.ts | 23 +- .../r2/buckets/domains/custom/list.ts | 62 +- .../r2/buckets/domains/custom/update.ts | 112 +- .../_generated/r2/buckets/domains/index.ts | 17 +- .../r2/buckets/domains/managed/get.ts | 59 +- .../r2/buckets/domains/managed/index.ts | 17 +- .../r2/buckets/domains/managed/update.ts | 83 +- .../commands/_generated/r2/buckets/edit.ts | 69 +- .../r2/buckets/event-notifications/delete.ts | 101 +- .../r2/buckets/event-notifications/get.ts | 75 +- .../r2/buckets/event-notifications/index.ts | 21 +- .../r2/buckets/event-notifications/list.ts | 62 +- .../r2/buckets/event-notifications/update.ts | 95 +- .../src/commands/_generated/r2/buckets/get.ts | 59 +- .../commands/_generated/r2/buckets/index.ts | 41 +- .../_generated/r2/buckets/jobs/create.ts | 146 +- .../_generated/r2/buckets/jobs/get.ts | 73 +- .../_generated/r2/buckets/jobs/index.ts | 19 +- .../_generated/r2/buckets/jobs/list.ts | 100 +- .../_generated/r2/buckets/lifecycle/get.ts | 59 +- .../_generated/r2/buckets/lifecycle/index.ts | 17 +- .../_generated/r2/buckets/lifecycle/update.ts | 83 +- .../commands/_generated/r2/buckets/list.ts | 110 +- .../r2/buckets/local-uploads/get.ts | 47 +- .../r2/buckets/local-uploads/index.ts | 17 +- .../r2/buckets/local-uploads/update.ts | 62 +- .../_generated/r2/buckets/locks/delete.ts | 63 +- .../_generated/r2/buckets/locks/get.ts | 59 +- .../_generated/r2/buckets/locks/index.ts | 19 +- .../_generated/r2/buckets/locks/update.ts | 83 +- .../_generated/r2/buckets/metrics/index.ts | 13 +- .../_generated/r2/buckets/metrics/list.ts | 40 +- .../_generated/r2/buckets/sippy/disable.ts | 63 +- .../_generated/r2/buckets/sippy/enable.ts | 225 +-- .../_generated/r2/buckets/sippy/get.ts | 59 +- .../_generated/r2/buckets/sippy/index.ts | 19 +- .../cli/src/commands/_generated/r2/index.ts | 21 +- .../_generated/r2/objects/bulk-delete.ts | 98 +- .../commands/_generated/r2/objects/delete.ts | 79 +- .../src/commands/_generated/r2/objects/get.ts | 99 +- .../commands/_generated/r2/objects/index.ts | 23 +- .../commands/_generated/r2/objects/list.ts | 112 +- .../src/commands/_generated/r2/objects/put.ts | 126 +- .../connectivity-precheck/index.ts | 17 +- .../connectivity-precheck/source.ts | 211 +-- .../connectivity-precheck/target.ts | 102 +- .../_generated/r2/super-slurper/index.ts | 17 +- .../r2/super-slurper/jobs/abort-all.ts | 46 +- .../_generated/r2/super-slurper/jobs/abort.ts | 51 +- .../r2/super-slurper/jobs/create.ts | 453 +++--- .../r2/super-slurper/jobs/delete.ts | 51 +- .../_generated/r2/super-slurper/jobs/get.ts | 45 +- .../_generated/r2/super-slurper/jobs/index.ts | 33 +- .../_generated/r2/super-slurper/jobs/list.ts | 44 +- .../r2/super-slurper/jobs/logs/index.ts | 13 +- .../r2/super-slurper/jobs/logs/list.ts | 50 +- .../_generated/r2/super-slurper/jobs/pause.ts | 45 +- .../r2/super-slurper/jobs/progress.ts | 45 +- .../r2/super-slurper/jobs/resume.ts | 45 +- .../r2/temporary-credentials/create.ts | 126 +- .../r2/temporary-credentials/index.ts | 15 +- .../_generated/radar/agent-readiness/index.ts | 15 +- .../radar/agent-readiness/summary.ts | 94 +- .../_generated/radar/ai/bots/index.ts | 19 +- .../_generated/radar/ai/bots/summary.ts | 246 +-- .../radar/ai/bots/timeseries-groups.ts | 270 ++-- .../_generated/radar/ai/bots/timeseries.ts | 246 +-- .../src/commands/_generated/radar/ai/index.ts | 19 +- .../_generated/radar/ai/inference/index.ts | 17 +- .../_generated/radar/ai/inference/summary.ts | 154 +- .../radar/ai/inference/timeseries-groups.ts | 178 ++- .../radar/ai/markdown-for-agents/index.ts | 17 +- .../radar/ai/markdown-for-agents/summary.ts | 97 +- .../ai/markdown-for-agents/timeseries.ts | 108 +- .../_generated/radar/annotations/get.ts | 52 +- .../_generated/radar/annotations/index.ts | 19 +- .../_generated/radar/annotations/list.ts | 244 +-- .../radar/annotations/outages/index.ts | 17 +- .../radar/annotations/outages/list.ts | 236 +-- .../radar/annotations/outages/locations.ts | 89 +- .../commands/_generated/radar/as112/index.ts | 21 +- .../_generated/radar/as112/summary.ts | 190 +-- .../radar/as112/timeseries-groups.ts | 201 +-- .../_generated/radar/as112/timeseries.ts | 180 +-- .../_generated/radar/as112/top/index.ts | 15 +- .../radar/as112/top/locations/dnssec/get.ts | 142 +- .../radar/as112/top/locations/dnssec/index.ts | 13 +- .../radar/as112/top/locations/edns/get.ts | 142 +- .../radar/as112/top/locations/edns/index.ts | 13 +- .../radar/as112/top/locations/get.ts | 131 +- .../radar/as112/top/locations/index.ts | 21 +- .../as112/top/locations/ip-version/get.ts | 138 +- .../as112/top/locations/ip-version/index.ts | 13 +- .../_generated/radar/attacks/index.ts | 17 +- .../_generated/radar/attacks/layer3/index.ts | 21 +- .../radar/attacks/layer3/summary.ts | 185 +-- .../radar/attacks/layer3/timeseries-groups.ts | 207 +-- .../radar/attacks/layer3/timeseries.ts | 209 +-- .../radar/attacks/layer3/top/attacks.ts | 206 +-- .../radar/attacks/layer3/top/index.ts | 17 +- .../attacks/layer3/top/locations/index.ts | 17 +- .../attacks/layer3/top/locations/origin.ts | 163 +- .../attacks/layer3/top/locations/target.ts | 163 +- .../_generated/radar/attacks/layer7/index.ts | 21 +- .../radar/attacks/layer7/summary.ts | 234 +-- .../radar/attacks/layer7/timeseries-groups.ts | 256 ++-- .../radar/attacks/layer7/timeseries.ts | 235 +-- .../radar/attacks/layer7/top/ases/index.ts | 15 +- .../radar/attacks/layer7/top/ases/origin.ts | 211 +-- .../radar/attacks/layer7/top/attacks.ts | 191 +-- .../radar/attacks/layer7/top/index.ts | 19 +- .../attacks/layer7/top/locations/index.ts | 17 +- .../attacks/layer7/top/locations/origin.ts | 211 +-- .../attacks/layer7/top/locations/target.ts | 135 +- .../radar/bgp/hijacks/events/index.ts | 13 +- .../radar/bgp/hijacks/events/list.ts | 192 +-- .../_generated/radar/bgp/hijacks/index.ts | 15 +- .../commands/_generated/radar/bgp/index.ts | 27 +- .../_generated/radar/bgp/ips/index.ts | 17 +- .../_generated/radar/bgp/ips/timeseries.ts | 146 +- .../_generated/radar/bgp/ips/top/ases.ts | 90 +- .../_generated/radar/bgp/ips/top/index.ts | 13 +- .../radar/bgp/leaks/events/index.ts | 13 +- .../_generated/radar/bgp/leaks/events/list.ts | 161 +- .../_generated/radar/bgp/leaks/index.ts | 15 +- .../_generated/radar/bgp/routes/ases.ts | 92 +- .../_generated/radar/bgp/routes/index.ts | 27 +- .../_generated/radar/bgp/routes/moas.ts | 68 +- .../radar/bgp/routes/paths/index.ts | 13 +- .../_generated/radar/bgp/routes/paths/list.ts | 80 +- .../_generated/radar/bgp/routes/pfx2as.ts | 81 +- .../_generated/radar/bgp/routes/realtime.ts | 49 +- .../_generated/radar/bgp/routes/stats.ts | 69 +- .../radar/bgp/routes/upstreams/index.ts | 15 +- .../radar/bgp/routes/upstreams/timeseries.ts | 101 +- .../_generated/radar/bgp/rpki/aspa/changes.ts | 89 +- .../_generated/radar/bgp/rpki/aspa/index.ts | 19 +- .../radar/bgp/rpki/aspa/snapshot.ts | 89 +- .../radar/bgp/rpki/aspa/timeseries.ts | 109 +- .../_generated/radar/bgp/rpki/index.ts | 17 +- .../_generated/radar/bgp/rpki/roas/index.ts | 15 +- .../radar/bgp/rpki/roas/timeseries.ts | 116 +- .../_generated/radar/bgp/timeseries.ts | 148 +- .../_generated/radar/bgp/top/ases/get.ts | 147 +- .../_generated/radar/bgp/top/ases/index.ts | 17 +- .../_generated/radar/bgp/top/ases/prefixes.ts | 64 +- .../_generated/radar/bgp/top/index.ts | 17 +- .../_generated/radar/bgp/top/prefixes.ts | 135 +- .../_generated/radar/bots/crawlers/index.ts | 17 +- .../_generated/radar/bots/crawlers/summary.ts | 198 +-- .../radar/bots/crawlers/timeseries-groups.ts | 220 +-- .../src/commands/_generated/radar/bots/get.ts | 52 +- .../commands/_generated/radar/bots/index.ts | 25 +- .../commands/_generated/radar/bots/list.ts | 109 +- .../commands/_generated/radar/bots/summary.ts | 226 +-- .../radar/bots/timeseries-groups.ts | 237 +-- .../_generated/radar/bots/timeseries.ts | 216 +-- .../_generated/radar/ct/authorities/get.ts | 58 +- .../_generated/radar/ct/authorities/index.ts | 17 +- .../_generated/radar/ct/authorities/list.ts | 69 +- .../src/commands/_generated/radar/ct/index.ts | 23 +- .../commands/_generated/radar/ct/logs/get.ts | 54 +- .../_generated/radar/ct/logs/index.ts | 17 +- .../commands/_generated/radar/ct/logs/list.ts | 66 +- .../commands/_generated/radar/ct/summary.ts | 343 +++-- .../_generated/radar/ct/timeseries-groups.ts | 354 ++--- .../_generated/radar/ct/timeseries.ts | 317 ++-- .../_generated/radar/datasets/download.ts | 67 +- .../commands/_generated/radar/datasets/get.ts | 47 +- .../_generated/radar/datasets/index.ts | 19 +- .../_generated/radar/datasets/list.ts | 87 +- .../commands/_generated/radar/dns/index.ts | 21 +- .../commands/_generated/radar/dns/summary.ts | 344 +++-- .../_generated/radar/dns/timeseries-groups.ts | 366 ++--- .../_generated/radar/dns/timeseries.ts | 332 +++-- .../commands/_generated/radar/dns/top/ases.ts | 331 ++-- .../_generated/radar/dns/top/index.ts | 17 +- .../_generated/radar/dns/top/locations.ts | 343 +++-- .../commands/_generated/radar/email/index.ts | 17 +- .../_generated/radar/email/routing/index.ts | 17 +- .../_generated/radar/email/routing/summary.ts | 214 +-- .../radar/email/routing/timeseries-groups.ts | 225 +-- .../_generated/radar/email/security/index.ts | 19 +- .../radar/email/security/summary.ts | 198 +-- .../radar/email/security/timeseries-groups.ts | 209 +-- .../radar/email/security/top/index.ts | 13 +- .../radar/email/security/top/tlds/get.ts | 198 +-- .../radar/email/security/top/tlds/index.ts | 21 +- .../email/security/top/tlds/malicious/get.ts | 209 +-- .../security/top/tlds/malicious/index.ts | 13 +- .../radar/email/security/top/tlds/spam/get.ts | 205 +-- .../email/security/top/tlds/spam/index.ts | 13 +- .../email/security/top/tlds/spoof/get.ts | 205 +-- .../email/security/top/tlds/spoof/index.ts | 13 +- .../_generated/radar/entities/asns/as-set.ts | 58 +- .../radar/entities/asns/botnet-threat-feed.ts | 134 +- .../_generated/radar/entities/asns/get.ts | 69 +- .../_generated/radar/entities/asns/index.ts | 25 +- .../_generated/radar/entities/asns/ip.ts | 53 +- .../_generated/radar/entities/asns/list.ts | 101 +- .../_generated/radar/entities/asns/rel.ts | 72 +- .../_generated/radar/entities/index.ts | 19 +- .../_generated/radar/entities/ips/get.ts | 50 +- .../_generated/radar/entities/ips/index.ts | 13 +- .../radar/entities/locations/get.ts | 54 +- .../radar/entities/locations/index.ts | 17 +- .../radar/entities/locations/list.ts | 107 +- .../_generated/radar/geolocations/get.ts | 60 +- .../_generated/radar/geolocations/index.ts | 17 +- .../_generated/radar/geolocations/list.ts | 89 +- .../commands/_generated/radar/http/index.ts | 21 +- .../commands/_generated/radar/http/summary.ts | 327 ++-- .../radar/http/timeseries-groups.ts | 349 ++--- .../_generated/radar/http/timeseries.ts | 340 +++-- .../radar/http/top/ases/bot-class/get.ts | 296 ++-- .../radar/http/top/ases/bot-class/index.ts | 13 +- .../radar/http/top/ases/browser-family/get.ts | 290 ++-- .../http/top/ases/browser-family/index.ts | 13 +- .../radar/http/top/ases/device-type/get.ts | 290 ++-- .../radar/http/top/ases/device-type/index.ts | 13 +- .../_generated/radar/http/top/ases/get.ts | 299 ++-- .../radar/http/top/ases/http-protocol/get.ts | 294 ++-- .../http/top/ases/http-protocol/index.ts | 13 +- .../radar/http/top/ases/http-version/get.ts | 290 ++-- .../radar/http/top/ases/http-version/index.ts | 13 +- .../_generated/radar/http/top/ases/index.ts | 31 +- .../radar/http/top/ases/ip-version/get.ts | 290 ++-- .../radar/http/top/ases/ip-version/index.ts | 13 +- .../_generated/radar/http/top/ases/os/get.ts | 288 ++-- .../radar/http/top/ases/os/index.ts | 13 +- .../radar/http/top/ases/tls-version/get.ts | 290 ++-- .../radar/http/top/ases/tls-version/index.ts | 13 +- .../_generated/radar/http/top/index.ts | 17 +- .../radar/http/top/locations/bot-class/get.ts | 296 ++-- .../http/top/locations/bot-class/index.ts | 13 +- .../http/top/locations/browser-family/get.ts | 290 ++-- .../top/locations/browser-family/index.ts | 13 +- .../http/top/locations/device-type/get.ts | 290 ++-- .../http/top/locations/device-type/index.ts | 13 +- .../radar/http/top/locations/get.ts | 299 ++-- .../http/top/locations/http-protocol/get.ts | 294 ++-- .../http/top/locations/http-protocol/index.ts | 13 +- .../http/top/locations/http-version/get.ts | 290 ++-- .../http/top/locations/http-version/index.ts | 13 +- .../radar/http/top/locations/index.ts | 31 +- .../http/top/locations/ip-version/get.ts | 290 ++-- .../http/top/locations/ip-version/index.ts | 13 +- .../radar/http/top/locations/os/get.ts | 288 ++-- .../radar/http/top/locations/os/index.ts | 13 +- .../http/top/locations/tls-version/get.ts | 290 ++-- .../http/top/locations/tls-version/index.ts | 13 +- .../src/commands/_generated/radar/index.ts | 63 +- .../radar/leaked-credentials/index.ts | 17 +- .../radar/leaked-credentials/summary.ts | 186 +-- .../leaked-credentials/timeseries-groups.ts | 226 +-- .../_generated/radar/netflows/index.ts | 21 +- .../_generated/radar/netflows/summary.ts | 199 +-- .../radar/netflows/timeseries-groups.ts | 221 +-- .../_generated/radar/netflows/timeseries.ts | 199 +-- .../_generated/radar/netflows/top/ases.ts | 171 ++- .../_generated/radar/netflows/top/index.ts | 17 +- .../radar/netflows/top/locations.ts | 171 ++- .../commands/_generated/radar/origins/get.ts | 52 +- .../_generated/radar/origins/index.ts | 23 +- .../commands/_generated/radar/origins/list.ts | 69 +- .../_generated/radar/origins/summary.ts | 159 +- .../radar/origins/timeseries-groups.ts | 181 +-- .../_generated/radar/origins/timeseries.ts | 147 +- .../_generated/radar/post-quantum/index.ts | 17 +- .../radar/post-quantum/origin/index.ts | 17 +- .../radar/post-quantum/origin/summary.ts | 110 +- .../post-quantum/origin/timeseries-groups.ts | 110 +- .../radar/post-quantum/tls/index.ts | 15 +- .../radar/post-quantum/tls/support.ts | 52 +- .../_generated/radar/quality/index.ts | 17 +- .../_generated/radar/quality/iqi/index.ts | 17 +- .../_generated/radar/quality/iqi/summary.ts | 144 +- .../radar/quality/iqi/timeseries-groups.ts | 164 +- .../radar/quality/speed/histogram.ts | 130 +- .../_generated/radar/quality/speed/index.ts | 19 +- .../_generated/radar/quality/speed/summary.ts | 109 +- .../radar/quality/speed/top/ases.ts | 139 +- .../radar/quality/speed/top/index.ts | 17 +- .../radar/quality/speed/top/locations.ts | 139 +- .../_generated/radar/ranking/domain/get.ts | 106 +- .../_generated/radar/ranking/domain/index.ts | 13 +- .../_generated/radar/ranking/index.ts | 21 +- .../ranking/internet-services/categories.ts | 81 +- .../radar/ranking/internet-services/index.ts | 19 +- .../internet-services/timeseries-groups.ts | 119 +- .../radar/ranking/internet-services/top.ts | 93 +- .../radar/ranking/timeseries-groups.ts | 154 +- .../commands/_generated/radar/ranking/top.ts | 118 +- .../_generated/radar/robots-txt/index.ts | 13 +- .../radar/robots-txt/top/domain-categories.ts | 92 +- .../_generated/radar/robots-txt/top/index.ts | 17 +- .../robots-txt/top/user-agents/directive.ts | 115 +- .../radar/robots-txt/top/user-agents/index.ts | 15 +- .../_generated/radar/search/global.ts | 111 +- .../commands/_generated/radar/search/index.ts | 15 +- .../radar/tcp-resets-timeouts/index.ts | 17 +- .../radar/tcp-resets-timeouts/summary.ts | 133 +- .../tcp-resets-timeouts/timeseries-groups.ts | 144 +- .../src/commands/_generated/radar/tlds/get.ts | 51 +- .../commands/_generated/radar/tlds/index.ts | 19 +- .../commands/_generated/radar/tlds/list.ts | 97 +- .../radar/tlds/performance/index.ts | 17 +- .../radar/tlds/performance/summary.ts | 164 +- .../tlds/performance/timeseries-groups.ts | 175 ++- .../_generated/radar/traffic-anomalies/get.ts | 54 +- .../radar/traffic-anomalies/index.ts | 19 +- .../radar/traffic-anomalies/list.ts | 168 ++- .../radar/traffic-anomalies/locations/get.ts | 100 +- .../traffic-anomalies/locations/index.ts | 13 +- .../src/commands/_generated/realtime/index.ts | 21 +- .../realtime/kit/analytics/index.ts | 17 +- .../kit/analytics/livestreams/daily/get.ts | 79 +- .../kit/analytics/livestreams/daily/index.ts | 13 +- .../realtime/kit/analytics/livestreams/get.ts | 79 +- .../kit/analytics/livestreams/index.ts | 17 +- .../realtime/kit/analytics/usage/get.ts | 67 +- .../realtime/kit/analytics/usage/index.ts | 13 +- .../_generated/realtime/kit/apps/create.ts | 54 +- .../_generated/realtime/kit/apps/edit.ts | 67 +- .../_generated/realtime/kit/apps/get.ts | 47 +- .../_generated/realtime/kit/apps/index.ts | 21 +- .../_generated/realtime/kit/apps/list.ts | 76 +- .../commands/_generated/realtime/kit/index.ts | 29 +- .../realtime/kit/livestreams/get.ts | 79 +- .../realtime/kit/livestreams/index.ts | 23 +- .../realtime/kit/livestreams/list.ts | 119 +- .../realtime/kit/livestreams/sessions/get.ts | 61 +- .../kit/livestreams/sessions/index.ts | 17 +- .../kit/livestreams/sessions/list-active.ts | 57 +- .../realtime/kit/livestreams/start.ts | 94 +- .../realtime/kit/livestreams/stop.ts | 63 +- .../realtime/kit/meetings/active/get.ts | 57 +- .../realtime/kit/meetings/active/index.ts | 25 +- .../realtime/kit/meetings/active/kick-all.ts | 63 +- .../realtime/kit/meetings/active/kick.ts | 82 +- .../realtime/kit/meetings/active/mute-all.ts | 74 +- .../realtime/kit/meetings/active/mute.ts | 81 +- .../kit/meetings/active/polls/create.ts | 100 +- .../kit/meetings/active/polls/index.ts | 15 +- .../realtime/kit/meetings/create.ts | 372 ++--- .../_generated/realtime/kit/meetings/edit.ts | 405 ++--- .../_generated/realtime/kit/meetings/get.ts | 65 +- .../_generated/realtime/kit/meetings/index.ts | 29 +- .../_generated/realtime/kit/meetings/list.ts | 109 +- .../realtime/kit/meetings/livestream/get.ts | 79 +- .../realtime/kit/meetings/livestream/index.ts | 17 +- .../kit/meetings/livestream/list-active.ts | 57 +- .../kit/meetings/participants/create.ts | 135 +- .../kit/meetings/participants/delete.ts | 79 +- .../kit/meetings/participants/edit.ts | 117 +- .../realtime/kit/meetings/participants/get.ts | 75 +- .../kit/meetings/participants/index.ts | 27 +- .../kit/meetings/participants/list.ts | 82 +- .../kit/meetings/participants/replace.ts | 127 +- .../kit/meetings/participants/tokens/index.ts | 17 +- .../meetings/participants/tokens/refresh.ts | 105 +- .../meetings/participants/tokens/revoke.ts | 99 +- .../realtime/kit/meetings/replace.ts | 393 ++--- .../_generated/realtime/kit/presets/create.ts | 767 +++++----- .../_generated/realtime/kit/presets/delete.ts | 67 +- .../_generated/realtime/kit/presets/edit.ts | 782 +++++----- .../_generated/realtime/kit/presets/get.ts | 61 +- .../_generated/realtime/kit/presets/index.ts | 25 +- .../_generated/realtime/kit/presets/list.ts | 82 +- .../realtime/kit/presets/replace.ts | 782 +++++----- .../realtime/kit/recordings/active/get.ts | 57 +- .../realtime/kit/recordings/active/index.ts | 13 +- .../realtime/kit/recordings/control.ts | 81 +- .../_generated/realtime/kit/recordings/get.ts | 61 +- .../realtime/kit/recordings/index.ts | 25 +- .../realtime/kit/recordings/list.ts | 155 +- .../realtime/kit/recordings/start.ts | 280 ++-- .../realtime/kit/recordings/tracks/index.ts | 15 +- .../realtime/kit/recordings/tracks/start.ts | 93 +- .../realtime/kit/sessions/chat/export.ts | 57 +- .../realtime/kit/sessions/chat/index.ts | 15 +- .../_generated/realtime/kit/sessions/get.ts | 62 +- .../_generated/realtime/kit/sessions/index.ts | 29 +- .../_generated/realtime/kit/sessions/list.ts | 148 +- .../realtime/kit/sessions/livestreams/get.ts | 77 +- .../kit/sessions/livestreams/index.ts | 13 +- .../realtime/kit/sessions/participants/get.ts | 73 +- .../kit/sessions/participants/index.ts | 17 +- .../kit/sessions/participants/list.ts | 127 +- .../realtime/kit/sessions/peers/get.ts | 76 +- .../realtime/kit/sessions/peers/index.ts | 13 +- .../realtime/kit/sessions/summaries/export.ts | 55 +- .../kit/sessions/summaries/generate.ts | 55 +- .../realtime/kit/sessions/summaries/index.ts | 17 +- .../kit/sessions/transcripts/export.ts | 64 +- .../kit/sessions/transcripts/index.ts | 15 +- .../realtime/kit/webhooks/create.ts | 93 +- .../realtime/kit/webhooks/delete.ts | 63 +- .../_generated/realtime/kit/webhooks/edit.ts | 101 +- .../realtime/kit/webhooks/events/index.ts | 13 +- .../realtime/kit/webhooks/events/list.ts | 50 +- .../_generated/realtime/kit/webhooks/get.ts | 57 +- .../_generated/realtime/kit/webhooks/index.ts | 27 +- .../_generated/realtime/kit/webhooks/list.ts | 50 +- .../realtime/kit/webhooks/replace.ts | 102 +- .../commands/_generated/realtime/moq/index.ts | 15 +- .../_generated/realtime/moq/relays/create.ts | 60 +- .../_generated/realtime/moq/relays/delete.ts | 57 +- .../_generated/realtime/moq/relays/get.ts | 51 +- .../_generated/realtime/moq/relays/index.ts | 25 +- .../_generated/realtime/moq/relays/list.ts | 77 +- .../realtime/moq/relays/tokens/create.ts | 95 +- .../realtime/moq/relays/tokens/delete.ts | 67 +- .../realtime/moq/relays/tokens/index.ts | 19 +- .../realtime/moq/relays/tokens/list.ts | 50 +- .../_generated/realtime/moq/relays/update.ts | 85 +- .../_generated/realtime/sfu/apps/create.ts | 61 +- .../_generated/realtime/sfu/apps/delete.ts | 56 +- .../_generated/realtime/sfu/apps/get.ts | 51 +- .../_generated/realtime/sfu/apps/index.ts | 23 +- .../_generated/realtime/sfu/apps/list.ts | 40 +- .../_generated/realtime/sfu/apps/update.ts | 73 +- .../commands/_generated/realtime/sfu/index.ts | 13 +- .../_generated/realtime/turn/index.ts | 13 +- .../_generated/realtime/turn/keys/create.ts | 58 +- .../_generated/realtime/turn/keys/delete.ts | 57 +- .../_generated/realtime/turn/keys/get.ts | 51 +- .../_generated/realtime/turn/keys/index.ts | 23 +- .../_generated/realtime/turn/keys/list.ts | 40 +- .../_generated/realtime/turn/keys/update.ts | 71 +- .../registrar-sandbox/extensions/get.ts | 51 +- .../registrar-sandbox/extensions/index.ts | 17 +- .../registrar-sandbox/extensions/list.ts | 91 +- .../_generated/registrar-sandbox/index.ts | 17 +- .../registrar-sandbox/registrations/check.ts | 67 +- .../registrar-sandbox/registrations/create.ts | 338 +++-- .../registrations/get-registration-status.ts | 53 +- .../registrations/get-update-status.ts | 53 +- .../registrar-sandbox/registrations/get.ts | 51 +- .../registrar-sandbox/registrations/index.ts | 29 +- .../registrar-sandbox/registrations/list.ts | 80 +- .../registrar-sandbox/registrations/search.ts | 74 +- .../registrar-sandbox/registrations/update.ts | 80 +- .../_generated/registrar/extensions/get.ts | 51 +- .../_generated/registrar/extensions/index.ts | 17 +- .../_generated/registrar/extensions/list.ts | 91 +- .../commands/_generated/registrar/index.ts | 17 +- .../registrar/registrations/check.ts | 67 +- .../registrations/get-registration-status.ts | 53 +- .../registrations/get-transfer-status.ts | 53 +- .../registrations/get-update-status.ts | 53 +- .../_generated/registrar/registrations/get.ts | 51 +- .../registrar/registrations/index.ts | 37 +- .../registrar/registrations/list.ts | 80 +- .../registrar/registrations/search.ts | 74 +- .../registrar/registrations/transfer-check.ts | 62 +- .../registrar/registrations/transfer-in.ts | 328 ++-- .../registrar/registrations/update.ts | 80 +- .../commands/_generated/reporting/index.ts | 19 +- .../_generated/reporting/industry/get.ts | 40 +- .../_generated/reporting/industry/index.ts | 17 +- .../_generated/reporting/industry/update.ts | 60 +- .../_generated/reporting/policies/get.ts | 51 +- .../_generated/reporting/policies/index.ts | 17 +- .../_generated/reporting/policies/list.ts | 40 +- .../_generated/reporting/reports/get.ts | 51 +- .../_generated/reporting/reports/index.ts | 17 +- .../_generated/reporting/reports/list.ts | 40 +- .../_generated/request-tracers/index.ts | 15 +- .../request-tracers/traces/create.ts | 266 ++-- .../request-tracers/traces/index.ts | 15 +- .../_generated/resource-sharing/create.ts | 99 +- .../_generated/resource-sharing/delete.ts | 53 +- .../excluded-recipients/create.ts | 68 +- .../excluded-recipients/delete.ts | 67 +- .../excluded-recipients/get.ts | 61 +- .../excluded-recipients/index.ts | 23 +- .../excluded-recipients/list.ts | 72 +- .../excluded-recipients/replace.ts | 63 +- .../_generated/resource-sharing/get.ts | 71 +- .../_generated/resource-sharing/index.ts | 29 +- .../_generated/resource-sharing/list.ts | 167 ++- .../resource-sharing/recipients/create.ts | 69 +- .../resource-sharing/recipients/delete.ts | 67 +- .../resource-sharing/recipients/get.ts | 66 +- .../resource-sharing/recipients/index.ts | 23 +- .../resource-sharing/recipients/list.ts | 77 +- .../resource-sharing/recipients/replace.ts | 63 +- .../resource-sharing/resources/create.ts | 100 +- .../resource-sharing/resources/delete.ts | 67 +- .../resource-sharing/resources/get.ts | 61 +- .../resource-sharing/resources/index.ts | 23 +- .../resource-sharing/resources/list.ts | 90 +- .../resource-sharing/resources/update.ts | 83 +- .../_generated/resource-sharing/update.ts | 78 +- .../src/commands/_generated/rules/index.ts | 15 +- .../rules/lists/bulk-operations/get.ts | 51 +- .../rules/lists/bulk-operations/index.ts | 13 +- .../commands/_generated/rules/lists/create.ts | 77 +- .../commands/_generated/rules/lists/delete.ts | 57 +- .../commands/_generated/rules/lists/get.ts | 48 +- .../commands/_generated/rules/lists/index.ts | 27 +- .../_generated/rules/lists/items/create.ts | 61 +- .../_generated/rules/lists/items/delete.ts | 77 +- .../_generated/rules/lists/items/get.ts | 61 +- .../_generated/rules/lists/items/index.ts | 23 +- .../_generated/rules/lists/items/list.ts | 79 +- .../_generated/rules/lists/items/update.ts | 61 +- .../commands/_generated/rules/lists/list.ts | 37 +- .../commands/_generated/rules/lists/update.ts | 71 +- .../commands/_generated/rulesets/create.ts | 110 +- .../commands/_generated/rulesets/delete.ts | 66 +- .../_generated/rulesets/entrypoint/get.ts | 47 +- .../_generated/rulesets/entrypoint/index.ts | 17 +- .../_generated/rulesets/entrypoint/update.ts | 94 +- .../src/commands/_generated/rulesets/get.ts | 51 +- .../src/commands/_generated/rulesets/index.ts | 27 +- .../src/commands/_generated/rulesets/list.ts | 60 +- .../_generated/rulesets/rules/create.ts | 98 +- .../_generated/rulesets/rules/delete.ts | 76 +- .../_generated/rulesets/rules/index.ts | 19 +- .../_generated/rulesets/rules/update.ts | 108 +- .../commands/_generated/rulesets/update.ts | 122 +- .../cli/src/commands/_generated/rum/index.ts | 17 +- .../_generated/rum/rules/bulk-create.ts | 84 +- .../commands/_generated/rum/rules/create.ts | 96 +- .../commands/_generated/rum/rules/delete.ts | 67 +- .../commands/_generated/rum/rules/index.ts | 23 +- .../src/commands/_generated/rum/rules/list.ts | 49 +- .../commands/_generated/rum/rules/update.ts | 106 +- .../_generated/rum/site-info/create.ts | 71 +- .../_generated/rum/site-info/delete.ts | 51 +- .../commands/_generated/rum/site-info/get.ts | 42 +- .../_generated/rum/site-info/index.ts | 29 +- .../rum/site-info/list-site-tags.ts | 45 +- .../rum/site-info/list-zone-tags.ts | 40 +- .../commands/_generated/rum/site-info/list.ts | 67 +- .../_generated/rum/site-info/update.ts | 97 +- .../rum/site-info/validate-hostname.ts | 53 +- .../commands/_generated/scim/groups/create.ts | 60 +- .../commands/_generated/scim/groups/delete.ts | 59 +- .../commands/_generated/scim/groups/edit.ts | 73 +- .../commands/_generated/scim/groups/get.ts | 53 +- .../commands/_generated/scim/groups/index.ts | 25 +- .../commands/_generated/scim/groups/list.ts | 73 +- .../commands/_generated/scim/groups/update.ts | 73 +- .../cli/src/commands/_generated/scim/index.ts | 23 +- .../_generated/scim/resource-types/get.ts | 51 +- .../_generated/scim/resource-types/index.ts | 17 +- .../_generated/scim/resource-types/list.ts | 40 +- .../commands/_generated/scim/schemas/get.ts | 51 +- .../commands/_generated/scim/schemas/index.ts | 17 +- .../commands/_generated/scim/schemas/list.ts | 40 +- .../scim/service-provider-config/get.ts | 40 +- .../scim/service-provider-config/index.ts | 13 +- .../commands/_generated/scim/users/create.ts | 60 +- .../commands/_generated/scim/users/delete.ts | 58 +- .../commands/_generated/scim/users/edit.ts | 72 +- .../src/commands/_generated/scim/users/get.ts | 52 +- .../commands/_generated/scim/users/index.ts | 25 +- .../commands/_generated/scim/users/list.ts | 73 +- .../commands/_generated/scim/users/update.ts | 72 +- .../_generated/secrets-store/index.ts | 19 +- .../_generated/secrets-store/quota/get.ts | 40 +- .../_generated/secrets-store/quota/index.ts | 13 +- .../secrets-store/secrets/bulk-delete.ts | 73 +- .../secrets-store/secrets/create.ts | 57 +- .../secrets-store/secrets/delete.ts | 59 +- .../secrets-store/secrets/duplicate.ts | 94 +- .../_generated/secrets-store/secrets/edit.ts | 97 +- .../_generated/secrets-store/secrets/get.ts | 53 +- .../_generated/secrets-store/secrets/index.ts | 27 +- .../_generated/secrets-store/secrets/list.ts | 106 +- .../_generated/secrets-store/stores/get.ts | 47 +- .../_generated/secrets-store/stores/index.ts | 17 +- .../_generated/secrets-store/stores/list.ts | 75 +- .../security-insights/audit-logs/get.ts | 116 +- .../security-insights/audit-logs/index.ts | 17 +- .../security-insights/audit-logs/list.ts | 111 +- .../_generated/security-insights/classify.ts | 78 +- .../security-insights/context/get.ts | 45 +- .../security-insights/context/index.ts | 13 +- .../security-insights/count/by-class.ts | 116 +- .../security-insights/count/by-partner.ts | 43 +- .../security-insights/count/by-severity.ts | 116 +- .../security-insights/count/by-type.ts | 116 +- .../security-insights/count/index.ts | 21 +- .../_generated/security-insights/dismiss.ts | 53 +- .../_generated/security-insights/index.ts | 31 +- .../_generated/security-insights/list.ts | 137 +- .../security-insights/partners/index.ts | 21 +- .../partners/settings/get.ts | 51 +- .../partners/settings/index.ts | 17 +- .../partners/settings/update.ts | 68 +- .../partners/shadow-hosts/index.ts | 13 +- .../partners/shadow-hosts/list.ts | 72 +- .../partners/shadow-zone-hosts/index.ts | 13 +- .../partners/shadow-zone-hosts/list.ts | 78 +- .../partners/shadow-zones/index.ts | 13 +- .../partners/shadow-zones/list.ts | 72 +- .../security-insights/scans/index.ts | 17 +- .../security-insights/scans/list.ts | 40 +- .../security-insights/scans/start.ts | 78 +- .../_generated/security-insights/state/get.ts | 40 +- .../security-insights/state/index.ts | 17 +- .../security-insights/state/update.ts | 55 +- .../_generated/security-txt/delete.ts | 46 +- .../commands/_generated/security-txt/get.ts | 40 +- .../commands/_generated/security-txt/index.ts | 19 +- .../_generated/security-txt/update.ts | 150 +- .../smart-shield/cache-reserve-clear/clear.ts | 46 +- .../smart-shield/cache-reserve-clear/index.ts | 17 +- .../cache-reserve-clear/status.ts | 40 +- .../commands/_generated/smart-shield/get.ts | 37 +- .../smart-shield/health-checks/create.ts | 270 ++-- .../smart-shield/health-checks/delete.ts | 53 +- .../smart-shield/health-checks/edit.ts | 277 ++-- .../smart-shield/health-checks/get.ts | 47 +- .../smart-shield/health-checks/index.ts | 25 +- .../smart-shield/health-checks/list.ts | 60 +- .../smart-shield/health-checks/update.ts | 306 ++-- .../commands/_generated/smart-shield/index.ts | 21 +- .../_generated/smart-shield/update.ts | 105 +- .../_generated/snippets/content/get.ts | 57 +- .../_generated/snippets/content/index.ts | 13 +- .../commands/_generated/snippets/delete.ts | 57 +- .../src/commands/_generated/snippets/get.ts | 51 +- .../src/commands/_generated/snippets/index.ts | 25 +- .../src/commands/_generated/snippets/list.ts | 57 +- .../_generated/snippets/rules/delete.ts | 46 +- .../_generated/snippets/rules/index.ts | 19 +- .../_generated/snippets/rules/list.ts | 40 +- .../_generated/snippets/rules/update.ts | 62 +- .../commands/_generated/snippets/update.ts | 81 +- .../analytics/aggregates/currents/get.ts | 62 +- .../analytics/aggregates/currents/index.ts | 13 +- .../spectrum/analytics/aggregates/index.ts | 15 +- .../spectrum/analytics/events/bytimes/get.ts | 107 +- .../analytics/events/bytimes/index.ts | 13 +- .../spectrum/analytics/events/index.ts | 17 +- .../analytics/events/summaries/get.ts | 100 +- .../analytics/events/summaries/index.ts | 13 +- .../_generated/spectrum/analytics/index.ts | 19 +- .../spectrum/analytics/zones/index.ts | 15 +- .../spectrum/analytics/zones/report/get.ts | 49 +- .../spectrum/analytics/zones/report/index.ts | 13 +- .../_generated/spectrum/apps/create.ts | 300 ++-- .../_generated/spectrum/apps/delete.ts | 53 +- .../commands/_generated/spectrum/apps/get.ts | 47 +- .../_generated/spectrum/apps/index.ts | 23 +- .../commands/_generated/spectrum/apps/list.ts | 80 +- .../_generated/spectrum/apps/update.ts | 310 ++-- .../src/commands/_generated/spectrum/index.ts | 19 +- .../_generated/spectrum/protocols/index.ts | 13 +- .../_generated/spectrum/protocols/list.ts | 40 +- .../_generated/speed/availabilities/index.ts | 13 +- .../_generated/speed/availabilities/list.ts | 40 +- .../src/commands/_generated/speed/index.ts | 19 +- .../commands/_generated/speed/pages/index.ts | 19 +- .../commands/_generated/speed/pages/list.ts | 37 +- .../_generated/speed/pages/tests/create.ts | 65 +- .../_generated/speed/pages/tests/delete.ts | 62 +- .../_generated/speed/pages/tests/get.ts | 51 +- .../_generated/speed/pages/tests/index.ts | 21 +- .../_generated/speed/pages/tests/list.ts | 64 +- .../commands/_generated/speed/pages/trend.ts | 94 +- .../_generated/speed/schedule/create.ts | 65 +- .../_generated/speed/schedule/delete.ts | 62 +- .../commands/_generated/speed/schedule/get.ts | 54 +- .../_generated/speed/schedule/index.ts | 19 +- .../src/commands/_generated/sql/datasets.ts | 103 +- .../cli/src/commands/_generated/sql/index.ts | 17 +- .../cli/src/commands/_generated/sql/query.ts | 123 +- .../commands/_generated/ssl/analyze/create.ts | 74 +- .../commands/_generated/ssl/analyze/index.ts | 15 +- .../ssl/auto-origin-tls-kex/edit.ts | 57 +- .../_generated/ssl/auto-origin-tls-kex/get.ts | 40 +- .../ssl/auto-origin-tls-kex/index.ts | 17 +- .../_generated/ssl/automatic-upgrader/get.ts | 40 +- .../ssl/automatic-upgrader/index.ts | 17 +- .../ssl/automatic-upgrader/patch.ts | 60 +- .../hostname-associations/get.ts | 52 +- .../hostname-associations/index.ts | 17 +- .../hostname-associations/update.ts | 74 +- .../ssl/certificate-authorities/index.ts | 15 +- .../ssl/certificate-packs/create.ts | 121 +- .../ssl/certificate-packs/delete.ts | 57 +- .../_generated/ssl/certificate-packs/edit.ts | 68 +- .../_generated/ssl/certificate-packs/get.ts | 51 +- .../_generated/ssl/certificate-packs/index.ts | 25 +- .../_generated/ssl/certificate-packs/list.ts | 80 +- .../ssl/certificate-packs/quota/get.ts | 40 +- .../ssl/certificate-packs/quota/index.ts | 13 +- .../ssl/client-certificates/create.ts | 73 +- .../ssl/client-certificates/delete.ts | 57 +- .../ssl/client-certificates/edit.ts | 66 +- .../_generated/ssl/client-certificates/get.ts | 51 +- .../ssl/client-certificates/index.ts | 23 +- .../ssl/client-certificates/list.ts | 86 +- .../_generated/ssl/ct-alerting/get.ts | 40 +- .../_generated/ssl/ct-alerting/index.ts | 17 +- .../_generated/ssl/ct-alerting/update.ts | 70 +- .../ssl/custom-certificates/create.ts | 145 +- .../ssl/custom-certificates/delete.ts | 57 +- .../ssl/custom-certificates/edit.ts | 141 +- .../_generated/ssl/custom-certificates/get.ts | 51 +- .../ssl/custom-certificates/index.ts | 25 +- .../ssl/custom-certificates/list.ts | 79 +- .../custom-certificates/prioritize/index.ts | 15 +- .../custom-certificates/prioritize/update.ts | 62 +- .../_generated/ssl/dcv-delegation/get.ts | 40 +- .../_generated/ssl/dcv-delegation/index.ts | 13 +- .../cli/src/commands/_generated/ssl/index.ts | 45 +- .../ssl/keyless-certificates/create.ts | 123 +- .../ssl/keyless-certificates/delete.ts | 57 +- .../ssl/keyless-certificates/edit.ts | 116 +- .../ssl/keyless-certificates/get.ts | 51 +- .../ssl/keyless-certificates/index.ts | 23 +- .../ssl/keyless-certificates/list.ts | 60 +- .../mtls-certificates/associations/index.ts | 13 +- .../mtls-certificates/associations/list.ts | 50 +- .../ssl/mtls-certificates/create.ts | 88 +- .../ssl/mtls-certificates/delete.ts | 57 +- .../_generated/ssl/mtls-certificates/get.ts | 51 +- .../_generated/ssl/mtls-certificates/index.ts | 23 +- .../_generated/ssl/mtls-certificates/list.ts | 98 +- .../ssl/origin-ca-certificates/create.ts | 108 +- .../ssl/origin-ca-certificates/delete.ts | 57 +- .../ssl/origin-ca-certificates/get.ts | 51 +- .../ssl/origin-ca-certificates/index.ts | 21 +- .../ssl/origin-ca-certificates/list.ts | 67 +- .../hostname-associations/index.ts | 13 +- .../hostname-associations/list.ts | 69 +- .../hostname-certificates/create.ts | 70 +- .../hostname-certificates/delete.ts | 57 +- .../hostname-certificates/get.ts | 51 +- .../hostname-certificates/index.ts | 21 +- .../hostname-certificates/list.ts | 82 +- .../origin-tls-client-auth/hostnames/get.ts | 53 +- .../origin-tls-client-auth/hostnames/index.ts | 17 +- .../hostnames/update.ts | 62 +- .../ssl/origin-tls-client-auth/index.ts | 23 +- .../origin-tls-client-auth/settings/get.ts | 40 +- .../origin-tls-client-auth/settings/index.ts | 17 +- .../origin-tls-client-auth/settings/update.ts | 57 +- .../zone-certificates/create.ts | 70 +- .../zone-certificates/delete.ts | 57 +- .../zone-certificates/get.ts | 51 +- .../zone-certificates/index.ts | 21 +- .../zone-certificates/list.ts | 82 +- .../_generated/ssl/recommendations/get.ts | 40 +- .../_generated/ssl/recommendations/index.ts | 13 +- .../_generated/ssl/universal/index.ts | 15 +- .../_generated/ssl/universal/settings/edit.ts | 57 +- .../_generated/ssl/universal/settings/get.ts | 40 +- .../ssl/universal/settings/index.ts | 17 +- .../_generated/ssl/verification/edit.ts | 74 +- .../_generated/ssl/verification/get.ts | 44 +- .../_generated/ssl/verification/index.ts | 17 +- .../src/commands/_generated/stream/index.ts | 25 +- .../commands/_generated/stream/keys/create.ts | 40 +- .../commands/_generated/stream/keys/delete.ts | 53 +- .../commands/_generated/stream/keys/index.ts | 19 +- .../commands/_generated/stream/keys/list.ts | 40 +- .../_generated/stream/live-inputs/create.ts | 159 +- .../_generated/stream/live-inputs/delete.ts | 57 +- .../_generated/stream/live-inputs/disable.ts | 57 +- .../_generated/stream/live-inputs/enable.ts | 51 +- .../_generated/stream/live-inputs/get.ts | 51 +- .../_generated/stream/live-inputs/index.ts | 31 +- .../_generated/stream/live-inputs/list.ts | 47 +- .../stream/live-inputs/outputs/create.ts | 88 +- .../stream/live-inputs/outputs/delete.ts | 67 +- .../stream/live-inputs/outputs/index.ts | 21 +- .../stream/live-inputs/outputs/list.ts | 50 +- .../stream/live-inputs/outputs/update.ts | 78 +- .../stream/live-inputs/rotate-keys.ts | 57 +- .../_generated/stream/live-inputs/update.ts | 162 +- .../_generated/stream/storage-usage.ts | 50 +- .../stream/videos/audio-tracks/copy.ts | 83 +- .../stream/videos/audio-tracks/delete.ts | 67 +- .../stream/videos/audio-tracks/edit.ts | 88 +- .../stream/videos/audio-tracks/index.ts | 21 +- .../stream/videos/audio-tracks/list.ts | 50 +- .../stream/videos/captions/index.ts | 17 +- .../stream/videos/captions/language/delete.ts | 67 +- .../videos/captions/language/generate.ts | 61 +- .../stream/videos/captions/language/get.ts | 61 +- .../stream/videos/captions/language/index.ts | 23 +- .../stream/videos/captions/language/upload.ts | 81 +- .../videos/captions/language/vtt/get.ts | 61 +- .../videos/captions/language/vtt/index.ts | 13 +- .../_generated/stream/videos/captions/list.ts | 50 +- .../commands/_generated/stream/videos/clip.ts | 176 ++- .../commands/_generated/stream/videos/copy.ts | 177 ++- .../_generated/stream/videos/create.ts | 87 +- .../_generated/stream/videos/delete.ts | 57 +- .../stream/videos/direct-upload/create.ts | 165 +- .../stream/videos/direct-upload/index.ts | 15 +- .../stream/videos/downloads/create.ts | 62 +- .../stream/videos/downloads/delete.ts | 68 +- .../stream/videos/downloads/index.ts | 17 +- .../commands/_generated/stream/videos/edit.ts | 190 +-- .../commands/_generated/stream/videos/get.ts | 51 +- .../_generated/stream/videos/index.ts | 37 +- .../commands/_generated/stream/videos/list.ts | 188 +-- .../_generated/stream/videos/token/create.ts | 135 +- .../_generated/stream/videos/token/index.ts | 15 +- .../_generated/stream/watermarks/create.ts | 123 +- .../_generated/stream/watermarks/delete.ts | 57 +- .../_generated/stream/watermarks/get.ts | 51 +- .../_generated/stream/watermarks/index.ts | 21 +- .../_generated/stream/watermarks/list.ts | 40 +- .../_generated/stream/webhooks/delete.ts | 43 +- .../_generated/stream/webhooks/get.ts | 40 +- .../_generated/stream/webhooks/index.ts | 19 +- .../_generated/stream/webhooks/update.ts | 66 +- .../tags/account-resources/delete.ts | 87 +- .../_generated/tags/account-resources/get.ts | 69 +- .../tags/account-resources/index.ts | 19 +- .../tags/account-resources/update.ts | 94 +- .../cli/src/commands/_generated/tags/index.ts | 23 +- .../commands/_generated/tags/keys/index.ts | 13 +- .../src/commands/_generated/tags/keys/list.ts | 47 +- .../_generated/tags/resources/index.ts | 13 +- .../_generated/tags/resources/list.ts | 112 +- .../commands/_generated/tags/summary/get.ts | 47 +- .../commands/_generated/tags/summary/index.ts | 13 +- .../commands/_generated/tags/values/index.ts | 13 +- .../commands/_generated/tags/values/list.ts | 66 +- .../tenant-custom-nameservers/create.ts | 82 +- .../tenant-custom-nameservers/delete.ts | 67 +- .../tenant-custom-nameservers/get.ts | 51 +- .../tenant-custom-nameservers/index.ts | 19 +- .../_generated/tenants/accounts/index.ts | 13 +- .../_generated/tenants/accounts/list.ts | 190 +-- .../src/commands/_generated/tenants/index.ts | 15 +- .../_generated/tunnels/config/delete.ts | 53 +- .../commands/_generated/tunnels/config/get.ts | 47 +- .../_generated/tunnels/config/index.ts | 19 +- .../_generated/tunnels/config/update.ts | 237 +-- .../_generated/tunnels/connections/cleanup.ts | 63 +- .../_generated/tunnels/connections/index.ts | 17 +- .../_generated/tunnels/connections/list.ts | 50 +- .../_generated/tunnels/connectors/get.ts | 61 +- .../_generated/tunnels/connectors/index.ts | 13 +- .../src/commands/_generated/tunnels/create.ts | 83 +- .../src/commands/_generated/tunnels/delete.ts | 53 +- .../src/commands/_generated/tunnels/edit.ts | 79 +- .../src/commands/_generated/tunnels/get.ts | 44 +- .../_generated/tunnels/hostnames/create.ts | 74 +- .../_generated/tunnels/hostnames/delete.ts | 67 +- .../_generated/tunnels/hostnames/edit.ts | 88 +- .../_generated/tunnels/hostnames/get.ts | 61 +- .../_generated/tunnels/hostnames/index.ts | 23 +- .../_generated/tunnels/hostnames/list.ts | 93 +- .../src/commands/_generated/tunnels/index.ts | 55 +- .../src/commands/_generated/tunnels/list.ts | 152 +- .../tunnels/management-token/create.ts | 69 +- .../tunnels/management-token/index.ts | 15 +- .../commands/_generated/tunnels/token/get.ts | 47 +- .../_generated/tunnels/token/index.ts | 13 +- .../commands/_generated/turnstile/index.ts | 15 +- .../_generated/turnstile/widgets/create.ts | 140 +- .../_generated/turnstile/widgets/delete.ts | 57 +- .../_generated/turnstile/widgets/get.ts | 51 +- .../_generated/turnstile/widgets/index.ts | 25 +- .../_generated/turnstile/widgets/list.ts | 89 +- .../turnstile/widgets/rotate-secret.ts | 67 +- .../_generated/turnstile/widgets/update.ts | 138 +- .../_generated/url-normalization/delete.ts | 46 +- .../_generated/url-normalization/get.ts | 40 +- .../_generated/url-normalization/index.ts | 19 +- .../_generated/url-normalization/update.ts | 72 +- .../commands/_generated/url-scanner/index.ts | 17 +- .../_generated/url-scanner/responses/get.ts | 47 +- .../_generated/url-scanner/responses/index.ts | 13 +- .../url-scanner/scans/bulk-create.ts | 50 +- .../_generated/url-scanner/scans/create.ts | 131 +- .../_generated/url-scanner/scans/dom.ts | 45 +- .../_generated/url-scanner/scans/get.ts | 42 +- .../_generated/url-scanner/scans/har.ts | 45 +- .../_generated/url-scanner/scans/index.ts | 27 +- .../_generated/url-scanner/scans/list.ts | 57 +- .../url-scanner/scans/screenshot.ts | 62 +- .../_generated/user/audit-logs/index.ts | 13 +- .../_generated/user/audit-logs/list.ts | 143 +- .../_generated/user/billing/history/index.ts | 13 +- .../_generated/user/billing/history/list.ts | 94 +- .../commands/_generated/user/billing/index.ts | 17 +- .../_generated/user/billing/profile/get.ts | 39 +- .../_generated/user/billing/profile/index.ts | 13 +- .../cli/src/commands/_generated/user/edit.ts | 91 +- .../user/firewall/access-rules/create.ts | 97 +- .../user/firewall/access-rules/delete.ts | 57 +- .../user/firewall/access-rules/edit.ts | 84 +- .../user/firewall/access-rules/get.ts | 51 +- .../user/firewall/access-rules/index.ts | 23 +- .../user/firewall/access-rules/list.ts | 134 +- .../_generated/user/firewall/index.ts | 15 +- .../cli/src/commands/_generated/user/get.ts | 40 +- .../cli/src/commands/_generated/user/index.ts | 37 +- .../commands/_generated/user/invites/get.ts | 51 +- .../commands/_generated/user/invites/index.ts | 19 +- .../commands/_generated/user/invites/list.ts | 40 +- .../_generated/user/invites/respond.ts | 68 +- .../_generated/user/load-balancers/index.ts | 21 +- .../user/load-balancers/monitors/create.ts | 206 +-- .../user/load-balancers/monitors/delete.ts | 51 +- .../user/load-balancers/monitors/edit.ts | 213 +-- .../user/load-balancers/monitors/get.ts | 45 +- .../user/load-balancers/monitors/index.ts | 29 +- .../user/load-balancers/monitors/list.ts | 40 +- .../load-balancers/monitors/preview/create.ts | 211 +-- .../load-balancers/monitors/preview/index.ts | 15 +- .../monitors/references/index.ts | 13 +- .../monitors/references/list.ts | 46 +- .../user/load-balancers/monitors/update.ts | 213 +-- .../user/load-balancers/pools/bulk-edit.ts | 62 +- .../user/load-balancers/pools/create.ts | 279 ++-- .../user/load-balancers/pools/delete.ts | 51 +- .../user/load-balancers/pools/edit.ts | 289 ++-- .../user/load-balancers/pools/get.ts | 45 +- .../user/load-balancers/pools/health/get.ts | 45 +- .../user/load-balancers/pools/health/index.ts | 13 +- .../user/load-balancers/pools/index.ts | 33 +- .../user/load-balancers/pools/list.ts | 49 +- .../load-balancers/pools/preview/create.ts | 211 +-- .../load-balancers/pools/preview/index.ts | 15 +- .../load-balancers/pools/references/index.ts | 13 +- .../load-balancers/pools/references/list.ts | 46 +- .../user/load-balancers/pools/update.ts | 289 ++-- .../user/load-balancers/preview/get.ts | 45 +- .../user/load-balancers/preview/index.ts | 13 +- .../user/load-balancers/regions/index.ts | 13 +- .../user/load-balancers/regions/list.ts | 60 +- .../load-balancing-analytics/events/index.ts | 13 +- .../load-balancing-analytics/events/list.ts | 103 +- .../user/load-balancing-analytics/index.ts | 15 +- .../_generated/user/memberships/delete.ts | 57 +- .../_generated/user/memberships/get.ts | 51 +- .../_generated/user/memberships/index.ts | 21 +- .../_generated/user/memberships/list.ts | 103 +- .../_generated/user/memberships/update.ts | 71 +- .../_generated/user/subscriptions/delete.ts | 57 +- .../_generated/user/subscriptions/index.ts | 19 +- .../_generated/user/subscriptions/list.ts | 37 +- .../_generated/user/subscriptions/update.ts | 164 +- .../commands/_generated/user/tenants/index.ts | 13 +- .../commands/_generated/user/tenants/list.ts | 40 +- .../commands/_generated/user/tokens/create.ts | 110 +- .../commands/_generated/user/tokens/delete.ts | 50 +- .../commands/_generated/user/tokens/get.ts | 47 +- .../commands/_generated/user/tokens/index.ts | 29 +- .../commands/_generated/user/tokens/list.ts | 77 +- .../user/tokens/permission-groups/index.ts | 13 +- .../user/tokens/permission-groups/list.ts | 62 +- .../commands/_generated/user/tokens/roll.ts | 50 +- .../commands/_generated/user/tokens/update.ts | 125 +- .../commands/_generated/user/tokens/verify.ts | 37 +- .../commands/_generated/vectorize/create.ts | 114 +- .../commands/_generated/vectorize/delete.ts | 51 +- .../src/commands/_generated/vectorize/get.ts | 45 +- .../commands/_generated/vectorize/index.ts | 27 +- .../src/commands/_generated/vectorize/info.ts | 45 +- .../src/commands/_generated/vectorize/list.ts | 37 +- .../vectorize/metadata-indexes/create.ts | 77 +- .../vectorize/metadata-indexes/delete.ts | 71 +- .../vectorize/metadata-indexes/index.ts | 19 +- .../vectorize/metadata-indexes/list.ts | 46 +- .../vectorize/vectors/bulk-delete.ts | 70 +- .../_generated/vectorize/vectors/bulk-get.ts | 70 +- .../_generated/vectorize/vectors/index.ts | 25 +- .../_generated/vectorize/vectors/insert.ts | 72 +- .../_generated/vectorize/vectors/list.ts | 66 +- .../_generated/vectorize/vectors/query.ts | 110 +- .../_generated/vectorize/vectors/upsert.ts | 72 +- .../account-waiting-rooms/index.ts | 13 +- .../account-waiting-rooms/list.ts | 61 +- .../_generated/waiting-rooms/create.ts | 291 ++-- .../_generated/waiting-rooms/delete.ts | 52 +- .../commands/_generated/waiting-rooms/edit.ts | 303 ++-- .../_generated/waiting-rooms/events/create.ts | 210 +-- .../_generated/waiting-rooms/events/delete.ts | 61 +- .../waiting-rooms/events/details/get.ts | 55 +- .../waiting-rooms/events/details/index.ts | 13 +- .../_generated/waiting-rooms/events/edit.ts | 221 +-- .../_generated/waiting-rooms/events/get.ts | 55 +- .../_generated/waiting-rooms/events/index.ts | 27 +- .../_generated/waiting-rooms/events/list.ts | 68 +- .../_generated/waiting-rooms/events/update.ts | 221 +-- .../commands/_generated/waiting-rooms/get.ts | 47 +- .../_generated/waiting-rooms/index.ts | 35 +- .../_generated/waiting-rooms/page/index.ts | 15 +- .../_generated/waiting-rooms/page/preview.ts | 61 +- .../_generated/waiting-rooms/rules/create.ts | 95 +- .../_generated/waiting-rooms/rules/delete.ts | 63 +- .../_generated/waiting-rooms/rules/edit.ts | 137 +- .../_generated/waiting-rooms/rules/index.ts | 23 +- .../_generated/waiting-rooms/rules/list.ts | 47 +- .../_generated/waiting-rooms/rules/update.ts | 57 +- .../_generated/waiting-rooms/settings/edit.ts | 57 +- .../_generated/waiting-rooms/settings/get.ts | 40 +- .../waiting-rooms/settings/index.ts | 19 +- .../waiting-rooms/settings/update.ts | 57 +- .../_generated/waiting-rooms/statuses/get.ts | 47 +- .../waiting-rooms/statuses/index.ts | 13 +- .../_generated/waiting-rooms/update.ts | 303 ++-- .../_generated/web-assets/discovery/get.ts | 40 +- .../_generated/web-assets/discovery/index.ts | 17 +- .../discovery/operations/bulk-edit.ts | 50 +- .../web-assets/discovery/operations/edit.ts | 71 +- .../web-assets/discovery/operations/get.ts | 51 +- .../web-assets/discovery/operations/index.ts | 21 +- .../web-assets/discovery/operations/list.ts | 145 +- .../commands/_generated/web-assets/index.ts | 21 +- .../_generated/web-assets/labels/index.ts | 19 +- .../_generated/web-assets/labels/list.ts | 110 +- .../web-assets/labels/managed/get.ts | 50 +- .../web-assets/labels/managed/index.ts | 17 +- .../labels/managed/operations/index.ts | 15 +- .../labels/managed/operations/update.ts | 55 +- .../web-assets/labels/user/bulk-create.ts | 50 +- .../web-assets/labels/user/bulk-delete.ts | 56 +- .../web-assets/labels/user/delete.ts | 51 +- .../_generated/web-assets/labels/user/edit.ts | 77 +- .../_generated/web-assets/labels/user/get.ts | 50 +- .../web-assets/labels/user/index.ts | 27 +- .../labels/user/operations/index.ts | 15 +- .../labels/user/operations/update.ts | 55 +- .../web-assets/labels/user/update.ts | 77 +- .../web-assets/operations/bulk-create.ts | 50 +- .../web-assets/operations/bulk-delete.ts | 56 +- .../web-assets/operations/create.ts | 77 +- .../web-assets/operations/delete.ts | 57 +- .../_generated/web-assets/operations/get.ts | 74 +- .../_generated/web-assets/operations/index.ts | 27 +- .../operations/labels/bulk-create.ts | 74 +- .../operations/labels/bulk-delete.ts | 80 +- .../operations/labels/bulk-update.ts | 76 +- .../web-assets/operations/labels/create.ts | 85 +- .../web-assets/operations/labels/delete.ts | 91 +- .../web-assets/operations/labels/index.ts | 25 +- .../web-assets/operations/labels/update.ts | 87 +- .../_generated/web-assets/operations/list.ts | 130 +- .../_generated/web-assets/schemas/index.ts | 13 +- .../_generated/web-assets/schemas/list.ts | 86 +- .../_generated/web3/hostnames/create.ts | 90 +- .../_generated/web3/hostnames/delete.ts | 57 +- .../_generated/web3/hostnames/edit.ts | 81 +- .../commands/_generated/web3/hostnames/get.ts | 51 +- .../_generated/web3/hostnames/index.ts | 25 +- .../content-lists/entries/create.ts | 91 +- .../content-lists/entries/delete.ts | 67 +- .../content-lists/entries/get.ts | 61 +- .../content-lists/entries/index.ts | 23 +- .../content-lists/entries/list.ts | 50 +- .../content-lists/entries/update.ts | 101 +- .../ipfs-universal-paths/content-lists/get.ts | 51 +- .../content-lists/index.ts | 19 +- .../content-lists/update.ts | 81 +- .../hostnames/ipfs-universal-paths/index.ts | 15 +- .../_generated/web3/hostnames/list.ts | 40 +- .../cli/src/commands/_generated/web3/index.ts | 15 +- .../dispatch-namespaces/create.ts | 66 +- .../dispatch-namespaces/delete.ts | 57 +- .../dispatch-namespaces/get.ts | 51 +- .../dispatch-namespaces/index.ts | 23 +- .../dispatch-namespaces/list.ts | 40 +- .../scripts/bindings/get.ts | 57 +- .../scripts/bindings/index.ts | 13 +- .../dispatch-namespaces/scripts/delete.ts | 72 +- .../dispatch-namespaces/scripts/get.ts | 57 +- .../dispatch-namespaces/scripts/index.ts | 27 +- .../dispatch-namespaces/scripts/list.ts | 62 +- .../scripts/secrets/bulk-edit.ts | 102 +- .../scripts/secrets/delete.ts | 87 +- .../scripts/secrets/get.ts | 77 +- .../scripts/secrets/index.ts | 23 +- .../scripts/secrets/list.ts | 60 +- .../scripts/secrets/update.ts | 174 ++- .../scripts/settings/edit.ts | 89 +- .../scripts/settings/get.ts | 57 +- .../scripts/settings/index.ts | 17 +- .../scripts/tags/delete.ts | 81 +- .../dispatch-namespaces/scripts/tags/index.ts | 19 +- .../dispatch-namespaces/scripts/tags/list.ts | 60 +- .../scripts/tags/update.ts | 67 +- .../_generated/workers-for-platforms/index.ts | 15 +- .../commands/_generated/workers-vpc/index.ts | 15 +- .../_generated/workers-vpc/services/create.ts | 246 +-- .../_generated/workers-vpc/services/delete.ts | 51 +- .../_generated/workers-vpc/services/get.ts | 45 +- .../_generated/workers-vpc/services/index.ts | 23 +- .../_generated/workers-vpc/services/list.ts | 67 +- .../_generated/workers-vpc/services/update.ts | 251 ++-- .../_generated/workers/deployments/create.ts | 163 +- .../_generated/workers/deployments/delete.ts | 67 +- .../_generated/workers/deployments/get.ts | 63 +- .../_generated/workers/deployments/index.ts | 21 +- .../_generated/workers/deployments/list.ts | 86 +- .../src/commands/_generated/workers/get.ts | 63 +- .../src/commands/_generated/workers/index.ts | 43 +- .../src/commands/_generated/workers/list.ts | 69 +- .../workers/previews/deployments/index.ts | 15 +- .../workers/previews/deployments/profile.ts | 135 +- .../_generated/workers/previews/index.ts | 15 +- .../_generated/workers/scripts/index.ts | 15 +- .../_generated/workers/scripts/search.ts | 83 +- .../_generated/workers/secrets/bulk-edit.ts | 92 +- .../_generated/workers/secrets/delete.ts | 77 +- .../_generated/workers/secrets/get.ts | 69 +- .../_generated/workers/secrets/index.ts | 23 +- .../_generated/workers/secrets/list.ts | 52 +- .../_generated/workers/secrets/update.ts | 168 ++- .../_generated/workers/versions/delete.ts | 68 +- .../_generated/workers/versions/get.ts | 72 +- .../_generated/workers/versions/index.ts | 25 +- .../_generated/workers/versions/list.ts | 63 +- .../_generated/workers/versions/profile.ts | 125 +- .../workflows/concurrency/create.ts | 73 +- .../workflows/concurrency/delete.ts | 57 +- .../_generated/workflows/concurrency/edit.ts | 72 +- .../_generated/workflows/concurrency/get.ts | 51 +- .../_generated/workflows/concurrency/index.ts | 23 +- .../_generated/workflows/concurrency/list.ts | 49 +- .../commands/_generated/workflows/delete.ts | 53 +- .../src/commands/_generated/workflows/get.ts | 47 +- .../commands/_generated/workflows/index.ts | 27 +- .../workflows/instances/batch/create.ts | 57 +- .../workflows/instances/batch/delete.ts | 75 +- .../workflows/instances/batch/index.ts | 17 +- .../_generated/workflows/instances/create.ts | 110 +- .../_generated/workflows/instances/delete.ts | 65 +- .../workflows/instances/events/index.ts | 13 +- .../workflows/instances/events/send.ts | 73 +- .../_generated/workflows/instances/get.ts | 79 +- .../_generated/workflows/instances/index.ts | 35 +- .../_generated/workflows/instances/list.ts | 113 +- .../_generated/workflows/instances/pause.ts | 133 +- .../_generated/workflows/instances/restart.ts | 133 +- .../_generated/workflows/instances/resume.ts | 133 +- .../workflows/instances/step/get.ts | 96 +- .../workflows/instances/step/index.ts | 13 +- .../workflows/instances/terminate.ts | 141 +- .../src/commands/_generated/workflows/list.ts | 58 +- .../_generated/workflows/settings/edit.ts | 72 +- .../_generated/workflows/settings/get.ts | 40 +- .../_generated/workflows/settings/index.ts | 17 +- .../_generated/workflows/versions/get.ts | 51 +- .../_generated/workflows/versions/graph.ts | 51 +- .../_generated/workflows/versions/index.ts | 19 +- .../_generated/workflows/versions/list.ts | 55 +- .../commands/_generated/zaraz/config/get.ts | 40 +- .../commands/_generated/zaraz/config/index.ts | 17 +- .../_generated/zaraz/config/update.ts | 474 +++--- .../commands/_generated/zaraz/default/get.ts | 39 +- .../_generated/zaraz/default/index.ts | 13 +- .../commands/_generated/zaraz/export/get.ts | 40 +- .../commands/_generated/zaraz/export/index.ts | 13 +- .../_generated/zaraz/history/configs/get.ts | 52 +- .../_generated/zaraz/history/configs/index.ts | 13 +- .../_generated/zaraz/history/index.ts | 19 +- .../commands/_generated/zaraz/history/list.ts | 80 +- .../_generated/zaraz/history/update.ts | 50 +- .../src/commands/_generated/zaraz/index.ts | 25 +- .../_generated/zaraz/publish/create.ts | 50 +- .../_generated/zaraz/publish/index.ts | 15 +- .../commands/_generated/zaraz/workflow/get.ts | 37 +- .../_generated/zaraz/workflow/index.ts | 17 +- .../_generated/zaraz/workflow/update.ts | 59 +- .../zero-trust/access/applications/create.ts | 50 +- .../zero-trust/access/applications/delete.ts | 51 +- .../zero-trust/access/applications/get.ts | 45 +- .../zero-trust/access/applications/index.ts | 35 +- .../zero-trust/access/applications/list.ts | 105 +- .../access/applications/policies/index.ts | 15 +- .../applications/policies/make-reusable.ts | 53 +- .../applications/policy-tests/create.ts | 50 +- .../access/applications/policy-tests/get.ts | 51 +- .../access/applications/policy-tests/index.ts | 19 +- .../applications/policy-tests/users/index.ts | 13 +- .../applications/policy-tests/users/list.ts | 71 +- .../access/applications/revoke-tokens.ts | 51 +- .../access/applications/settings/index.ts | 15 +- .../access/applications/settings/update.ts | 69 +- .../short-lived-certificates/create.ts | 45 +- .../short-lived-certificates/delete.ts | 51 +- .../short-lived-certificates/get.ts | 45 +- .../short-lived-certificates/index.ts | 21 +- .../short-lived-certificates/list.ts | 57 +- .../zero-trust/access/applications/update.ts | 55 +- .../applications/user-policy-checks/index.ts | 13 +- .../applications/user-policy-checks/list.ts | 46 +- .../zero-trust/access/custom-pages/create.ts | 113 +- .../zero-trust/access/custom-pages/delete.ts | 51 +- .../zero-trust/access/custom-pages/get.ts | 45 +- .../zero-trust/access/custom-pages/index.ts | 25 +- .../zero-trust/access/custom-pages/list.ts | 54 +- .../zero-trust/access/custom-pages/update.ts | 121 +- .../access/custom-pages/validate.ts | 80 +- .../_generated/zero-trust/access/index.ts | 43 +- .../infrastructure/audit-ssh-settings/get.ts | 40 +- .../audit-ssh-settings/index.ts | 19 +- .../audit-ssh-settings/rotate-seed.ts | 40 +- .../audit-ssh-settings/update.ts | 62 +- .../zero-trust/access/infrastructure/index.ts | 17 +- .../access/infrastructure/ssh-ca/create.ts | 40 +- .../access/infrastructure/ssh-ca/delete.ts | 51 +- .../access/infrastructure/ssh-ca/index.ts | 19 +- .../access/infrastructure/ssh-ca/list.ts | 40 +- .../access/logs/access-requests/index.ts | 13 +- .../access/logs/access-requests/list.ts | 234 +-- .../zero-trust/access/logs/index.ts | 19 +- .../access/logs/jit-requests/get.ts | 51 +- .../access/logs/jit-requests/index.ts | 17 +- .../access/logs/jit-requests/list.ts | 96 +- .../zero-trust/access/logs/scim/index.ts | 15 +- .../access/logs/scim/updates/index.ts | 13 +- .../access/logs/scim/updates/list.ts | 204 +-- .../access/mfa/authenticator-catalog/index.ts | 13 +- .../access/mfa/authenticator-catalog/list.ts | 40 +- .../_generated/zero-trust/access/mfa/index.ts | 15 +- .../access/mtls-certificates/create.ts | 84 +- .../access/mtls-certificates/delete.ts | 51 +- .../access/mtls-certificates/get.ts | 45 +- .../access/mtls-certificates/index.ts | 25 +- .../access/mtls-certificates/list.ts | 57 +- .../access/mtls-certificates/settings/get.ts | 40 +- .../mtls-certificates/settings/index.ts | 17 +- .../mtls-certificates/settings/update.ts | 62 +- .../access/mtls-certificates/update.ts | 79 +- .../zero-trust/access/policies/create.ts | 222 +-- .../zero-trust/access/policies/delete.ts | 57 +- .../zero-trust/access/policies/get.ts | 51 +- .../zero-trust/access/policies/index.ts | 23 +- .../zero-trust/access/policies/list.ts | 57 +- .../zero-trust/access/policies/update.ts | 233 +-- .../zero-trust/access/rule-groups/create.ts | 97 +- .../zero-trust/access/rule-groups/delete.ts | 51 +- .../zero-trust/access/rule-groups/get.ts | 45 +- .../zero-trust/access/rule-groups/index.ts | 23 +- .../zero-trust/access/rule-groups/list.ts | 74 +- .../zero-trust/access/rule-groups/update.ts | 102 +- .../saml-encryption-certificates/get-pem.ts | 51 +- .../saml-encryption-certificates/get.ts | 51 +- .../saml-encryption-certificates/index.ts | 21 +- .../saml-encryption-certificates/list.ts | 72 +- .../saml-encryption-certificates/rotate.ts | 51 +- .../access/service-tokens/create.ts | 107 +- .../access/service-tokens/delete.ts | 53 +- .../zero-trust/access/service-tokens/get.ts | 47 +- .../zero-trust/access/service-tokens/index.ts | 27 +- .../zero-trust/access/service-tokens/list.ts | 78 +- .../access/service-tokens/refresh.ts | 47 +- .../access/service-tokens/rotate.ts | 69 +- .../access/service-tokens/update.ts | 114 +- .../zero-trust/access/signing-keys/get.ts | 40 +- .../zero-trust/access/signing-keys/index.ts | 19 +- .../zero-trust/access/signing-keys/rotate.ts | 40 +- .../zero-trust/access/signing-keys/update.ts | 60 +- .../zero-trust/access/tags/create.ts | 54 +- .../zero-trust/access/tags/delete.ts | 50 +- .../_generated/zero-trust/access/tags/get.ts | 44 +- .../zero-trust/access/tags/index.ts | 23 +- .../_generated/zero-trust/access/tags/list.ts | 54 +- .../zero-trust/access/tags/update.ts | 76 +- .../zero-trust/access/targets/bulk-create.ts | 50 +- .../zero-trust/access/targets/bulk-delete.ts | 62 +- .../access/targets/bulk-replace-tags.ts | 62 +- .../zero-trust/access/targets/create.ts | 112 +- .../zero-trust/access/targets/delete.ts | 53 +- .../zero-trust/access/targets/get.ts | 47 +- .../zero-trust/access/targets/index.ts | 29 +- .../zero-trust/access/targets/list.ts | 256 ++-- .../zero-trust/access/targets/update.ts | 119 +- .../access/user-populations/create.ts | 62 +- .../access/user-populations/delete.ts | 53 +- .../zero-trust/access/user-populations/get.ts | 47 +- .../access/user-populations/index.ts | 25 +- .../access/user-populations/list.ts | 57 +- .../access/user-populations/update.ts | 69 +- .../access/user-populations/users/create.ts | 226 +-- .../access/user-populations/users/delete.ts | 63 +- .../access/user-populations/users/get.ts | 78 +- .../access/user-populations/users/index.ts | 25 +- .../access/user-populations/users/list.ts | 97 +- .../access/user-populations/users/replace.ts | 236 +-- .../access/user-populations/users/update.ts | 101 +- .../access/users/active-sessions/get.ts | 51 +- .../access/users/active-sessions/index.ts | 17 +- .../access/users/active-sessions/list.ts | 46 +- .../zero-trust/access/users/create.ts | 61 +- .../zero-trust/access/users/delete.ts | 51 +- .../access/users/failed-logins/index.ts | 13 +- .../access/users/failed-logins/list.ts | 46 +- .../_generated/zero-trust/access/users/get.ts | 45 +- .../zero-trust/access/users/index.ts | 31 +- .../access/users/last-seen-identity/get.ts | 45 +- .../access/users/last-seen-identity/index.ts | 13 +- .../zero-trust/access/users/list.ts | 81 +- .../zero-trust/access/users/revoke.ts | 94 +- .../zero-trust/access/users/update.ts | 69 +- .../casb/applications/auth-methods/index.ts | 13 +- .../casb/applications/auth-methods/list.ts | 79 +- .../zero-trust/casb/applications/get.ts | 60 +- .../zero-trust/casb/applications/index.ts | 19 +- .../zero-trust/casb/applications/list.ts | 69 +- .../zero-trust/casb/asset-schemas/get.ts | 51 +- .../zero-trust/casb/asset-schemas/index.ts | 17 +- .../zero-trust/casb/asset-schemas/list.ts | 49 +- .../zero-trust/casb/content/export.ts | 138 +- .../zero-trust/casb/content/index.ts | 17 +- .../zero-trust/casb/content/list.ts | 135 +- .../_generated/zero-trust/casb/exports/get.ts | 51 +- .../zero-trust/casb/exports/index.ts | 17 +- .../zero-trust/casb/exports/list.ts | 67 +- .../zero-trust/casb/finding-types/create.ts | 136 +- .../zero-trust/casb/finding-types/delete.ts | 57 +- .../zero-trust/casb/finding-types/get.ts | 51 +- .../zero-trust/casb/finding-types/index.ts | 27 +- .../zero-trust/casb/finding-types/list.ts | 183 +-- .../finding-types/remediation-types/index.ts | 13 +- .../finding-types/remediation-types/list.ts | 90 +- .../zero-trust/casb/finding-types/update.ts | 112 +- .../zero-trust/casb/finding-types/validate.ts | 136 +- .../zero-trust/casb/findings/export.ts | 142 +- .../zero-trust/casb/findings/get.ts | 53 +- .../zero-trust/casb/findings/ignore.ts | 62 +- .../zero-trust/casb/findings/index.ts | 29 +- .../casb/findings/instances/archive.ts | 75 +- .../casb/findings/instances/export.ts | 107 +- .../zero-trust/casb/findings/instances/get.ts | 63 +- .../casb/findings/instances/index.ts | 23 +- .../casb/findings/instances/list.ts | 169 ++- .../casb/findings/instances/unarchive.ts | 75 +- .../zero-trust/casb/findings/list.ts | 202 +-- .../casb/findings/reset-severity.ts | 53 +- .../zero-trust/casb/findings/tune-severity.ts | 73 +- .../zero-trust/casb/findings/unignore.ts | 62 +- .../_generated/zero-trust/casb/index.ts | 33 +- .../zero-trust/casb/integrations/create.ts | 135 +- .../zero-trust/casb/integrations/delete.ts | 51 +- .../zero-trust/casb/integrations/get.ts | 45 +- .../zero-trust/casb/integrations/index.ts | 27 +- .../zero-trust/casb/integrations/list.ts | 130 +- .../zero-trust/casb/integrations/pause.ts | 45 +- .../zero-trust/casb/integrations/resume.ts | 45 +- .../zero-trust/casb/integrations/update.ts | 145 +- .../zero-trust/casb/policies/create.ts | 128 +- .../zero-trust/casb/policies/delete.ts | 57 +- .../zero-trust/casb/policies/get.ts | 51 +- .../zero-trust/casb/policies/index.ts | 23 +- .../zero-trust/casb/policies/list.ts | 52 +- .../zero-trust/casb/policies/update.ts | 130 +- .../zero-trust/casb/remediations/index.ts | 13 +- .../casb/remediations/jobs/create.ts | 72 +- .../casb/remediations/jobs/export.ts | 113 +- .../casb/remediations/jobs/index.ts | 19 +- .../zero-trust/casb/remediations/jobs/list.ts | 154 +- .../zero-trust/casb/webhooks/create.ts | 117 +- .../zero-trust/casb/webhooks/delete.ts | 57 +- .../casb/webhooks/evaluate-existing.ts | 51 +- .../zero-trust/casb/webhooks/evaluate.ts | 94 +- .../zero-trust/casb/webhooks/get.ts | 51 +- .../zero-trust/casb/webhooks/index.ts | 29 +- .../zero-trust/casb/webhooks/jobs/create.ts | 76 +- .../zero-trust/casb/webhooks/jobs/index.ts | 15 +- .../zero-trust/casb/webhooks/list.ts | 40 +- .../zero-trust/casb/webhooks/update.ts | 128 +- .../zero-trust/connectivity-settings/edit.ts | 64 +- .../zero-trust/connectivity-settings/get.ts | 40 +- .../zero-trust/connectivity-settings/index.ts | 17 +- .../cws/basic-auth-credentials/create.ts | 62 +- .../cws/basic-auth-credentials/delete.ts | 57 +- .../cws/basic-auth-credentials/get.ts | 51 +- .../cws/basic-auth-credentials/index.ts | 23 +- .../cws/basic-auth-credentials/list.ts | 98 +- .../basic-auth-credentials/secrets/create.ts | 83 +- .../basic-auth-credentials/secrets/delete.ts | 67 +- .../cws/basic-auth-credentials/secrets/get.ts | 61 +- .../basic-auth-credentials/secrets/index.ts | 21 +- .../basic-auth-credentials/secrets/list.ts | 88 +- .../zero-trust/cws/deployments/create.ts | 148 +- .../zero-trust/cws/deployments/delete.ts | 57 +- .../zero-trust/cws/deployments/get.ts | 51 +- .../zero-trust/cws/deployments/index.ts | 23 +- .../zero-trust/cws/deployments/list.ts | 89 +- .../zero-trust/cws/deployments/update.ts | 159 +- .../zero-trust/cws/domain-acls/create.ts | 80 +- .../zero-trust/cws/domain-acls/delete.ts | 57 +- .../zero-trust/cws/domain-acls/get.ts | 51 +- .../zero-trust/cws/domain-acls/index.ts | 23 +- .../zero-trust/cws/domain-acls/list.ts | 99 +- .../zero-trust/cws/domain-acls/update.ts | 91 +- .../_generated/zero-trust/cws/index.ts | 31 +- .../zero-trust/cws/policies/create.ts | 109 +- .../zero-trust/cws/policies/delete.ts | 57 +- .../_generated/zero-trust/cws/policies/get.ts | 51 +- .../zero-trust/cws/policies/index.ts | 23 +- .../zero-trust/cws/policies/list.ts | 110 +- .../zero-trust/cws/policies/update.ts | 120 +- .../zero-trust/cws/policy-sets/create.ts | 113 +- .../zero-trust/cws/policy-sets/delete.ts | 57 +- .../zero-trust/cws/policy-sets/get.ts | 51 +- .../zero-trust/cws/policy-sets/index.ts | 23 +- .../zero-trust/cws/policy-sets/list.ts | 99 +- .../zero-trust/cws/policy-sets/update.ts | 124 +- .../zero-trust/cws/rego-metadata/create.ts | 72 +- .../zero-trust/cws/rego-metadata/delete.ts | 57 +- .../zero-trust/cws/rego-metadata/get.ts | 51 +- .../zero-trust/cws/rego-metadata/index.ts | 23 +- .../zero-trust/cws/rego-metadata/list.ts | 100 +- .../zero-trust/cws/rego-metadata/update.ts | 83 +- .../zero-trust/cws/rego-modules/create.ts | 72 +- .../zero-trust/cws/rego-modules/delete.ts | 57 +- .../zero-trust/cws/rego-modules/get.ts | 51 +- .../zero-trust/cws/rego-modules/index.ts | 23 +- .../zero-trust/cws/rego-modules/list.ts | 100 +- .../zero-trust/cws/rego-modules/update.ts | 83 +- .../cws/tenant-structures/create.ts | 82 +- .../cws/tenant-structures/delete.ts | 57 +- .../zero-trust/cws/tenant-structures/get.ts | 51 +- .../zero-trust/cws/tenant-structures/index.ts | 25 +- .../zero-trust/cws/tenant-structures/list.ts | 101 +- .../cws/tenant-structures/nodes/bulk-apply.ts | 96 +- .../cws/tenant-structures/nodes/create.ts | 103 +- .../cws/tenant-structures/nodes/delete.ts | 67 +- .../cws/tenant-structures/nodes/get.ts | 61 +- .../cws/tenant-structures/nodes/index.ts | 25 +- .../cws/tenant-structures/nodes/list.ts | 128 +- .../cws/tenant-structures/nodes/update.ts | 113 +- .../cws/tenant-structures/update.ts | 94 +- .../zero-trust/cws/workloads/create.ts | 92 +- .../zero-trust/cws/workloads/delete.ts | 57 +- .../zero-trust/cws/workloads/get.ts | 51 +- .../zero-trust/cws/workloads/index.ts | 23 +- .../zero-trust/cws/workloads/list.ts | 98 +- .../zero-trust/cws/workloads/update.ts | 103 +- .../devices/client-versions/index.ts | 17 +- .../devices/client-versions/list.ts | 79 +- .../target-environments/index.ts | 13 +- .../target-environments/list.ts | 40 +- .../_generated/zero-trust/devices/delete.ts | 48 +- .../devices/deployment-groups/create.ts | 85 +- .../devices/deployment-groups/delete.ts | 51 +- .../devices/deployment-groups/get.ts | 45 +- .../devices/deployment-groups/index.ts | 23 +- .../devices/deployment-groups/list.ts | 61 +- .../devices/deployment-groups/update.ts | 89 +- .../devices/emergency-disconnect/get.ts | 40 +- .../devices/emergency-disconnect/index.ts | 17 +- .../devices/emergency-disconnect/set.ts | 67 +- .../_generated/zero-trust/devices/get.ts | 57 +- .../_generated/zero-trust/devices/index.ts | 39 +- .../zero-trust/devices/ip-profiles/create.ts | 106 +- .../zero-trust/devices/ip-profiles/delete.ts | 51 +- .../zero-trust/devices/ip-profiles/get.ts | 45 +- .../zero-trust/devices/ip-profiles/index.ts | 23 +- .../zero-trust/devices/ip-profiles/list.ts | 60 +- .../zero-trust/devices/ip-profiles/update.ts | 112 +- .../_generated/zero-trust/devices/list.ts | 184 +-- .../zero-trust/devices/networks/create.ts | 90 +- .../zero-trust/devices/networks/delete.ts | 51 +- .../zero-trust/devices/networks/get.ts | 45 +- .../zero-trust/devices/networks/index.ts | 23 +- .../zero-trust/devices/networks/list.ts | 40 +- .../zero-trust/devices/networks/update.ts | 99 +- .../devices/override-codes/create.ts | 93 +- .../devices/override-codes/index.ts | 15 +- .../zero-trust/devices/posture/index.ts | 17 +- .../devices/posture/integrations/create.ts | 209 +-- .../devices/posture/integrations/delete.ts | 53 +- .../devices/posture/integrations/get.ts | 47 +- .../devices/posture/integrations/index.ts | 23 +- .../devices/posture/integrations/list.ts | 40 +- .../devices/posture/integrations/update.ts | 216 +-- .../devices/posture/rules/create.ts | 852 ++++++----- .../devices/posture/rules/delete.ts | 51 +- .../zero-trust/devices/posture/rules/get.ts | 45 +- .../zero-trust/devices/posture/rules/index.ts | 23 +- .../zero-trust/devices/posture/rules/list.ts | 40 +- .../devices/posture/rules/update.ts | 857 ++++++----- .../devices/registrations/bulk-delete.ts | 58 +- .../devices/registrations/delete.ts | 53 +- .../zero-trust/devices/registrations/get.ts | 59 +- .../zero-trust/devices/registrations/index.ts | 23 +- .../zero-trust/devices/registrations/list.ts | 187 +-- .../registrations/override-codes/get.ts | 47 +- .../registrations/override-codes/index.ts | 13 +- .../zero-trust/devices/settings/delete.ts | 46 +- .../zero-trust/devices/settings/get.ts | 40 +- .../zero-trust/devices/settings/index.ts | 19 +- .../zero-trust/devices/settings/update.ts | 134 +- .../_generated/zero-trust/devices/update.ts | 67 +- .../_generated/zero-trust/dex/colos/index.ts | 13 +- .../_generated/zero-trust/dex/colos/list.ts | 69 +- .../zero-trust/dex/commands/create.ts | 62 +- .../dex/commands/eligible-devices/index.ts | 13 +- .../dex/commands/eligible-devices/list.ts | 70 +- .../zero-trust/dex/commands/index.ts | 23 +- .../zero-trust/dex/commands/list.ts | 119 +- .../zero-trust/dex/commands/quota/get.ts | 40 +- .../zero-trust/dex/commands/quota/index.ts | 13 +- .../zero-trust/dex/commands/results/get.ts | 69 +- .../zero-trust/dex/commands/results/index.ts | 13 +- .../dex/devices/aggregates/index.ts | 17 +- .../dex/devices/aggregates/live/get.ts | 50 +- .../dex/devices/aggregates/live/index.ts | 13 +- .../dex/devices/aggregates/over-time/get.ts | 82 +- .../dex/devices/aggregates/over-time/index.ts | 13 +- .../_generated/zero-trust/dex/devices/get.ts | 81 +- .../zero-trust/dex/devices/index.ts | 21 +- .../_generated/zero-trust/dex/devices/list.ts | 154 +- .../zero-trust/dex/devices/over-time/get.ts | 90 +- .../zero-trust/dex/devices/over-time/index.ts | 13 +- .../_generated/zero-trust/dex/index.ts | 31 +- .../_generated/zero-trust/dex/isps/index.ts | 13 +- .../_generated/zero-trust/dex/isps/list.ts | 120 +- .../zero-trust/dex/overview/index.ts | 15 +- .../zero-trust/dex/overview/tests/index.ts | 17 +- .../zero-trust/dex/overview/tests/list.ts | 111 +- .../dex/overview/tests/unique-devices/get.ts | 64 +- .../overview/tests/unique-devices/index.ts | 13 +- .../_generated/zero-trust/dex/rules/create.ts | 74 +- .../_generated/zero-trust/dex/rules/delete.ts | 54 +- .../_generated/zero-trust/dex/rules/get.ts | 50 +- .../_generated/zero-trust/dex/rules/index.ts | 23 +- .../_generated/zero-trust/dex/rules/list.ts | 85 +- .../_generated/zero-trust/dex/rules/update.ts | 85 +- .../zero-trust/dex/test-results/http/get.ts | 102 +- .../zero-trust/dex/test-results/http/index.ts | 17 +- .../dex/test-results/http/percentiles/get.ts | 96 +- .../test-results/http/percentiles/index.ts | 13 +- .../zero-trust/dex/test-results/index.ts | 17 +- .../dex/test-results/traceroute/get.ts | 102 +- .../dex/test-results/traceroute/index.ts | 19 +- .../traceroute/network-path/get.ts | 51 +- .../traceroute/network-path/index.ts | 13 +- .../traceroute/percentiles/get.ts | 96 +- .../traceroute/percentiles/index.ts | 13 +- .../_generated/zero-trust/dex/tests/create.ts | 134 +- .../_generated/zero-trust/dex/tests/delete.ts | 57 +- .../_generated/zero-trust/dex/tests/get.ts | 51 +- .../_generated/zero-trust/dex/tests/index.ts | 25 +- .../_generated/zero-trust/dex/tests/list.ts | 74 +- .../zero-trust/dex/tests/network-path/get.ts | 88 +- .../dex/tests/network-path/index.ts | 13 +- .../_generated/zero-trust/dex/tests/update.ts | 145 +- .../dex/warp-change-events/index.ts | 13 +- .../zero-trust/dex/warp-change-events/list.ts | 132 +- .../dlp/custom-prompt-topics/create.ts | 82 +- .../dlp/custom-prompt-topics/delete.ts | 51 +- .../dlp/custom-prompt-topics/get.ts | 45 +- .../dlp/custom-prompt-topics/index.ts | 23 +- .../dlp/custom-prompt-topics/list.ts | 40 +- .../dlp/custom-prompt-topics/update.ts | 77 +- .../zero-trust/dlp/data-classes/create.ts | 101 +- .../zero-trust/dlp/data-classes/delete.ts | 53 +- .../zero-trust/dlp/data-classes/get.ts | 47 +- .../zero-trust/dlp/data-classes/index.ts | 23 +- .../zero-trust/dlp/data-classes/list.ts | 40 +- .../zero-trust/dlp/data-classes/update.ts | 108 +- .../dlp/data-tag-categories/create.ts | 89 +- .../dlp/data-tag-categories/delete.ts | 53 +- .../zero-trust/dlp/data-tag-categories/get.ts | 47 +- .../dlp/data-tag-categories/index.ts | 23 +- .../dlp/data-tag-categories/list.ts | 40 +- .../dlp/data-tag-categories/update.ts | 86 +- .../dlp/data-tag-category-templates/get.ts | 47 +- .../dlp/data-tag-category-templates/index.ts | 17 +- .../dlp/data-tag-category-templates/list.ts | 40 +- .../zero-trust/dlp/data-tags/create.ts | 74 +- .../zero-trust/dlp/data-tags/delete.ts | 57 +- .../zero-trust/dlp/data-tags/get.ts | 51 +- .../zero-trust/dlp/data-tags/index.ts | 23 +- .../zero-trust/dlp/data-tags/list.ts | 43 +- .../zero-trust/dlp/data-tags/update.ts | 78 +- .../zero-trust/dlp/datasets/create.ts | 93 +- .../zero-trust/dlp/datasets/delete.ts | 51 +- .../_generated/zero-trust/dlp/datasets/get.ts | 45 +- .../zero-trust/dlp/datasets/index.ts | 27 +- .../zero-trust/dlp/datasets/list.ts | 40 +- .../zero-trust/dlp/datasets/prepare-upload.ts | 45 +- .../zero-trust/dlp/datasets/update.ts | 82 +- .../zero-trust/dlp/datasets/upload.ts | 75 +- .../dlp/document-fingerprints/create.ts | 78 +- .../dlp/document-fingerprints/delete.ts | 57 +- .../dlp/document-fingerprints/get.ts | 51 +- .../dlp/document-fingerprints/index.ts | 25 +- .../dlp/document-fingerprints/list.ts | 40 +- .../dlp/document-fingerprints/update.ts | 88 +- .../dlp/document-fingerprints/upload.ts | 71 +- .../dlp/email/account-mapping/create.ts | 75 +- .../dlp/email/account-mapping/get.ts | 40 +- .../dlp/email/account-mapping/index.ts | 17 +- .../_generated/zero-trust/dlp/email/index.ts | 17 +- .../zero-trust/dlp/email/rules/bulk-edit.ts | 62 +- .../zero-trust/dlp/email/rules/create.ts | 102 +- .../zero-trust/dlp/email/rules/delete.ts | 51 +- .../zero-trust/dlp/email/rules/get.ts | 45 +- .../zero-trust/dlp/email/rules/index.ts | 25 +- .../zero-trust/dlp/email/rules/list.ts | 40 +- .../zero-trust/dlp/email/rules/update.ts | 107 +- .../zero-trust/dlp/entries/create.ts | 112 +- .../zero-trust/dlp/entries/delete.ts | 51 +- .../_generated/zero-trust/dlp/entries/get.ts | 45 +- .../zero-trust/dlp/entries/index.ts | 23 +- .../_generated/zero-trust/dlp/entries/list.ts | 40 +- .../zero-trust/dlp/entries/update.ts | 52 +- .../_generated/zero-trust/dlp/index.ts | 47 +- .../_generated/zero-trust/dlp/limits/index.ts | 13 +- .../_generated/zero-trust/dlp/limits/list.ts | 40 +- .../zero-trust/dlp/patterns/index.ts | 15 +- .../zero-trust/dlp/patterns/validate.ts | 69 +- .../zero-trust/dlp/profiles/custom/create.ts | 177 ++- .../zero-trust/dlp/profiles/custom/delete.ts | 51 +- .../zero-trust/dlp/profiles/custom/index.ts | 19 +- .../zero-trust/dlp/profiles/custom/update.ts | 184 +-- .../_generated/zero-trust/dlp/profiles/get.ts | 45 +- .../zero-trust/dlp/profiles/index.ts | 21 +- .../zero-trust/dlp/profiles/list.ts | 47 +- .../dlp/profiles/predefined/index.ts | 15 +- .../dlp/profiles/predefined/update.ts | 123 +- .../dlp/sensitivity-group-templates/get.ts | 47 +- .../dlp/sensitivity-group-templates/index.ts | 17 +- .../dlp/sensitivity-group-templates/list.ts | 40 +- .../dlp/sensitivity-groups/create.ts | 89 +- .../dlp/sensitivity-groups/delete.ts | 57 +- .../dlp/sensitivity-groups/get-level-order.ts | 51 +- .../zero-trust/dlp/sensitivity-groups/get.ts | 51 +- .../dlp/sensitivity-groups/index.ts | 27 +- .../zero-trust/dlp/sensitivity-groups/list.ts | 40 +- .../sensitivity-groups/update-level-order.ts | 73 +- .../dlp/sensitivity-groups/update.ts | 90 +- .../dlp/sensitivity-levels/create.ts | 78 +- .../dlp/sensitivity-levels/delete.ts | 67 +- .../zero-trust/dlp/sensitivity-levels/get.ts | 61 +- .../dlp/sensitivity-levels/index.ts | 23 +- .../zero-trust/dlp/sensitivity-levels/list.ts | 50 +- .../dlp/sensitivity-levels/update.ts | 88 +- .../zero-trust/dlp/settings/delete.ts | 46 +- .../zero-trust/dlp/settings/edit.ts | 92 +- .../_generated/zero-trust/dlp/settings/get.ts | 40 +- .../zero-trust/dlp/settings/index.ts | 21 +- .../zero-trust/dlp/settings/update.ts | 92 +- .../zero-trust/dlp/validators/get.ts | 47 +- .../zero-trust/dlp/validators/index.ts | 21 +- .../zero-trust/dlp/validators/list.ts | 48 +- .../dlp/validators/proximity-words/create.ts | 72 +- .../dlp/validators/proximity-words/delete.ts | 53 +- .../dlp/validators/proximity-words/get.ts | 47 +- .../dlp/validators/proximity-words/index.ts | 23 +- .../dlp/validators/proximity-words/list.ts | 40 +- .../dlp/validators/proximity-words/update.ts | 79 +- .../dlp/validators/worker/create.ts | 82 +- .../dlp/validators/worker/delete.ts | 53 +- .../zero-trust/dlp/validators/worker/get.ts | 47 +- .../zero-trust/dlp/validators/worker/index.ts | 25 +- .../zero-trust/dlp/validators/worker/list.ts | 40 +- .../dlp/validators/worker/status/get.ts | 47 +- .../dlp/validators/worker/status/index.ts | 13 +- .../dlp/validators/worker/update.ts | 89 +- .../zero-trust/gateway/app-types/index.ts | 13 +- .../zero-trust/gateway/app-types/list.ts | 40 +- .../zero-trust/gateway/categories/index.ts | 13 +- .../zero-trust/gateway/categories/list.ts | 37 +- .../gateway/certificates/activate.ts | 51 +- .../zero-trust/gateway/certificates/create.ts | 72 +- .../gateway/certificates/deactivate.ts | 51 +- .../zero-trust/gateway/certificates/delete.ts | 57 +- .../zero-trust/gateway/certificates/get.ts | 51 +- .../zero-trust/gateway/certificates/index.ts | 25 +- .../zero-trust/gateway/certificates/list.ts | 40 +- .../zero-trust/gateway/configurations/edit.ts | 420 +++--- .../zero-trust/gateway/configurations/get.ts | 40 +- .../gateway/configurations/index.ts | 19 +- .../gateway/configurations/update.ts | 420 +++--- .../_generated/zero-trust/gateway/create.ts | 40 +- .../gateway/dns-destination-ips/index.ts | 13 +- .../gateway/dns-destination-ips/list.ts | 40 +- .../_generated/zero-trust/gateway/index.ts | 39 +- .../_generated/zero-trust/gateway/list.ts | 40 +- .../zero-trust/gateway/lists/create.ts | 86 +- .../zero-trust/gateway/lists/delete.ts | 57 +- .../zero-trust/gateway/lists/edit.ts | 85 +- .../zero-trust/gateway/lists/get.ts | 51 +- .../zero-trust/gateway/lists/index.ts | 27 +- .../zero-trust/gateway/lists/items/index.ts | 13 +- .../zero-trust/gateway/lists/items/list.ts | 70 +- .../zero-trust/gateway/lists/list.ts | 93 +- .../zero-trust/gateway/lists/update.ts | 90 +- .../zero-trust/gateway/locations/create.ts | 210 +-- .../zero-trust/gateway/locations/delete.ts | 53 +- .../zero-trust/gateway/locations/get.ts | 47 +- .../zero-trust/gateway/locations/index.ts | 23 +- .../zero-trust/gateway/locations/list.ts | 82 +- .../zero-trust/gateway/locations/update.ts | 220 +-- .../zero-trust/gateway/logging/get.ts | 40 +- .../zero-trust/gateway/logging/index.ts | 17 +- .../zero-trust/gateway/logging/update.ts | 114 +- .../zero-trust/gateway/pacfiles/create.ts | 89 +- .../zero-trust/gateway/pacfiles/delete.ts | 51 +- .../zero-trust/gateway/pacfiles/get.ts | 45 +- .../zero-trust/gateway/pacfiles/index.ts | 23 +- .../zero-trust/gateway/pacfiles/list.ts | 60 +- .../zero-trust/gateway/pacfiles/update.ts | 82 +- .../gateway/proxy-endpoints/create.ts | 61 +- .../gateway/proxy-endpoints/delete.ts | 57 +- .../gateway/proxy-endpoints/edit.ts | 83 +- .../zero-trust/gateway/proxy-endpoints/get.ts | 51 +- .../gateway/proxy-endpoints/index.ts | 23 +- .../gateway/proxy-endpoints/list.ts | 82 +- .../zero-trust/gateway/rules/create.ts | 851 ++++++----- .../zero-trust/gateway/rules/delete.ts | 57 +- .../zero-trust/gateway/rules/get.ts | 51 +- .../zero-trust/gateway/rules/index.ts | 27 +- .../zero-trust/gateway/rules/list-tenant.ts | 40 +- .../zero-trust/gateway/rules/list.ts | 82 +- .../gateway/rules/reset-expiration.ts | 51 +- .../zero-trust/gateway/rules/update.ts | 867 ++++++----- .../zero-trust/identity-providers/create.ts | 50 +- .../zero-trust/identity-providers/delete.ts | 53 +- .../federation-grants/create.ts | 62 +- .../federation-grants/delete.ts | 57 +- .../federation-grants/get.ts | 51 +- .../federation-grants/index.ts | 21 +- .../federation-grants/list.ts | 40 +- .../zero-trust/identity-providers/get.ts | 47 +- .../zero-trust/identity-providers/index.ts | 29 +- .../zero-trust/identity-providers/list.ts | 69 +- .../saml-certificate/create.ts | 47 +- .../saml-certificate/index.ts | 15 +- .../identity-providers/scim/groups/delete.ts | 57 +- .../identity-providers/scim/groups/get.ts | 51 +- .../identity-providers/scim/groups/index.ts | 19 +- .../identity-providers/scim/groups/list.ts | 99 +- .../identity-providers/scim/index.ts | 17 +- .../identity-providers/scim/users/delete.ts | 57 +- .../identity-providers/scim/users/get.ts | 51 +- .../identity-providers/scim/users/index.ts | 19 +- .../identity-providers/scim/users/list.ts | 119 +- .../zero-trust/identity-providers/update.ts | 57 +- .../commands/_generated/zero-trust/index.ts | 41 +- .../zero-trust/organization/create.ts | 383 ++--- .../zero-trust/organization/doh/get.ts | 40 +- .../zero-trust/organization/doh/index.ts | 17 +- .../zero-trust/organization/doh/update.ts | 72 +- .../zero-trust/organization/edit.ts | 410 ++--- .../_generated/zero-trust/organization/get.ts | 40 +- .../zero-trust/organization/index.ts | 25 +- .../organization/trust-settings/delete.ts | 46 +- .../organization/trust-settings/get.ts | 40 +- .../organization/trust-settings/index.ts | 21 +- .../organization/trust-settings/replace.ts | 69 +- .../organization/trust-settings/update.ts | 69 +- .../zero-trust/organization/update.ts | 410 ++--- .../_generated/zero-trust/region/delete.ts | 46 +- .../_generated/zero-trust/region/get.ts | 40 +- .../_generated/zero-trust/region/index.ts | 19 +- .../_generated/zero-trust/region/update.ts | 60 +- .../_generated/zero-trust/regions/index.ts | 13 +- .../_generated/zero-trust/regions/list.ts | 40 +- .../zero-trust/risk-scoring/behaviours/get.ts | 40 +- .../risk-scoring/behaviours/index.ts | 17 +- .../risk-scoring/behaviours/update.ts | 62 +- .../_generated/zero-trust/risk-scoring/get.ts | 45 +- .../zero-trust/risk-scoring/index.ts | 23 +- .../risk-scoring/integrations/create.ts | 84 +- .../risk-scoring/integrations/delete.ts | 53 +- .../risk-scoring/integrations/get.ts | 47 +- .../risk-scoring/integrations/index.ts | 25 +- .../risk-scoring/integrations/list.ts | 40 +- .../integrations/references/get.ts | 47 +- .../integrations/references/index.ts | 13 +- .../risk-scoring/integrations/update.ts | 85 +- .../zero-trust/risk-scoring/reset.ts | 51 +- .../zero-trust/risk-scoring/summary/get.ts | 40 +- .../zero-trust/risk-scoring/summary/index.ts | 13 +- .../_generated/zero-trust/users/index.ts | 17 +- .../users/mfa/authenticators/delete.ts | 63 +- .../users/mfa/authenticators/index.ts | 15 +- .../_generated/zero-trust/users/mfa/index.ts | 15 +- .../zero-trust/users/passkeys/delete.ts | 63 +- .../zero-trust/users/passkeys/index.ts | 15 +- .../zones/activation-check/activate.ts | 40 +- .../zones/activation-check/index.ts | 15 +- .../commands/_generated/zones/aegis/delete.ts | 46 +- .../commands/_generated/zones/aegis/edit.ts | 67 +- .../commands/_generated/zones/aegis/get.ts | 40 +- .../commands/_generated/zones/aegis/index.ts | 19 +- .../automatic-platform-optimization/edit.ts | 114 +- .../automatic-platform-optimization/get.ts | 40 +- .../automatic-platform-optimization/index.ts | 17 +- .../_generated/zones/binary-ast/edit.ts | 60 +- .../_generated/zones/binary-ast/get.ts | 40 +- .../_generated/zones/binary-ast/index.ts | 17 +- .../src/commands/_generated/zones/create.ts | 78 +- .../src/commands/_generated/zones/delete.ts | 43 +- .../cli/src/commands/_generated/zones/edit.ts | 88 +- .../commands/_generated/zones/fonts/edit.ts | 60 +- .../commands/_generated/zones/fonts/get.ts | 40 +- .../commands/_generated/zones/fonts/index.ts | 17 +- .../cli/src/commands/_generated/zones/get.ts | 40 +- .../zones/h2-prioritization/edit.ts | 60 +- .../_generated/zones/h2-prioritization/get.ts | 40 +- .../zones/h2-prioritization/index.ts | 17 +- .../commands/_generated/zones/holds/create.ts | 47 +- .../commands/_generated/zones/holds/delete.ts | 56 +- .../commands/_generated/zones/holds/edit.ts | 67 +- .../commands/_generated/zones/holds/get.ts | 40 +- .../commands/_generated/zones/holds/index.ts | 21 +- .../_generated/zones/hostnames/index.ts | 15 +- .../zones/hostnames/settings/index.ts | 17 +- .../hostnames/settings/tls-single/get.ts | 63 +- .../hostnames/settings/tls-single/index.ts | 13 +- .../zones/hostnames/settings/tls/delete.ts | 67 +- .../zones/hostnames/settings/tls/get.ts | 95 +- .../zones/hostnames/settings/tls/index.ts | 19 +- .../zones/hostnames/settings/tls/update.ts | 73 +- .../_generated/zones/image-resizing/edit.ts | 60 +- .../_generated/zones/image-resizing/get.ts | 40 +- .../_generated/zones/image-resizing/index.ts | 17 +- .../src/commands/_generated/zones/index.ts | 65 +- .../cli/src/commands/_generated/zones/list.ts | 149 +- .../zones/origin-h2-max-streams/edit.ts | 60 +- .../zones/origin-h2-max-streams/get.ts | 40 +- .../zones/origin-h2-max-streams/index.ts | 17 +- .../zones/origin-max-http-version/edit.ts | 60 +- .../zones/origin-max-http-version/get.ts | 40 +- .../zones/origin-max-http-version/index.ts | 17 +- .../origin-tls-compliance-modes/delete.ts | 46 +- .../zones/origin-tls-compliance-modes/edit.ts | 64 +- .../zones/origin-tls-compliance-modes/get.ts | 40 +- .../origin-tls-compliance-modes/index.ts | 21 +- .../origin-tls-compliance-modes/update.ts | 64 +- .../commands/_generated/zones/plans/get.ts | 47 +- .../commands/_generated/zones/plans/index.ts | 17 +- .../commands/_generated/zones/plans/list.ts | 40 +- .../_generated/zones/rate-plans/index.ts | 13 +- .../_generated/zones/rate-plans/list.ts | 40 +- .../src/commands/_generated/zones/rum/edit.ts | 57 +- .../src/commands/_generated/zones/rum/get.ts | 37 +- .../commands/_generated/zones/rum/index.ts | 17 +- .../_generated/zones/settings/edit.ts | 245 +-- .../commands/_generated/zones/settings/get.ts | 47 +- .../_generated/zones/settings/index.ts | 17 +- .../_generated/zones/speed-brain/edit.ts | 60 +- .../_generated/zones/speed-brain/get.ts | 40 +- .../_generated/zones/speed-brain/index.ts | 17 +- .../_generated/zones/subscriptions/create.ts | 153 +- .../_generated/zones/subscriptions/delete.ts | 43 +- .../_generated/zones/subscriptions/get.ts | 37 +- .../_generated/zones/subscriptions/index.ts | 21 +- .../_generated/zones/subscriptions/update.ts | 153 +- .../transformations-allowed-origins/edit.ts | 62 +- .../transformations-allowed-origins/get.ts | 40 +- .../transformations-allowed-origins/index.ts | 17 +- .../zones/transformations-c2pa/edit.ts | 60 +- .../zones/transformations-c2pa/get.ts | 40 +- .../zones/transformations-c2pa/index.ts | 17 +- .../zones/transformations-config/edit.ts | 87 +- .../zones/transformations-config/get.ts | 40 +- .../zones/transformations-config/index.ts | 17 +- packages/cli/src/lib/api-command.ts | 290 ++++ packages/cli/src/lib/cli-types.ts | 10 +- packages/cli/src/lib/stricli.ts | 301 ++-- scripts/compare-cli-parity.mjs | 8 + 4163 files changed, 143615 insertions(+), 147549 deletions(-) create mode 100644 packages/cli/src/lib/api-command.ts diff --git a/docs/architecture.md b/docs/architecture.md index 756fac97ad..25e24c89eb 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -155,7 +155,7 @@ the document; the command generator is a forge plugin that lives here, in WebAssembly component that forge runs. It walks forge's model of the operations, each top-level group's commands in turn, and emits: -- `src/commands/_generated///.ts` — yargs command modules +- `src/commands/_generated///.ts` — Stricli API command declarations - `src/commands/_generated/_operations///.ts` — one module per method, at its path in the group tree, whose default export is its `Operation` (`d1.database.query` in `_operations/d1/database/query.ts`); @@ -363,7 +363,7 @@ Vite+ Pack preserves those dynamic root imports as code-split chunks (and may fa ### Generator output (DO NOT EDIT) -- `packages/cli/src/commands/_generated/` — yargs modules, `_operations/` +- `packages/cli/src/commands/_generated/` — Stricli command and route-map modules, `_operations/` operation literals, and `_meta/` JSON Tracked in git and never safe to patch by hand. Every `pnpm generate` cleans, rewrites, and Vite+-formats `_generated/`. Make changes in Forge's OpenAPI or in the generator plugin (`packages/cli/generator/plugin/`), then regenerate and commit the resulting artifacts. @@ -757,7 +757,7 @@ break at sunset; surfacing them encourages users to adopt doomed paths. ### Argument parsing -`src/lib/stricli.ts` collects the selected command’s builder declarations, resolves aliases, and constructs a Stricli command for the flags and positionals. Unknown options are rejected before startup unless the command explicitly accepts dynamic flags or forwards arguments. Keep the declarations authoritative; do not add product-specific allowlists to the parser. Generated and hand-written modules retain the yargs builder **types**, not the runtime dependency. +`src/lib/api-command.ts` builds Stricli commands and route maps from generated declarations. Flag kinds, parsers, defaults, variadic flags, and named operands determine generated handler input types. `src/lib/stricli.ts` preserves cf help, error messages, aliases, and token spellings that Stricli does not accept natively. Hand-written commands can still use builder declarations and yargs types; neither path loads the yargs runtime. Unknown options are rejected before startup unless a command explicitly accepts or forwards them. ### Output diff --git a/packages/cli/AGENTS.md b/packages/cli/AGENTS.md index d44e9846c8..3f019e73c8 100644 --- a/packages/cli/AGENTS.md +++ b/packages/cli/AGENTS.md @@ -1,6 +1,6 @@ # cf (`packages/cli`) -Cloudflare CLI. Stricli runtime with yargs-compatible command declarations, TypeScript, ESM, Node ≥ 22. +Cloudflare CLI. Native Stricli declarations for generated commands, a compatibility builder for hand-written commands, TypeScript, ESM, Node ≥ 22. This package IS the CLI. It also owns the generator that produces its per-API command surface: the forge plugin in `generator/plugin/`, which @@ -181,7 +181,7 @@ cf resolves account parameters itself. ## Generated (DO NOT EDIT) -- `src/commands/_generated/` — yargs command files, `_operations/` operation +- `src/commands/_generated/` — Stricli command and route-map files, `_operations/` operation literals, and `_meta/*.json` The output is tracked in git, owned by `pnpm generate`, and must not be hand-edited. Shell-completion scripts are no longer generated — `cf complete` (backed by `@bomb.sh/tab`) reads the complete generated and hand-written command tree from `_meta/commands.json`. `_meta/hand-written-commands.json` republishes the hand-written subset with root/leaf/subgroup/override provenance. diff --git a/packages/cli/generator/plugin/emit/builder.ts b/packages/cli/generator/plugin/emit/builder.ts index 14aa27bd83..a901428f5b 100644 --- a/packages/cli/generator/plugin/emit/builder.ts +++ b/packages/cli/generator/plugin/emit/builder.ts @@ -1,4 +1,3 @@ -/** Emits a command's yargs builder: a port of cf's `emit/builder.ts`. */ import { fileFormat, hasChoices, @@ -12,16 +11,6 @@ import { import { kebab, obj, stringify, type Value } from "../js.js"; import { type Ctx, escapeSingle } from "./index.js"; -function option(name: string, fields: [string, Value | undefined][]): string { - const map = obj(); - for (const [k, v] of fields) { - if (v !== undefined) { - map[k] = v; - } - } - return `.option('${name}', ${stringify(map)})`; -} - const quoted = (v: readonly string[]) => v.map((c) => `'${c}'`).join(", "); export const JSON_BODY_DESCRIPTION = @@ -44,29 +33,51 @@ export function bodyOptionDescription(op: Ctx["op"]): string { : JSON_BODY_DESCRIPTION; } -/** `generateBuilderLines`. */ -export function builderLines(ctx: Ctx): string[] { +export function parameterSource(ctx: Ctx) { const d = ctx.derived; const op = ctx.op; const positional = positionals(d); const options = optionArgs(d); const defaults = optionDefaults(d, op); - const lines: string[] = []; + const flags = new Map(); + const operands: string[] = []; + const rules: string[] = []; + function emitFlag( + name: string, + type: string, + description: string, + extras: Record = {}, + coerce?: string + ) { + const { choices, array, required, ...rest } = extras; + const nativeEnum = + type === "string" && Array.isArray(choices) && choices.length && !coerce; + const kind = + type === "boolean" ? "boolean" : nativeEnum ? "enum" : "parsed"; + const spec = obj([ + ["kind", kind], + ["brief", description], + ]); + if (nativeEnum) spec.values = choices; + if (array) spec.variadic = true; + if (!required && rest.default === undefined) spec.optional = true; + for (const [key, value] of Object.entries(rest)) + if (value !== undefined) spec[key] = value; + if (!nativeEnum && choices !== undefined) spec.choices = choices; + if (kind === "parsed" && spec.default !== undefined) + spec.default = String(spec.default); + const properties = [stringify(spec).slice(1, -1)]; + if (kind === "parsed") + properties.push(`parse: ${type === "number" ? "Number" : "String"}`); + if (coerce) properties.push(`coerce: ${coerce}`); + flags.set(name, `${stringify(name)}: {${properties.join(", ")}},`); + } for (const arg of positional) { - lines.push(` .positional('${kebab(arg.name)}', {`); - lines.push( - ` type: '${arg.type === "number" || arg.type === "boolean" ? arg.type : "string"}',` - ); - if (arg.type === "array") { - lines.push(" array: true,"); - } const base = escapeSingle(arg.description); const desc = arg.isZone ? `${base} (or use --zone flag)` : base; - lines.push(` description: '${desc}',`); - if (arg.required && !arg.isZone && !arg.isWorkerName) { - lines.push(" demandOption: true,"); - } - lines.push(" })"); + operands.push( + `{placeholder: '${kebab(arg.name)}', brief: '${desc}', parse: ${arg.type === "number" ? "Number" : "String"}, ${arg.required && !arg.isZone && !arg.isWorkerName ? "" : "optional: true,"} ${arg.type === "array" ? "rest: true," : ""}${arg.type === "boolean" ? "booleanLabel: true," : ""}},` + ); } for (const arg of options) { const name = kebab(arg.name); @@ -84,17 +95,7 @@ export function builderLines(ctx: Ctx): string[] { : "string"; const demand = arg.required && !arg.isZone && !arg.isWorkerName && !skipDemand; - lines.push( - option(name, [ - ["type", type], - ["array", scalarArray ? true : undefined], - ["alias", arg.isWorkerName ? WORKER_ALIASES : undefined], - ["description", arg.description], - ["choices", arg.choices], - ["default", defaults.get(arg.name)], - ["demandOption", demand ? true : undefined], - ]) - ); + let coerce: string | undefined; if (scalarArray && arg.origin.in === "query" && hasChoices(arg)) { const commaChoices = arg.choices?.filter((value) => value.includes(",")) ?? []; @@ -102,45 +103,59 @@ export function builderLines(ctx: Ctx): string[] { commaChoices.length > 0 ? `${stringify(commaChoices)}.includes(value) ? [value] : value.split(",")` : 'value.split(",")'; - lines.push( - `.coerce(${stringify(name)}, (values: string[]) => values.flatMap((value) => ${split}))` - ); + coerce = `(values: string[]) => values.flatMap((value) => ${split})`; } - if (arg.isWorkerName && arg.positional) { - lines.push(`.group(${stringify(name)}, theme.brand('Options'))`); - } - // Resolve `@file` before yargs validates `choices` against the value, + // Resolve `@file` before cf validates `choices` against the value, // so the handler gets the file's contents without reading it twice. if (arg.fromFile !== undefined && hasChoices(arg)) { - lines.push( - `.coerce(${stringify(name)}, (value) => resolveFileToken(value, ${stringify(name)}, ${fileFormat(arg)}))` - ); + coerce = `(value: string) => resolveFileToken(value, ${stringify(name)}, ${fileFormat(arg)})`; } + emitFlag( + name, + type, + arg.description, + { + array: scalarArray, + required: demand, + choices: arg.choices, + default: defaults.get(arg.name), + alias: arg.isWorkerName ? WORKER_ALIASES : undefined, + grouped: (arg.isWorkerName && arg.positional) || undefined, + }, + coerce + ); } - lines.push( - `.option("dry-run", {"type":"boolean","description":"Validate and show what would happen without executing","default":false})` + emitFlag( + "dry-run", + "boolean", + "Validate and show what would happen without executing", + { default: false } ); if (ctx.isDelete) { - lines.push( - `.option("force", {"type":"boolean","alias":"f","description":"Skip confirmation (useful in scripts and CI)","default":false})` + emitFlag( + "force", + "boolean", + "Skip confirmation (useful in scripts and CI)", + { alias: "f", default: false } ); } if (d.hasBody) { - const desc = bodyOptionDescription(op); - lines.push(" .option('body', {"); - lines.push(" type: 'string',"); - lines.push(` description: '${escapeSingle(desc)}',`); - lines.push(" })"); + emitFlag( + "body", + "string", + bodyOptionDescription(op).replace(/[\r\n\u2028\u2029]/g, " ") + ); } if (ctx.outputKind === "binary") { - lines.push( - `.option("text", {"type":"boolean","description":"Decode the response body as UTF-8 text instead of writing raw bytes","default":false})` + emitFlag( + "text", + "boolean", + "Decode the response body as UTF-8 text instead of writing raw bytes", + { default: false } ); } if (d.hasFileUpload) { - lines.push( - `.option("file", {"type":"string","description":"Path to a file to upload as the request body"})` - ); + emitFlag("file", "string", "Path to a file to upload as the request body"); } for (const { field, flag } of d.multipartFlagFields) { if ([...options, ...positional].some((a) => kebab(a.name) === flag)) { @@ -152,20 +167,13 @@ export function builderLines(ctx: Ctx): string[] { : field.type === "boolean" ? "boolean" : "string"; - lines.push(` .option('${flag}', {`); - lines.push(` type: '${type}',`); - lines.push(` description: '${escapeSingle(field.description)}',`); - lines.push(" })"); + emitFlag(flag, type, field.description.replace(/[\r\n\u2028\u2029]/g, " ")); } for (const { field, flag } of d.multipartFileFields) { - lines.push( - option(flag, [ - ["type", "string"], - ["array", field.type === "array" ? true : undefined], - ["requiresArg", field.type === "array" ? true : undefined], - ["description", multipartFileFlagDescription(field)], - ]) - ); + emitFlag(flag, "string", multipartFileFlagDescription(field), { + array: field.type === "array", + requiresArg: field.type === "array" || undefined, + }); } for (const arg of d.args) { if (!isBody(arg) || arg.positional) { @@ -173,13 +181,13 @@ export function builderLines(ctx: Ctx): string[] { } const me = kebab(arg.name); if (arg.conflicts !== undefined && arg.conflicts.length > 0) { - lines.push( - ` .conflicts('${me}', [${quoted(arg.conflicts.map(kebab))}])` + rules.push( + `rules.conflicts('${me}', [${quoted(arg.conflicts.map(kebab))}]);` ); } if (arg.implies !== undefined && arg.implies.length > 0) { - lines.push( - ` .implies('${me}', [${quoted(arg.implies.map(kebab))}])` + rules.push( + `rules.implies('${me}', [${quoted(arg.implies.map(kebab))}]);` ); } } @@ -222,32 +230,38 @@ export function builderLines(ctx: Ctx): string[] { conflictsByFlag.find(([k]) => k === f)?.[1] ?? [], ]) .filter(([, c]) => c.length > 0); - lines.push(" .check((argv) => {"); - lines.push( + rules.push("rules.check((argv) => {"); + rules.push( ` const groupSet = ${set}.some((k) => argv[k] !== undefined);` ); - lines.push(" if (!argv.body && groupSet) {"); + rules.push(" if (!argv.body && groupSet) {"); if (pairs.length === 0) { - lines.push( + rules.push( ` const missing = ${required}.filter((k) => argv[k] === undefined);` ); } else { const map = pairs.map(([f, c]) => `'${f}': [${quoted(c)}]`).join(", "); - lines.push( + rules.push( ` const requiredConflicts: Record = { ${map} };` ); - lines.push( + rules.push( ` const missing = ${required}.filter((k) => argv[k] === undefined && !(requiredConflicts[k] ?? []).some((x) => argv[x] !== undefined));` ); } - lines.push(" if (missing.length > 0) {"); - lines.push( + rules.push(" if (missing.length > 0) {"); + rules.push( ` throw new Error(\`\${missing.map((m) => '--' + m).join(', ')} \${missing.length === 1 ? 'is' : 'are'} required when ${groupFlags} is set\`);` ); - lines.push(" }"); - lines.push(" }"); - lines.push(" return true;"); - lines.push(" })"); + rules.push(" }"); + rules.push(" }"); + rules.push(" return true;"); + rules.push("});"); } - return lines; + return [ + `flags: {`, + ...flags.values(), + `},`, + `operands: [${operands.join("\n")}],`, + ...(rules.length ? [`rules(rules) {`, ...rules, `},`] : []), + ]; } diff --git a/packages/cli/generator/plugin/emit/handler.ts b/packages/cli/generator/plugin/emit/handler.ts index 1900543aeb..4a62bd6217 100644 --- a/packages/cli/generator/plugin/emit/handler.ts +++ b/packages/cli/generator/plugin/emit/handler.ts @@ -1162,8 +1162,7 @@ export function imports(ctx: Ctx): Imports { const d = ctx.derived; const i = new Imports(); const lib = "#lib"; - i.typeFrom("yargs", ["Argv", "CommandModule"]); - i.typeFrom(`${lib}/cli-types.js`, ["CommonYargsOptions", "InferArgs"]); + i.from(`${lib}/api-command.js`, ["apiCommand"]); const authNames = ["createCommandClient"]; if (ctx.needsAccountId) { authNames.push("getAccountId", "resolveAccountIdSilent"); @@ -1183,9 +1182,6 @@ export function imports(ctx: Ctx): Imports { } i.from(`${lib}/output.js`, ["formatOutput"]); i.from(`${lib}/dry-run.js`, ["formatDryRun"]); - if (positionals(d).some((arg) => arg.isWorkerName)) { - i.from(`${lib}/ui/theme.js`, ["theme"]); - } if ((ctx.op.bodyUnions?.length ?? 0) > 0 && d.hasBodyParams) { i.from(`${lib}/body-unions.js`, ["validateBodyUnions"]); } diff --git a/packages/cli/generator/plugin/files.ts b/packages/cli/generator/plugin/files.ts index 36c63c39b8..beda350b30 100644 --- a/packages/cli/generator/plugin/files.ts +++ b/packages/cli/generator/plugin/files.ts @@ -21,7 +21,7 @@ import { import { requiresConfirmation } from "./confirmation.js"; import { bodyOptionDescription, - builderLines, + parameterSource, isPlainTextBody, JSON_BODY_DESCRIPTION, } from "./emit/builder.js"; @@ -475,7 +475,7 @@ class Walk { ); const handlerLines = handler(ctx); const importSet = imports(ctx); - const builder = builderLines(ctx); + const parameters = parameterSource(ctx); const usage = leafUsage( method, resource, @@ -483,12 +483,10 @@ class Walk { command, ctx.hasAccountOrZoneScope ); - const builderBody = `return yargs\n .usage(${quote(usage)})\n${builder.join("\n")};`; const declarations = - "type Args = InferArgs;\n" + - ((op.bodyUnions?.length ?? 0) > 0 && ctx.derived.hasBodyParams + (op.bodyUnions?.length ?? 0) > 0 && ctx.derived.hasBodyParams ? `const bodyUnions: Parameters[1] = ${stringify(op.bodyUnions ?? [])};\n` - : ""); + : ""; const telemetryPath = group !== undefined && group !== "" ? `${resource} ${group.replaceAll("/", " ")} ${method.name}` @@ -508,27 +506,24 @@ class Walk { */ ${importSet.render().join("\n")} -function builder(yargs: Argv) { - ${builderBody} -} - ${declarations} -const command: CommandModule = { +const command = apiCommand({ command: '${command}', describe: '${escapeSingle(summary(method))}', - builder, + usage: ${quote(usage)}, + ${parameters.join("\n")} handler: async (argv): Promise => runWithTelemetry( { command: '${escapeSingle(telemetryPath)}', - classification: { safeFlags: ${safe}${aliases} } satisfies ArgClassification, + classification: { safeFlags: ${safe}${aliases} } satisfies ArgClassification, }, argv as Record, async () => { ${handlerLines.join("\n")} }, ), -}; +}); export default command; `; @@ -669,14 +664,14 @@ export default command; // A hand-written command handles `--dry-run` by the strategy it // chose, which the index wraps it with. let wraps = false; - const register = (v: string, dryRun: DryRun | undefined) => { + const register = (name: string, v: string, dryRun: DryRun | undefined) => { if (dryRun === undefined) { - registrations.push(` .command(${v})`); + registrations.push(` '${name}': ${v},`); return; } wraps = true; registrations.push( - ` .command(withHandWrittenDryRun(${v}, '${String(dryRun)}'))` + ` '${name}': withHandWrittenDryRun(${v}, '${String(dryRun)}'),` ); }; const parent = trimEndMatches(prefix, "/"); @@ -691,7 +686,7 @@ export default command; : `./${cmd}.js`); importLines.push(`import ${v} from '${module}';`); const leaf = this.hand.leaves(parent).find((l) => l.name === cmd); - register(v, leaf?.dryRun); + register(cmd, v, leaf?.dryRun); } for (const [name, handWritten] of subgroups) { const v = `$${name.replaceAll("-", "")}`; @@ -700,7 +695,7 @@ export default command; ? `#commands/${handWritten.dir}/index.js` : `./${name}/index.js`; importLines.push(`import ${v} from '${module}';`); - register(v, handWritten?.dryRun); + register(name, v, handWritten?.dryRun); } const wrapper = wraps ? "import { withHandWrittenDryRun } from '#lib/hand-written-dry-run.js';" @@ -709,23 +704,18 @@ export default command; * ${header} * @generated from apis/overlays/${resource}.ts */ -import type { CommandModule } from 'yargs'; -import type { CommonYargsOptions } from '#lib/cli-types.js'; +import { apiGroup } from '#lib/api-command.js'; ${wrapper} ${importLines.join("\n")} -const command: CommandModule = { +const command = apiGroup({ command: '${command}', describe: '${escapeSingle(describe)}', - builder: (yargs) => { - return yargs + routes: { ${registrations.join("\n")} - .demandCommand(1, "Please specify a subcommand"); }, - - handler: () => {}, -}; +}); export default command; `; diff --git a/packages/cli/src/__tests__/commands/hand-written-leaf-commands.test.ts b/packages/cli/src/__tests__/commands/hand-written-leaf-commands.test.ts index a3c718810d..5afabbbddc 100644 --- a/packages/cli/src/__tests__/commands/hand-written-leaf-commands.test.ts +++ b/packages/cli/src/__tests__/commands/hand-written-leaf-commands.test.ts @@ -34,7 +34,7 @@ describe("hand-written leaf commands", () => { "import $run from '#commands/ai/run/index.js';" ); expect(generated).not.toContain("import $run from './run.js';"); - expect(generated).toContain(".command($run)"); + expect(generated).toContain("'run': $run,"); }); it("registers a leaf command against its generated product", () => { @@ -254,12 +254,12 @@ describe("hand-written leaf commands", () => { ); expect(generated).toContain("describe: 'Manage Worker Previews'"); if (leaves.length > 0) { - expect(generated).toContain(".command($delete)"); + expect(generated).toContain("'delete': $delete,"); } else { - expect(generated).not.toContain(".command($delete)"); + expect(generated).not.toContain("'delete': $delete,"); } expect(generated).toContain( - ".command(withHandWrittenDryRun($deploy, 'preview'))" + "'deploy': withHandWrittenDryRun($deploy, 'preview')," ); }); @@ -315,16 +315,16 @@ describe("hand-written leaf commands", () => { expect(generated).toContain( "import $delete from '#commands/workers/delete/index.js';" ); - expect(generated).toContain(".command($delete)"); + expect(generated).toContain("'delete': $delete,"); expect(generated).toContain( - ".command(withHandWrittenDryRun($check, 'preview'))" + "'check': withHandWrittenDryRun($check, 'preview')," ); expect(generated).toContain( - ".command(withHandWrittenDryRun($types, 'preview'))" + "'types': withHandWrittenDryRun($types, 'preview')," ); expect( - generated.indexOf(".command(withHandWrittenDryRun($check, 'preview'))") - ).toBeLessThan(generated.indexOf(".command($versions)")); + generated.indexOf("'check': withHandWrittenDryRun($check, 'preview'),") + ).toBeLessThan(generated.indexOf("'versions': $versions,")); }); it("splices a nested leaf into its generated group index", () => { @@ -344,11 +344,11 @@ describe("hand-written leaf commands", () => { "import $create from '#commands/workers/versions/create/index.js';" ); expect(generated).toContain( - ".command(withHandWrittenDryRun($create, 'native'))" + "'create': withHandWrittenDryRun($create, 'native')," ); expect( - generated.indexOf(".command(withHandWrittenDryRun($create, 'native'))") - ).toBeLessThan(generated.indexOf(".command($delete)")); + generated.indexOf("'create': withHandWrittenDryRun($create, 'native'),") + ).toBeLessThan(generated.indexOf("'delete': $delete,")); }); it.each([ @@ -423,7 +423,7 @@ describe("nested hand-written image leaves", () => { ); expect(output).toContain("#commands/containers/images/list/index.js"); expect(output).toContain("#commands/containers/images/delete/index.js"); - expect(output).toContain(".command($prepare)"); + expect(output).toContain("'prepare': $prepare,"); expect(handWrittenLeafCommandModule("containers/images/list")).toBe( "#commands/containers/images/list/index.js" ); diff --git a/packages/cli/src/__tests__/generator/plugin/body-description.test.ts b/packages/cli/src/__tests__/generator/plugin/body-description.test.ts index 81204126a3..d0c1d4e7ab 100644 --- a/packages/cli/src/__tests__/generator/plugin/body-description.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/body-description.test.ts @@ -5,6 +5,7 @@ import { generateFiles } from "../../helpers/cli-plugin.js"; import { commandParser } from "../../helpers/command-parser.js"; import type { CommandMeta } from "../../../lib/command-meta.js"; import type { CommandModule } from "yargs"; +import { apiCommand } from "#lib/api-command.js"; const JSON_BODY = "Raw JSON request body (bypasses individual flags)"; const PLAIN = "Send the workflow name as plain text, without JSON quotes."; @@ -41,7 +42,9 @@ async function bodyDescriptions(contentTypes: string[], description?: string) { const source = stripTypeScriptTypes(files.get("things/update.ts") ?? "") .replace(/^import[\s\S]*?;\n/gm, "") .replace("export default command;", "command;"); - const command = new Script(source).runInNewContext() as CommandModule; + const command = new Script(source).runInNewContext({ + apiCommand, + }) as CommandModule; const help = await commandParser(["update"], command).getHelp(); return { metadata: bodyDescription, help }; } diff --git a/packages/cli/src/__tests__/generator/plugin/body-positionals.test.ts b/packages/cli/src/__tests__/generator/plugin/body-positionals.test.ts index c86a04e5dc..c53fadca4a 100644 --- a/packages/cli/src/__tests__/generator/plugin/body-positionals.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/body-positionals.test.ts @@ -8,6 +8,7 @@ import { generateFiles } from "../../helpers/cli-plugin.js"; import { commandParser } from "../../helpers/command-parser.js"; import type { CommandMeta } from "../../../lib/command-meta.js"; import type { CommandModule } from "yargs"; +import { apiCommand } from "#lib/api-command.js"; function setup(code: string) { const send = vi.fn(async () => undefined); @@ -15,10 +16,11 @@ function setup(code: string) { const formatDryRun = vi.fn(); const source = stripTypeScriptTypes( code - .slice(code.indexOf("function builder")) + .replace(/^import[\s\S]*?;\n/gm, "") .replace("export default command;", "command;") ); const command = new Script(source).runInNewContext({ + apiCommand, ...bodyParser, resolveFileToken, operation: {}, diff --git a/packages/cli/src/__tests__/generator/plugin/emit.test.ts b/packages/cli/src/__tests__/generator/plugin/emit.test.ts index 51b6e9e079..65a1399b43 100644 --- a/packages/cli/src/__tests__/generator/plugin/emit.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/emit.test.ts @@ -1,7 +1,5 @@ -import { stripTypeScriptTypes } from "node:module"; -import { Script } from "node:vm"; import { describe, expect, it } from "vite-plus/test"; -import { builderLines } from "../../../../generator/plugin/emit/builder.js"; +import { parameterSource } from "../../../../generator/plugin/emit/builder.js"; import { ACCOUNT_OR_ZONE_HELP, bodyObject, @@ -26,11 +24,13 @@ import { param, wire, } from "../../helpers/cli-plugin.js"; -import { commandParser } from "../../helpers/command-parser.js"; +import { + generatedParameters, + commandParser, +} from "../../helpers/command-parser.js"; import type { Arg, ArgType } from "../../../../generator/plugin/args.js"; import type { Method } from "../../../../generator/plugin/commands.js"; import type { OperationInfo } from "../../../../generator/plugin/operation.js"; -import type { Argv } from "yargs"; describe("descriptions", () => { it("labels POST validation without claiming to create a resource", () => { @@ -170,10 +170,10 @@ describe("an API force parameter on a delete", () => { "things", op() ); - const builder = builderLines(ctx).join("\n"); - expect(builder).toContain('.option(\'force-delete\', {"type":"boolean"'); + const builder = parameterSource(ctx).join("\n"); + expect(builder).toContain('"force-delete": {"kind":"boolean"'); expect(builder).toContain( - '.option("force", {"type":"boolean","alias":"f","description":"Skip confirmation (useful in scripts and CI)","default":false})' + '"force": {"kind":"boolean","brief":"Skip confirmation (useful in scripts and CI)","alias":"f","default":false}' ); const code = handler(ctx).join("\n"); expect(code).toContain(`'force': argv["force-delete"]`); @@ -383,15 +383,12 @@ describe("optional joined query enums", () => { wire: wire({ joined: ["selector"] }), }) ); - const builder = new Script( - stripTypeScriptTypes(`(yargs) => yargs${builderLines(ctx).join("\n")}`) - ).runInNewContext() as (args: Argv) => Argv; + const params = generatedParameters(parameterSource(ctx)); expect( ( await commandParser(["list"], { + ...params, command: "list", - builder, - handler() {}, }).parse() ).selector ).toBeUndefined(); @@ -417,15 +414,14 @@ describe("file-backed enum arguments", () => { requestContentTypes: ["application/json"], }) ); - const builder = builderLines(ctx).join("\n"); + const builder = parameterSource(ctx).join("\n"); const body = bodyObject(ctx, "").join("\n"); expect(builder).toContain('"choices":["first","second"]'); expect(builder).toContain( - '.coerce("selection", (value) => resolveFileToken(value, "selection", "text"))' + 'coerce: (value: string) => resolveFileToken(value, "selection", "text")' ); - expect(builder).not.toContain('.coerce("sort"'); - expect(builder).not.toContain('.coerce("description"'); + expect(builder).not.toMatch(/"(?:sort|description)": \{[^\n]*coerce:/); expect(body).toContain('selection: argv["selection"]'); expect(body).toContain('resolveFileToken(argv["description"]'); }); @@ -461,11 +457,9 @@ describe("optional body-object validation", () => { requestContentTypes: ["application/json"], }) ); - const builder = new Script( - `(yargs) => yargs\n${builderLines(ctx).join("\n")}` - ).runInNewContext() as (args: Argv) => Argv; + const params = generatedParameters(parameterSource(ctx)); const parse = async (args: string[]) => - commandParser(args, { command: "create", builder, handler() {} }).parse(); + commandParser(args, { ...params, command: "create" }).parse(); await expect( parse(["create", "--parameters-order-by-order", "asc"]) @@ -558,19 +552,19 @@ describe("object-array bodies", () => { const ctx = context(createMethod, "tests", create(true)); expect(find(ctx.derived.args, "versions").type).toBe("objectArray"); expect(find(ctx.derived.args, "tags").type).toBe("array"); - const lines = builderLines(ctx); + const lines = parameterSource(ctx); const option = (name: string) => { - const line = lines.find((l) => l.startsWith(`.option('${name}'`)); + const line = lines.find((l) => l.startsWith(`"${name}": {`)); if (line === undefined) { throw new Error(`no --${name} in ${lines.join("\n")}`); } return line; }; - expect(option("versions")).toContain(`"type":"string"`); - expect(option("versions")).not.toContain(`"array":true`); - expect(option("versions")).not.toContain(`"demandOption":true`); - expect(option("tags")).toContain(`"type":"string"`); - expect(option("tags")).toContain(`"array":true`); + expect(option("versions")).toContain(`parse: String`); + expect(option("versions")).not.toContain(`"variadic":true`); + expect(option("versions")).toContain(`"optional":true`); + expect(option("tags")).toContain(`parse: String`); + expect(option("tags")).toContain(`"variadic":true`); }); it("parses the complete JSON value when assembling the body", () => { @@ -612,7 +606,7 @@ describe("Fern names", () => { const ctx = context(m, "example", op); return { handler: handler(ctx).join("\n"), - builder: builderLines(ctx).join("\n"), + builder: parameterSource(ctx).join("\n"), resolvedRequestPath: ctx.resolvedRequestPath, }; }; @@ -630,14 +624,11 @@ describe("Fern names", () => { "./" ); expect(command).toBe(required ? "get " : "get [consumer]"); - const builder = new Script( - `(yargs) => yargs\n${builderLines(ctx).join("\n")}` - ).runInNewContext() as (args: Argv) => Argv; + const params = generatedParameters(parameterSource(ctx)); const parse = async (args: string[]) => commandParser(args, { + ...params, command: command, - builder, - handler() {}, }).parse(); expect( await parse(["get", "consumer-1", "--queue", "queue-1"]) @@ -658,8 +649,8 @@ describe("Fern names", () => { ...renamedConsumerGet(), wire: wire({ hasRequest: true }), }); - expect(builder).toContain(".positional('consumer'"); - expect(builder).toContain(".option('queue'"); + expect(builder).toContain("placeholder: 'consumer'"); + expect(builder).toContain('"queue": {'); expect(builder).not.toContain("queue-id"); expect(builder).not.toContain("consumer-id"); @@ -732,8 +723,8 @@ describe("Fern names", () => { method("create", "example-without-sdk-entry"), op ); - expect(builder).toContain(".option('mtls-certificate-id'"); - expect(builder).toContain(".option('token'"); + expect(builder).toContain('"mtls-certificate-id": {'); + expect(builder).toContain('"token": {'); expect(builder).toContain(".conflicts('mtls-certificate-id', ['token'])"); expect(builder).toContain(".conflicts('token', ['mtls-certificate-id'])"); expect(h).toContain( diff --git a/packages/cli/src/__tests__/generator/plugin/forge-model.test.ts b/packages/cli/src/__tests__/generator/plugin/forge-model.test.ts index ce5d6ba3c0..298e82d8bb 100644 --- a/packages/cli/src/__tests__/generator/plugin/forge-model.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/forge-model.test.ts @@ -4,6 +4,7 @@ */ import { describe, expect, it } from "vite-plus/test"; import { generateFiles } from "../../helpers/cli-plugin.js"; +import { generatedOptions } from "../../helpers/command-parser.js"; type Json = Record; @@ -160,9 +161,10 @@ describe("the forge model", () => { ); const code = files.get("uploads/create.ts") ?? ""; for (const field of ["files", "attachments"]) { - expect(code).toContain( - `.option('${field}', {"type":"string","array":true` - ); + expect(generatedOptions(code)[field]).toMatchObject({ + array: true, + type: "string", + }); expect(code).toContain(`for (const value of argv["${field}"])`); } expect(code).toContain( @@ -195,10 +197,10 @@ describe("the forge model", () => { ) ); const code = files.get("things/create.ts") ?? ""; - expect(code).toContain('.option(\'id\', {"type":"string"'); - expect(code).toContain('.option(\'parent-id\', {"type":"string"'); - expect(code).toContain( - '.option(\'dataset-ids\', {"type":"string","array":true' + expect(code).toContain('"id": {"kind":"parsed"'); + expect(code).toContain('"parent-id": {"kind":"parsed"'); + expect(code).toMatch( + /"dataset-ids": \{[^}]*"variadic":true[^}]*parse: String/ ); expect(code).toContain("promptForRequiredField('id'"); expect(code).toContain('id: resolveFileToken(argv["id"]'); @@ -227,9 +229,7 @@ describe("the forge model", () => { const files = generateFiles(listing(schema)); const schemas = JSON.parse(files.get("_meta/schemas.json") ?? "{}"); expect(schemas.schemas["things list"].queryParams[0].type).toBe("string"); - expect(files.get("things/list.ts")).toContain( - '.option(\'status\', {"type":"string"' - ); + expect(files.get("things/list.ts")).toContain('"status": {"kind":"parsed"'); }); it("retains required and optional scalar intersections and their enum constraints", () => { @@ -263,7 +263,7 @@ describe("the forge model", () => { ); const files = generateFiles(d); const code = files.get("things/create.ts") ?? ""; - expect(code).toContain(".option('vendor'"); + expect(code).toContain('"vendor": {'); expect(code).toContain('"choices":["GITHUB","SLACK"]'); expect(code).toContain('"choices":["High","Low"]'); expect(code).toContain("promptForRequiredEnumField('vendor'"); @@ -324,7 +324,7 @@ describe("the forge model", () => { ) ); const code = files.get("things/create.ts") ?? ""; - expect(code).toContain(".option('fallback'"); + expect(code).toContain('"fallback": {'); expect(code).toContain("parseScalarValue"); expect(code).toContain( 'fallback: parseScalarValue(argv["fallback"], "fallback")' @@ -419,14 +419,15 @@ describe("the forge model", () => { "things/create.ts" ); expect(code).toContain( - `.option('display-name', {"type":"string","description":"The name."})` + `"display-name": {"kind":"parsed","brief":"The name."` ); // A nullable integer is still a number. - expect(code).toContain(`.option('ttl-seconds', {"type":"number"`); - expect(code).toContain(".option('secret-token'"); + const options = generatedOptions(code); + expect(options["ttl-seconds"]).toMatchObject({ type: "number" }); + expect(code).toContain('"secret-token": {'); expect(code).toContain(`sensitiveBodyPaths: [["token_value"]]`); expect(code).not.toContain("'id'"); - expect(code).toContain(`"choices":["a","b"],"default":"a"`); + expect(options.kind).toMatchObject({ choices: ["a", "b"], default: "a" }); expect(code).toContain("promptForRequiredField('display-name'"); }); @@ -714,7 +715,7 @@ describe("the forge model", () => { }), "things/get.ts" ); - expect(code).toContain(".positional('thing'"); + expect(code).toContain("placeholder: 'thing'"); expect(code).toContain(`requestApi(client, "GET"`); expect(code).not.toContain("const operation"); }); @@ -1028,11 +1029,11 @@ describe("the forge model", () => { "tunnels/create.ts" ); expect(code).toContain( - `.option('config-source', {"type":"string","description":"Where the tunnel is configured.",` + `"config-source": {"kind":"parsed","brief":"Where the tunnel is configured.",` ); // A field's own description wins. expect(code).toContain( - `.option('name', {"type":"string","description":"Its own description.",` + `"name": {"kind":"parsed","brief":"Its own description.",` ); }); @@ -1060,7 +1061,7 @@ describe("the forge model", () => { "things/list.ts" ); expect(code).toContain( - `.option('jurisdiction', {"type":"string","description":"The cf-r2-jurisdiction header"})` + `"jurisdiction": {"kind":"parsed","brief":"The cf-r2-jurisdiction header"` ); expect(code).toContain( `headers['cf-r2-jurisdiction'] = String(argv["jurisdiction"])` @@ -1145,14 +1146,12 @@ describe("the forge model", () => { "things/list.ts" ); expect(code).toMatch( - /\.option\('cf-storage-class', \{[^}]*"description":"Storage class for new objects\."/ - ); - expect(code).toMatch( - /\.option\('class', \{[^}]*"description":"Storage class for new objects\."/ + /"cf-storage-class": \{[^}]*"brief":"Storage class for new objects\."/ ); expect(code).toMatch( - /\.option\('described', \{[^}]*"description":"Its own\."/ + /"class": \{[^}]*"brief":"Storage class for new objects\."/ ); + expect(code).toMatch(/"described": \{[^}]*"brief":"Its own\."/); }); it("leaves the members of an anyOf to the body", () => { @@ -1174,7 +1173,7 @@ describe("the forge model", () => { expect(code).not.toContain("'tags'"); expect(code).not.toContain("'hosts'"); expect(code).not.toContain(".conflicts("); - expect(code).toContain(".option('body'"); + expect(code).toContain('"body": {'); }); it("still sends an object body without properties", () => { @@ -1182,7 +1181,7 @@ describe("the forge model", () => { create({ type: "object", required: ["id"] }), "things/create.ts" ); - expect(code).toContain(".option('body'"); + expect(code).toContain('"body": {'); }); it("describes a body by its schema, never its title", () => { @@ -1195,7 +1194,7 @@ describe("the forge model", () => { }), "things/create.ts" ) - ).toContain("description: 'Some names.',"); + ).toContain('"brief":"Some names."'); const code = file( create( @@ -1211,7 +1210,7 @@ describe("the forge model", () => { "things/create.ts" ); expect(code).toContain( - "description: 'Raw JSON request body (bypasses individual flags)'," + '"brief":"Raw JSON request body (bypasses individual flags)"' ); expect(code).not.toContain("Thing Input"); }); @@ -1237,7 +1236,7 @@ describe("the forge model", () => { anyOf: [values, { type: "array", items: values }], }); expect(file(anyOf, "things/list.ts")).toContain( - `"choices":["running","done"]` + `"values":["running","done"]` ); expect(queryType(anyOf)).toBe("string"); }); @@ -1306,7 +1305,7 @@ describe("the forge model", () => { }), "things/create.ts" ); - expect(code).toContain(".option('filters'"); + expect(code).toContain('"filters": {'); }); it("publishes an object array as one string option in command metadata", () => { diff --git a/packages/cli/src/__tests__/generator/plugin/hand-written-roots.test.ts b/packages/cli/src/__tests__/generator/plugin/hand-written-roots.test.ts index d884c189dc..24e7dae43f 100644 --- a/packages/cli/src/__tests__/generator/plugin/hand-written-roots.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/hand-written-roots.test.ts @@ -88,9 +88,9 @@ describe("created roots", () => { previews() ); const index = read(files, "previews/index.ts"); - expect(index).toContain(".command($delete)"); + expect(index).toContain("'delete': $delete,"); expect(index).toContain( - ".command(withHandWrittenDryRun($deploy, 'preview'))" + "'deploy': withHandWrittenDryRun($deploy, 'preview')," ); const root = read(files, "index.ts"); expect(root.match(/lazyCommand\('previews'/g)).toEqual([ diff --git a/packages/cli/src/__tests__/generator/plugin/json-shape.test.ts b/packages/cli/src/__tests__/generator/plugin/json-shape.test.ts index 35d683f79e..c3d09ffe50 100644 --- a/packages/cli/src/__tests__/generator/plugin/json-shape.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/json-shape.test.ts @@ -7,6 +7,7 @@ import { commandParser } from "../../helpers/command-parser.js"; import type { CommandMeta } from "../../../lib/command-meta.js"; import type { ObjectType, Type } from "@cloudflare/forge/plugin"; import type { CommandModule } from "yargs"; +import { apiCommand } from "#lib/api-command.js"; describe("JSON parameter shapes", () => { const files = generateFiles({ @@ -123,7 +124,9 @@ describe("JSON parameter shapes", () => { const source = stripTypeScriptTypes(files.get("things/create.ts") ?? "") .replace(/^import[\s\S]*?;\n/gm, "") .replace("export default command;", "command;"); - const command = new Script(source).runInNewContext() as CommandModule; + const command = new Script(source).runInNewContext({ + apiCommand, + }) as CommandModule; it("shows the same first-level wire shape in help, command metadata, and cf schema", async () => { const description = diff --git a/packages/cli/src/__tests__/generator/plugin/metadata-defaults.test.ts b/packages/cli/src/__tests__/generator/plugin/metadata-defaults.test.ts index d0669d4c88..887f8e980a 100644 --- a/packages/cli/src/__tests__/generator/plugin/metadata-defaults.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/metadata-defaults.test.ts @@ -1,5 +1,6 @@ import { describe, expect, it } from "vite-plus/test"; import { generateFiles } from "../../helpers/cli-plugin.js"; +import { generatedOptions } from "../../helpers/command-parser.js"; import type { CommandMeta } from "../../../lib/command-meta.js"; type Json = Record; @@ -48,12 +49,11 @@ function expectDefault( value: unknown ) { const metadata = generated.command.options.find((o) => o.name === flag); - const match = generated.code.match( - new RegExp(`\\.option\\('${flag}', (\\{[^\\n]*\\})\\)`) - ); + const builder = generatedOptions(generated.code)[flag]; expect(metadata, `metadata for --${flag}`).toBeDefined(); - expect(match, `builder for --${flag}`).not.toBeNull(); - const builder = JSON.parse(match?.[1] ?? "") as Json; + if (!builder) { + throw new Error(`missing flag: ${flag}`); + } for (const option of [metadata, builder]) { if (value === undefined) { expect(option).not.toHaveProperty("default"); diff --git a/packages/cli/src/__tests__/generator/plugin/metadata-force.test.ts b/packages/cli/src/__tests__/generator/plugin/metadata-force.test.ts index 98cb69d30a..1c38aab275 100644 --- a/packages/cli/src/__tests__/generator/plugin/metadata-force.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/metadata-force.test.ts @@ -59,7 +59,7 @@ describe("command metadata force option", () => { }, ]); expect(code).toContain( - '.option("force", {"type":"boolean","alias":"f","description":"Skip confirmation (useful in scripts and CI)","default":false})' + '"force": {"kind":"boolean","brief":"Skip confirmation (useful in scripts and CI)","alias":"f","default":false}' ); expect(code).toContain("confirmDelete({ force: Boolean(argv.force)"); expect(code).toContain("shortFlagAliases: { f:"); @@ -74,7 +74,7 @@ describe("command metadata force option", () => { expect(meta.options.some((option) => option.name === "force")).toBe( false ); - expect(code).not.toContain('.option("force"'); + expect(code).not.toContain('"force": {'); expect(code).not.toContain("confirmDelete"); expect(code).not.toContain("shortFlagAliases"); } @@ -83,7 +83,7 @@ describe("command metadata force option", () => { it("ignores an empty confirmation annotation consistently", () => { const { meta, code } = generate("put", ""); expect(meta.options.some((option) => option.name === "force")).toBe(false); - expect(code).not.toContain('.option("force"'); + expect(code).not.toContain('"force": {'); expect(code).not.toContain("confirmDelete"); expect(code).not.toContain("shortFlagAliases"); }); diff --git a/packages/cli/src/__tests__/generator/plugin/metadata-multipart.test.ts b/packages/cli/src/__tests__/generator/plugin/metadata-multipart.test.ts index 4110507b78..98d02d8204 100644 --- a/packages/cli/src/__tests__/generator/plugin/metadata-multipart.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/metadata-multipart.test.ts @@ -5,6 +5,7 @@ import { } from "../../../../generator/plugin/files.js"; import { HandWritten } from "../../../../generator/plugin/hand-written.js"; import { bodyParam, method, operation } from "../../helpers/cli-plugin.js"; +import { generatedOptions } from "../../helpers/command-parser.js"; import type { Command } from "../../../../generator/plugin/commands.js"; import type { MultipartField } from "../../../../generator/plugin/operation.js"; import type { CommandMeta } from "../../../lib/command-meta.js"; @@ -73,11 +74,9 @@ function generate() { describe("command metadata multipart form options", () => { it("lists the same flags as the runtime builder", () => { const { meta, code } = generate(); - const runtime = [ - ...code.matchAll( - /\.option\(['"]([^'"]+)['"], \{\s*(?:"type":"|type: ')(\w+)/g - ), - ].map(([, name, type]) => ({ name, type })); + const runtime = Object.entries(generatedOptions(code)).map( + ([name, { type }]) => ({ name, type }) + ); expect(meta.options.map(({ name, type }) => ({ name, type }))).toEqual( runtime ); diff --git a/packages/cli/src/__tests__/generator/plugin/metadata-text.test.ts b/packages/cli/src/__tests__/generator/plugin/metadata-text.test.ts index 27baa7ce37..d15ea361ab 100644 --- a/packages/cli/src/__tests__/generator/plugin/metadata-text.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/metadata-text.test.ts @@ -5,6 +5,7 @@ import { } from "../../../../generator/plugin/files.js"; import { HandWritten } from "../../../../generator/plugin/hand-written.js"; import { method, operation } from "../../helpers/cli-plugin.js"; +import { generatedOptions } from "../../helpers/command-parser.js"; import type { Command } from "../../../../generator/plugin/commands.js"; import type { CommandMeta } from "../../../lib/command-meta.js"; @@ -50,9 +51,7 @@ describe("command metadata text option", () => { "matches the runtime option for %s responses", (contentType) => { const { meta, code } = generate(contentType); - const match = code.match(/\.option\("text", (\{[^\n]*\})\)/); - expect(match).not.toBeNull(); - const runtime = JSON.parse(match?.[1] ?? "") as Record; + const runtime = generatedOptions(code).text; expect(runtime).toMatchObject({ type: "boolean", default: false }); expect(meta.options.filter((option) => option.name === "text")).toEqual([ { name: "text", required: false, ...runtime }, @@ -69,7 +68,7 @@ describe("command metadata text option", () => { (contentType, status) => { const { meta, code } = generate(contentType, status); expect(meta.options.some((option) => option.name === "text")).toBe(false); - expect(code).not.toContain('.option("text"'); + expect(code).not.toContain('"text": {'); } ); }); diff --git a/packages/cli/src/__tests__/generator/plugin/multipart-files.test.ts b/packages/cli/src/__tests__/generator/plugin/multipart-files.test.ts index a9554baa80..e08c6074ae 100644 --- a/packages/cli/src/__tests__/generator/plugin/multipart-files.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/multipart-files.test.ts @@ -2,7 +2,7 @@ import { stripTypeScriptTypes } from "node:module"; import { Script } from "node:vm"; import { describe, expect, it, vi } from "vite-plus/test"; import { derive } from "../../../../generator/plugin/args.js"; -import { builderLines } from "../../../../generator/plugin/emit/builder.js"; +import { parameterSource } from "../../../../generator/plugin/emit/builder.js"; import { dryRun, handler } from "../../../../generator/plugin/emit/handler.js"; import { bodyParam, @@ -244,7 +244,7 @@ describe("multipart field flag names", () => { "example", op ); - expect(builderLines(ctx).join("\n")).toContain(".option('form-label', {"); + expect(parameterSource(ctx).join("\n")).toContain('"form-label": {'); const code = handler(ctx).join("\n"); expect(code).toContain( "if (argv[\"form-label\"] !== undefined) formData.append('label'" @@ -261,8 +261,8 @@ describe("multipart field flag names", () => { "example", op ); - const builder = builderLines(ctx).join("\n"); - expect(builder.match(/\.option\('display-label'/g)).toHaveLength(1); + const builder = parameterSource(ctx).join("\n"); + expect(builder.match(/"display-label": \{/g)).toHaveLength(1); expect(builder).not.toContain("'label'"); expect(handler(ctx).join("\n")).toContain( "if (argv[\"display-label\"] !== undefined) formData.append('label'" diff --git a/packages/cli/src/__tests__/generator/plugin/nested-array-flags.test.ts b/packages/cli/src/__tests__/generator/plugin/nested-array-flags.test.ts index e0701ce119..e00dcd9585 100644 --- a/packages/cli/src/__tests__/generator/plugin/nested-array-flags.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/nested-array-flags.test.ts @@ -14,6 +14,7 @@ import { generateFiles } from "../../helpers/cli-plugin.js"; import { commandParser } from "../../helpers/command-parser.js"; import type { CommandMeta } from "../../../lib/command-meta.js"; import type { CommandModule } from "yargs"; +import { apiCommand } from "#lib/api-command.js"; function generate(typed: boolean) { const schema = { @@ -118,6 +119,7 @@ describe.each([true, false])( const requestApi = vi.fn(async () => undefined); const formatDryRun = vi.fn(); const command = new Script(source).runInNewContext({ + apiCommand, compactBody, parseBody, parseNestedArray, diff --git a/packages/cli/src/__tests__/generator/plugin/nested-body-overrides.test.ts b/packages/cli/src/__tests__/generator/plugin/nested-body-overrides.test.ts index 41e6c62fd6..44b36acf1f 100644 --- a/packages/cli/src/__tests__/generator/plugin/nested-body-overrides.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/nested-body-overrides.test.ts @@ -16,6 +16,7 @@ import { commandParser } from "../../helpers/command-parser.js"; import type { Method } from "../../../../generator/plugin/commands.js"; import type { CommandMeta } from "../../../lib/command-meta.js"; import type { CommandModule } from "yargs"; +import { apiCommand } from "#lib/api-command.js"; describe("exact body-field overrides", () => { const op = operation("post", "/things", { @@ -217,6 +218,7 @@ describe("emitted nested overrides and metadata", () => { .replace("export default command;", "command;"); const formatDryRun = vi.fn(); const command = new Script(source).runInNewContext({ + apiCommand, compactBody, parseBody, resolveFileToken, diff --git a/packages/cli/src/__tests__/generator/plugin/nested-unions.test.ts b/packages/cli/src/__tests__/generator/plugin/nested-unions.test.ts index fca901408e..53e4452091 100644 --- a/packages/cli/src/__tests__/generator/plugin/nested-unions.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/nested-unions.test.ts @@ -11,6 +11,7 @@ import { resolveFileToken } from "../../../lib/input-validation.js"; import { generateFiles } from "../../helpers/cli-plugin.js"; import { commandParser } from "../../helpers/command-parser.js"; import type { CommandModule } from "yargs"; +import { apiCommand } from "#lib/api-command.js"; type Json = Record; const id = "b07a1f7c-1b34-4fba-9c57-f8033b913973"; @@ -84,10 +85,11 @@ function command(code: string) { const preview = vi.fn((_detail: { body: unknown }) => {}); const source = stripTypeScriptTypes( code - .slice(code.indexOf("function builder")) + .replace(/^import[\s\S]*?;\n/gm, "") .replace("export default command;", "command;") ); const module = new Script(source).runInNewContext({ + apiCommand, compactBody, parseBody, setNestedValue, @@ -254,7 +256,7 @@ describe("read-only request properties", () => { }); const code = files.get("things/create.ts") ?? ""; expect(code).not.toContain("server_top"); - expect(code).not.toContain(".option('settings-scope-server-id'"); + expect(code).not.toContain('"settings-scope-server-id": {'); const start = code.indexOf("const bodyUnions:"); const definition = code.slice(start, code.indexOf(";\n", start) + 1); const constraints = new Script( @@ -302,7 +304,7 @@ describe("read-only request properties", () => { }); const code = files.get("things/create.ts") ?? ""; expect(code).not.toContain("validateBodyUnions"); - expect(code).not.toContain(".option('settings-scope-kind'"); + expect(code).not.toContain('"settings-scope-kind": {'); const c = command(code); await c.run([ "create", diff --git a/packages/cli/src/__tests__/generator/plugin/normalization.test.ts b/packages/cli/src/__tests__/generator/plugin/normalization.test.ts index b88ebd66a8..63b2f9978d 100644 --- a/packages/cli/src/__tests__/generator/plugin/normalization.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/normalization.test.ts @@ -1,5 +1,6 @@ import { describe, expect, it } from "vite-plus/test"; import { generateFiles } from "../../helpers/cli-plugin.js"; +import { generatedOptions } from "../../helpers/command-parser.js"; import type { CommandMeta } from "../../../lib/command-meta.js"; describe("Forge metadata normalization", () => { @@ -79,10 +80,7 @@ describe("Forge metadata normalization", () => { (entry) => entry.command === "cf things create" ); const code = files.get("things/create.ts") ?? ""; - const builderNames = Array.from( - code.matchAll(/\.option\(['"]([^'"]+)['"],/g), - (match) => match[1] - ); + const builderNames = Object.keys(generatedOptions(code)); expect(command?.options.map((option) => option.name)).toEqual(builderNames); expect(builderNames).toEqual( diff --git a/packages/cli/src/__tests__/generator/plugin/oneof-body-flags.test.ts b/packages/cli/src/__tests__/generator/plugin/oneof-body-flags.test.ts index 5b3538a9a8..3d093ab721 100644 --- a/packages/cli/src/__tests__/generator/plugin/oneof-body-flags.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/oneof-body-flags.test.ts @@ -10,6 +10,7 @@ import { resolveFileToken } from "../../../lib/input-validation.js"; import { generateFiles } from "../../helpers/cli-plugin.js"; import { commandParser } from "../../helpers/command-parser.js"; import type { CommandModule } from "yargs"; +import { apiCommand } from "#lib/api-command.js"; const network = { type: "object", @@ -115,6 +116,7 @@ function setup(code: string, initialFlags: string[] = []) { const requestBody = vi.fn(); const formatDryRun = vi.fn(); const command = new Script(source).runInNewContext({ + apiCommand, compactBody, parseBody, setNestedValue, diff --git a/packages/cli/src/__tests__/generator/plugin/path-parameter-overrides.test.ts b/packages/cli/src/__tests__/generator/plugin/path-parameter-overrides.test.ts index 2c84d5b71c..2061a423d6 100644 --- a/packages/cli/src/__tests__/generator/plugin/path-parameter-overrides.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/path-parameter-overrides.test.ts @@ -1,5 +1,6 @@ import { beforeAll, describe, expect, it } from "vite-plus/test"; import { generateFiles } from "../../helpers/cli-plugin.js"; +import { generatedOptions } from "../../helpers/command-parser.js"; import type { CommandMeta } from "../../../lib/metadata.js"; const spec = { @@ -74,19 +75,13 @@ describe("path parameter overrides in generated commands", () => { it("registers a defaulted namespace flag beside the sole instance positional", () => { const code = read("ai-search/create.ts"); - const namespaceLine = code - .split("\n") - .map((line) => line.trim()) - .find((line) => line.startsWith(".option('namespace',")); - expect(namespaceLine).toBeDefined(); - const json = namespaceLine?.slice(".option('namespace', ".length, -1) ?? ""; - expect(JSON.parse(json)).toEqual({ + expect(generatedOptions(code).namespace).toEqual({ type: "string", description: "Name", default: "default", }); expect(code).toContain("command: 'create '"); - expect(code).not.toContain(".positional('namespace'"); + expect(code).not.toContain("placeholder: 'namespace'"); }); it("keeps the default and positional placement consistent with metadata, requests, and previews", () => { diff --git a/packages/cli/src/__tests__/generator/plugin/query-array-flags.test.ts b/packages/cli/src/__tests__/generator/plugin/query-array-flags.test.ts index a6fd9de411..c3451aef9f 100644 --- a/packages/cli/src/__tests__/generator/plugin/query-array-flags.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/query-array-flags.test.ts @@ -7,6 +7,7 @@ import { generateFiles } from "../../helpers/cli-plugin.js"; import { commandParser } from "../../helpers/command-parser.js"; import type { CommandsMetadata } from "../../../lib/command-meta.js"; import type { CommandModule } from "yargs"; +import { apiCommand } from "#lib/api-command.js"; const enumValues = ["001", "a/b &c", "literal,comma"]; const enumSchema = { type: "string", enum: enumValues }; @@ -112,6 +113,7 @@ describe.each( }, }); const command = new Script(source).runInNewContext({ + apiCommand, operation, createCommandClient: async () => client, formatOutput: () => {}, @@ -128,7 +130,9 @@ describe.each( } it("preserves the array type and publishes item choices", () => { - expect(source).toContain('"type":"string","array":true'); + expect(source).toMatch( + /"indicator-ids": \{[^}]*"variadic":true[^}]*parse: String/ + ); if (choices === undefined) { expect(source).not.toContain('"choices"'); } else { @@ -143,9 +147,9 @@ describe.each( expect(option).toMatchObject({ type: "string", required: true }); expect(option?.enum).toEqual(choices); if (choices !== undefined) { - expect(source).toContain('.coerce("indicator-ids"'); + expect(source).toContain("coerce: (values"); } else { - expect(source).not.toContain(".coerce("); + expect(source).not.toContain("coerce:"); } }); diff --git a/packages/cli/src/__tests__/generator/plugin/required-raw-bodies.test.ts b/packages/cli/src/__tests__/generator/plugin/required-raw-bodies.test.ts index 88464ce105..29d52fd4bf 100644 --- a/packages/cli/src/__tests__/generator/plugin/required-raw-bodies.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/required-raw-bodies.test.ts @@ -9,6 +9,7 @@ import { import { generateFiles } from "../../helpers/cli-plugin.js"; import { commandParser } from "../../helpers/command-parser.js"; import type { CommandModule } from "yargs"; +import { apiCommand } from "#lib/api-command.js"; function setup(files: Map, name = "update") { const source = stripTypeScriptTypes(files.get(`things/${name}.ts`) ?? "") @@ -28,6 +29,7 @@ function setup(files: Map, name = "update") { const formatOutput = vi.fn(); const formatDryRun = vi.fn(); const command = new Script(source).runInNewContext({ + apiCommand, Blob, FormData, operation: {}, @@ -334,7 +336,7 @@ describe("multipart bodies", () => { ); const code = files.get("things/update.ts") ?? ""; for (const field of Object.keys(readOnlyFields)) { - expect(code).not.toContain(`.option('${field}',`); + expect(code).not.toContain(`"${field}": {`); expect(code).not.toContain(`formData.append('${field}',`); } await seed({ "payload.txt": "writable content" }); diff --git a/packages/cli/src/__tests__/generator/plugin/scalar-union-positionals.test.ts b/packages/cli/src/__tests__/generator/plugin/scalar-union-positionals.test.ts index 9fa42deb8f..7fcb5af93a 100644 --- a/packages/cli/src/__tests__/generator/plugin/scalar-union-positionals.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/scalar-union-positionals.test.ts @@ -2,7 +2,7 @@ import { stripTypeScriptTypes } from "node:module"; import { Script } from "node:vm"; import { runInTempDir, seed } from "@cloudflare/workers-utils/test-helpers"; import { describe, expect, it, vi } from "vite-plus/test"; -import { builderLines } from "../../../../generator/plugin/emit/builder.js"; +import { parameterSource } from "../../../../generator/plugin/emit/builder.js"; import { handler, imports } from "../../../../generator/plugin/emit/handler.js"; import { context as emitContext } from "../../../../generator/plugin/emit/index.js"; import { @@ -17,8 +17,10 @@ import { operation, wire, } from "../../helpers/cli-plugin.js"; -import { commandParser } from "../../helpers/command-parser.js"; -import type { Argv } from "yargs"; +import { + generatedParameters, + commandParser, +} from "../../helpers/command-parser.js"; describe.each([true, false])( "scalar-union positionals (typed request: %s)", @@ -38,9 +40,7 @@ describe.each([true, false])( }), "./" ); - const builder = new Script( - `(yargs) => yargs\n${builderLines(ctx).join("\n")}` - ).runInNewContext() as (args: Argv) => Argv; + const params = generatedParameters(parameterSource(ctx)); const source = stripTypeScriptTypes( `(async (argv) => {\n${handler(ctx).join("\n")}\n})` ); @@ -88,7 +88,7 @@ describe.each([true, false])( }) as (argv: Record) => Promise; const argv = await commandParser( ["create", ...args, ...(dryRun ? ["--dry-run"] : [])], - { command: command, builder, handler() {} } + { ...params, command: command } ).parse(); await run(argv); if (dryRun) { diff --git a/packages/cli/src/__tests__/generator/plugin/variant-descriptions.test.ts b/packages/cli/src/__tests__/generator/plugin/variant-descriptions.test.ts index 6dc6bb73cd..434c4bea85 100644 --- a/packages/cli/src/__tests__/generator/plugin/variant-descriptions.test.ts +++ b/packages/cli/src/__tests__/generator/plugin/variant-descriptions.test.ts @@ -1,5 +1,6 @@ import { describe, expect, it } from "vite-plus/test"; import { generateFiles } from "../../helpers/cli-plugin.js"; +import { generatedOptions } from "../../helpers/command-parser.js"; import type { CommandMeta } from "../../../lib/command-meta.js"; type Json = Record; @@ -36,12 +37,11 @@ function generate(schema: Json, schemas: Json = {}) { function option(generated: ReturnType, flag: string) { const metadata = generated.command.options.find((o) => o.name === flag); - const match = generated.code.match( - new RegExp(`\\.option\\('${flag}', (\\{[^\\n]*\\})\\)`) - ); + const builder = generatedOptions(generated.code)[flag]; expect(metadata, `metadata for --${flag}`).toBeDefined(); - expect(match, `builder for --${flag}`).not.toBeNull(); - const builder = JSON.parse(match?.[1] ?? "") as Json; + if (!builder) { + throw new Error(`missing flag: ${flag}`); + } expect(builder["description"]).toBe(metadata?.description); return { metadata, builder }; } diff --git a/packages/cli/src/__tests__/helpers/command-parser.ts b/packages/cli/src/__tests__/helpers/command-parser.ts index 1cd302cf19..3f86aadfc1 100644 --- a/packages/cli/src/__tests__/helpers/command-parser.ts +++ b/packages/cli/src/__tests__/helpers/command-parser.ts @@ -1,6 +1,53 @@ +import { stripTypeScriptTypes } from "node:module"; +import { Script } from "node:vm"; import type { CommandModule } from "yargs"; +import type { Options } from "yargs"; +import { apiCommand } from "#lib/api-command.js"; import { createParser } from "#lib/stricli.js"; +export function generatedParameters(lines: string[]) { + const parameters = new Script( + stripTypeScriptTypes(`({${lines.join("\n")}})`) + ).runInNewContext() as Pick< + Parameters[0], + "flags" | "operands" | "rules" + >; + return apiCommand({ + command: "test", + describe: "test", + usage: "", + ...parameters, + async handler() {}, + }); +} + +export function generatedOptions(source: string) { + const code = stripTypeScriptTypes(source) + .replace(/^import[\s\S]*?;\n/gm, "") + .replace("export default command;", "command;"); + const command = new Script(code).runInNewContext({ + apiCommand, + }) as ReturnType; + const flags: Record = {}; + command.configure({ + usage() {}, + positional() {}, + group() {}, + check() {}, + implies() {}, + conflicts() {}, + option(name, options) { + flags[name] = Object.fromEntries( + Object.entries(options).filter( + ([key, value]) => + value !== undefined && !(key === "demandOption" && !value) + ) + ); + }, + }); + return flags; +} + export function commandParser( args: string[], command: CommandModule diff --git a/packages/cli/src/__tests__/lib/stricli.test.ts b/packages/cli/src/__tests__/lib/stricli.test.ts index 753b642bb2..dc50b28a5d 100644 --- a/packages/cli/src/__tests__/lib/stricli.test.ts +++ b/packages/cli/src/__tests__/lib/stricli.test.ts @@ -1,8 +1,70 @@ -import { describe, expect, it, vi } from "vite-plus/test"; +import { describe, expect, expectTypeOf, it, vi } from "vite-plus/test"; +import { apiCommand, apiGroup } from "../../lib/api-command.js"; import { commandParser } from "../helpers/command-parser.js"; import type { CommandModule } from "yargs"; describe("Stricli command boundary", () => { + it("derives handler inputs from native parameters and dispatches the same native leaf through its group", async () => { + const execute = vi.fn(); + const leaf = apiCommand({ + command: "list ", + describe: "List items", + usage: "", + flags: { + limit: { + kind: "parsed", + parse: Number, + brief: "Limit", + optional: true, + }, + order: { + kind: "enum", + values: ["asc", "desc"], + default: "asc", + brief: "Order", + }, + "dry-run": { kind: "boolean", default: false, brief: "Preview" }, + tags: { + kind: "parsed", + parse: String, + variadic: true, + optional: true, + brief: "Tags", + }, + }, + operands: [{ placeholder: "bucket-id", brief: "Bucket", parse: String }], + async handler(argv) { + expectTypeOf(argv.limit).toEqualTypeOf(); + expectTypeOf(argv.order).toEqualTypeOf<"asc" | "desc">(); + expectTypeOf(argv.dryRun).toEqualTypeOf(); + expectTypeOf(argv.tags).toEqualTypeOf(); + expectTypeOf(argv.bucketId).toEqualTypeOf(); + expectTypeOf().extract<"misspelled">().toBeNever(); + execute(argv); + }, + }); + const group = apiGroup({ + command: "items", + describe: "Items", + routes: { list: leaf }, + }); + expect(group.routeMap().getRoutingTargetForInput("list")).toBe( + leaf.native() + ); + await commandParser( + ["items", "list", "a", "--tags", "one", "two", "--limit=4"], + group + ).parse(); + expect(execute).toHaveBeenCalledWith( + expect.objectContaining({ + bucketId: "a", + order: "asc", + dryRun: false, + limit: 4, + tags: ["one", "two"], + }) + ); + }); const handler = vi.fn(); const command: CommandModule = { command: "remove ", diff --git a/packages/cli/src/commands/_generated/abuse-reports/appeals/eligibility.ts b/packages/cli/src/commands/_generated/abuse-reports/appeals/eligibility.ts index 7243a6edc1..c0a7e43b37 100644 --- a/packages/cli/src/commands/_generated/abuse-reports/appeals/eligibility.ts +++ b/packages/cli/src/commands/_generated/abuse-reports/appeals/eligibility.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/abuse-reports/appeals/eligibility.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * eligibility command * @generated from apis/overlays/abuse-reports.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,28 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 abuse-reports appeals eligibility \n\nReturns whether the report is currently appealable, along with the signals behind that decision: whether it already has an open appeal, how many appeals have been submitted against it, and whether it has at least one mitigation that an appeal could reverse. Report-level appeals are currently available only for DMCA (copyright) reports. For other report types this operation returns the same `404 Report not found` response as a report that does not exist for the account." - ) - .positional("report-id", { - type: "string", - description: "Abuse Report ID", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "eligibility ", describe: "Check whether a report can be appealed", - builder, + usage: + "$0 abuse-reports appeals eligibility \n\nReturns whether the report is currently appealable, along with the signals behind that decision: whether it already has an open appeal, how many appeals have been submitted against it, and whether it has at least one mitigation that an appeal could reverse. Report-level appeals are currently available only for DMCA (copyright) reports. For other report types this operation returns the same `404 Report not found` response as a report that does not exist for the account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { placeholder: "report-id", brief: "Abuse Report ID", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "abuse-reports appeals eligibility", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -74,6 +65,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/abuse-reports/appeals/index.ts b/packages/cli/src/commands/_generated/abuse-reports/appeals/index.ts index 8161a1b535..e519748885 100644 --- a/packages/cli/src/commands/_generated/abuse-reports/appeals/index.ts +++ b/packages/cli/src/commands/_generated/abuse-reports/appeals/index.ts @@ -1,22 +1,17 @@ import $eligibility from "./eligibility.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * appeals command group * @generated from apis/overlays/abuse-reports.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "appeals", describe: "Appeal eligibility for abuse reports", - builder: (yargs) => { - return yargs - .command($eligibility) - .demandCommand(1, "Please specify a subcommand"); + routes: { + eligibility: $eligibility, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/abuse-reports/create.ts b/packages/cli/src/commands/_generated/abuse-reports/create.ts index cdbf95d652..8ef0770160 100644 --- a/packages/cli/src/commands/_generated/abuse-reports/create.ts +++ b/packages/cli/src/commands/_generated/abuse-reports/create.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/abuse-reports.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -23,19 +22,16 @@ import { } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 abuse-reports create \n\nSubmit an abuse report of a particular type. Requires the abuse-reports entitlement on the account (Enterprise accounts have it by default; other accounts must request access) and an API token with the `Trust and Safety Write` permission. If the account is not entitled, the request is rejected with an HTTP `401` response (see below). Delegated reports: In limited circumstances, Cloudflare delegates processing of abuse reports to select customers who have established abuse-handling programs. For these customers, Cloudflare may forward abuse reports directly and in full—including reporter contact information, comments, and supporting evidence—without redaction or preprocessing by Cloudflare. This allows the customer to investigate and respond using their own policies and processes. For delegated reports, the report—including contact information and comments—will be forwarded to the customer in full regardless of the `host_notification` and `owner_notification` values." - ) - .positional("report-type", { - type: "string", - description: "The report type to be submitted. Example: abuse_general", - demandOption: true, - }) - .option("act", { - type: "string", - description: "The act field", +const command = apiCommand({ + command: "create ", + describe: "Submit an abuse report", + usage: + "$0 abuse-reports create \n\nSubmit an abuse report of a particular type. Requires the abuse-reports entitlement on the account (Enterprise accounts have it by default; other accounts must request access) and an API token with the `Trust and Safety Write` permission. If the account is not entitled, the request is rejected with an HTTP `401` response (see below). Delegated reports: In limited circumstances, Cloudflare delegates processing of abuse reports to select customers who have established abuse-handling programs. For these customers, Cloudflare may forward abuse reports directly and in full—including reporter contact information, comments, and supporting evidence—without redaction or preprocessing by Cloudflare. This allows the customer to investigate and respond using their own policies and processes. For delegated reports, the report—including contact information and comments—will be forwarded to the customer in full regardless of the `host_notification` and `owner_notification` values.", + flags: { + act: { + kind: "parsed", + brief: "The act field", + optional: true, choices: [ "abuse_dmca", "abuse_trademark", @@ -46,210 +42,289 @@ function builder(yargs: Argv) { "abuse_registrar_whois", "abuse_ncsei", ], - }) - .coerce("act", (value) => resolveFileToken(value, "act", "text")) - .option("comments", { - type: "string", - description: + parse: String, + coerce: (value: string) => resolveFileToken(value, "act", "text"), + }, + comments: { + kind: "parsed", + brief: "Any additional comments about the infringement not exceeding 2000 characters. With the exception of delegated reports, comments are kept internal to Cloudflare and not shared with the host or customer as part of regular processing. For the limited circumstances where we delegate reports to customers with established abuse-handling programs, comments may be shared in full.", - }) - .option("company", { - type: "string", - description: + optional: true, + parse: String, + }, + company: { + kind: "parsed", + brief: "Text not exceeding 100 characters. This field may be released by Cloudflare to third parties such as the Lumen Database (https://lumendatabase.org/).", - }) - .option("email", { - type: "string", - description: + optional: true, + parse: String, + }, + email: { + kind: "parsed", + brief: "A valid email of the abuse reporter. This field may be released by Cloudflare to third parties such as the Lumen Database (https://lumendatabase.org/).", - }) - .option("email2", { - type: "string", - description: "Should match the value provided in `email`", - }) - .option("name", { - type: "string", - description: + optional: true, + parse: String, + }, + email2: { + kind: "parsed", + brief: "Should match the value provided in `email`", + optional: true, + parse: String, + }, + name: { + kind: "parsed", + brief: "Text not exceeding 255 characters. This field may be released by Cloudflare to third parties such as the Lumen Database (https://lumendatabase.org/).", - }) - .option("reported-country", { - type: "string", - description: "Text containing 2 characters", - }) - .option("reported-user-agent", { - type: "string", - description: "Text not exceeding 255 characters", - }) - .option("tele", { - type: "string", - description: + optional: true, + parse: String, + }, + "reported-country": { + kind: "parsed", + brief: "Text containing 2 characters", + optional: true, + parse: String, + }, + "reported-user-agent": { + kind: "parsed", + brief: "Text not exceeding 255 characters", + optional: true, + parse: String, + }, + tele: { + kind: "parsed", + brief: "Text not exceeding 20 characters. This field may be released by Cloudflare to third parties such as the Lumen Database (https://lumendatabase.org/).", - }) - .option("title", { - type: "string", - description: "Text not exceeding 255 characters", - }) - .option("urls", { - type: "string", - description: + optional: true, + parse: String, + }, + title: { + kind: "parsed", + brief: "Text not exceeding 255 characters", + optional: true, + parse: String, + }, + urls: { + kind: "parsed", + brief: "A list of valid URLs separated by ‘\\n’ (new line character). The list of the URLs should not exceed 250 URLs. All URLs should have the same hostname. Each URL should be unique. This field may be released by Cloudflare to third parties such as the Lumen Database (https://lumendatabase.org/).", - }) - .option("address1", { - type: "string", - description: + optional: true, + parse: String, + }, + address1: { + kind: "parsed", + brief: "Text not exceeding 100 characters. This field may be released by Cloudflare to third parties such as the Lumen Database (https://lumendatabase.org/).", - }) - .option("agent-name", { - type: "string", - description: + optional: true, + parse: String, + }, + "agent-name": { + kind: "parsed", + brief: "The name of the copyright holder. Text not exceeding 60 characters. This field may be released by Cloudflare to third parties such as the Lumen Database (https://lumendatabase.org/).", - }) - .option("agree", { - type: "number", - description: + optional: true, + parse: String, + }, + agree: { + kind: "parsed", + brief: "Can be `0` for false or `1` for true. Must be value: 1 for DMCA reports", - }) - .option("city", { - type: "string", - description: + optional: true, + parse: Number, + }, + city: { + kind: "parsed", + brief: "Text not exceeding 255 characters. This field may be released by Cloudflare to third parties such as the Lumen Database (https://lumendatabase.org/).", - }) - .option("country", { - type: "string", - description: + optional: true, + parse: String, + }, + country: { + kind: "parsed", + brief: "Text not exceeding 255 characters. This field may be released by Cloudflare to third parties such as the Lumen Database (https://lumendatabase.org/).", - }) - .option("host-notification", { - type: "string", - description: + optional: true, + parse: String, + }, + "host-notification": { + kind: "parsed", + brief: "Notification type based on the abuse type. For delegated reports, the report—including contact information and comments—will be forwarded to the customer in full regardless of this value. NOTE: Copyright (DMCA) and Trademark reports cannot be anonymous.", + optional: true, choices: ["send", "send-anon"], - }) - .coerce("host-notification", (value) => - resolveFileToken(value, "host-notification", "text") - ) - .option("original-work", { - type: "string", - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "host-notification", "text"), + }, + "original-work": { + kind: "parsed", + brief: "Text not exceeding 255 characters. This field may be released by Cloudflare to third parties such as the Lumen Database (https://lumendatabase.org/).", - }) - .option("owner-notification", { - type: "string", - description: + optional: true, + parse: String, + }, + "owner-notification": { + kind: "parsed", + brief: "Notification type based on the abuse type. For delegated reports, the report—including contact information and comments—will be forwarded to the customer in full regardless of this value. NOTE: Copyright (DMCA) and Trademark reports cannot be anonymous.", + optional: true, choices: ["send", "send-anon", "none"], - }) - .coerce("owner-notification", (value) => - resolveFileToken(value, "owner-notification", "text") - ) - .option("signature", { - type: "string", - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "owner-notification", "text"), + }, + signature: { + kind: "parsed", + brief: "Required for DMCA reports, should be same as Name. An affirmation that all information in the report is true and accurate while agreeing to the policies of Cloudflare's abuse reports", - }) - .option("state", { - type: "string", - description: + optional: true, + parse: String, + }, + state: { + kind: "parsed", + brief: "Text not exceeding 255 characters. This field may be released by Cloudflare to third parties such as the Lumen Database (https://lumendatabase.org/).", - }) - .option("justification", { - type: "string", - description: + optional: true, + parse: String, + }, + justification: { + kind: "parsed", + brief: "A detailed description of the infringement, including any necessary access details and the exact steps needed to view the content, not exceeding 5000 characters.", - }) - .option("trademark-number", { - type: "string", - description: "Text not exceeding 1000 characters", - }) - .option("trademark-office", { - type: "string", - description: "Text not exceeding 1000 characters", - }) - .option("trademark-symbol", { - type: "string", - description: "Text not exceeding 1000 characters", - }) - .option("destination-ips", { - type: "string", - description: + optional: true, + parse: String, + }, + "trademark-number": { + kind: "parsed", + brief: "Text not exceeding 1000 characters", + optional: true, + parse: String, + }, + "trademark-office": { + kind: "parsed", + brief: "Text not exceeding 1000 characters", + optional: true, + parse: String, + }, + "trademark-symbol": { + kind: "parsed", + brief: "Text not exceeding 1000 characters", + optional: true, + parse: String, + }, + "destination-ips": { + kind: "parsed", + brief: "A list of IP addresses separated by ‘\\n’ (new line character). The list of destination IPs should not exceed 30 IP addresses. Each one of the IP addresses ought to be unique.", - }) - .option("ports-protocols", { - type: "string", - description: + optional: true, + parse: String, + }, + "ports-protocols": { + kind: "parsed", + brief: "A comma separated list of ports and protocols e.g. 80/TCP, 22/UDP. The total size of the field should not exceed 2000 characters. Each individual port/protocol should not exceed 100 characters. The list should not have more than 30 unique ports and protocols.", - }) - .option("source-ips", { - type: "string", - description: + optional: true, + parse: String, + }, + "source-ips": { + kind: "parsed", + brief: "A list of IP addresses separated by ‘\\n’ (new line character). The list of source IPs should not exceed 30 IP addresses. Each one of the IP addresses ought to be unique.", - }) - .option("ncmec-notification", { - type: "string", - description: + optional: true, + parse: String, + }, + "ncmec-notification": { + kind: "parsed", + brief: "Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark reports cannot be anonymous.\n", + optional: true, choices: ["send", "send-anon"], - }) - .coerce("ncmec-notification", (value) => - resolveFileToken(value, "ncmec-notification", "text") - ) - .option("reg-who-request-reg-who-authorization-statement", { - type: "string", - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "ncmec-notification", "text"), + }, + "reg-who-request-reg-who-authorization-statement": { + kind: "parsed", + brief: "Optional authorization statement or power of attorney per RDP 10.2.1.3.", - }) - .option("reg-who-request-reg-who-good-faith-affirmation", { - type: "boolean", - description: + optional: true, + parse: String, + }, + "reg-who-request-reg-who-good-faith-affirmation": { + kind: "boolean", + brief: "Affirmation that the request is made in good faith per RDP 10.2.4. Must be true.", - }) - .option("reg-who-request-reg-who-lawful-processing-agreement", { - type: "boolean", - description: - "Agreement to process data lawfully per RDP 10.2.5. Must be true.", - }) - .option("reg-who-request-reg-who-legal-basis", { - type: "string", - description: + optional: true, + }, + "reg-who-request-reg-who-lawful-processing-agreement": { + kind: "boolean", + brief: "Agreement to process data lawfully per RDP 10.2.5. Must be true.", + optional: true, + }, + "reg-who-request-reg-who-legal-basis": { + kind: "parsed", + brief: "Legal rights and rationale for the request per RDP 10.2.3. Required for all WHOIS requests.", - }) - .option("reg-who-request-reg-who-request-type", { - type: "string", - description: "The type of WHOIS data request per RDP procedure.", + optional: true, + parse: String, + }, + "reg-who-request-reg-who-request-type": { + kind: "parsed", + brief: "The type of WHOIS data request per RDP procedure.", + optional: true, choices: ["disclosure", "invalid_whois"], - }) - .coerce("reg-who-request-reg-who-request-type", (value) => - resolveFileToken(value, "reg-who-request-reg-who-request-type", "text") - ) - .option("reg-who-request-reg-who-requested-data-elements", { - type: "string", - array: true, - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "reg-who-request-reg-who-request-type", "text"), + }, + "reg-who-request-reg-who-requested-data-elements": { + kind: "parsed", + brief: "The specific WHOIS data elements being requested per RDP 10.2.2. Required for all WHOIS requests.", - }) - .option("reg-who-request-reg-who-requestor-type", { - type: "string", - description: "The nature of the requestor per RDP 10.2.1.2.", + variadic: true, + optional: true, + parse: String, + }, + "reg-who-request-reg-who-requestor-type": { + kind: "parsed", + brief: "The nature of the requestor per RDP 10.2.1.2.", + optional: true, choices: ["government", "corporation", "individual"], - }) - .coerce("reg-who-request-reg-who-requestor-type", (value) => - resolveFileToken(value, "reg-who-request-reg-who-requestor-type", "text") - ) - .option("ncsei-subject-representation", { - type: "boolean", - description: + parse: String, + coerce: (value: string) => + resolveFileToken( + value, + "reg-who-request-reg-who-requestor-type", + "text" + ), + }, + "ncsei-subject-representation": { + kind: "boolean", + brief: "If the submitter is the target of NCSEI in the URLs of the abuse report.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }) - .conflicts("address1", [ + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "report-type", + brief: "The report type to be submitted. Example: abuse_general", + parse: String, + }, + ], + rules(rules) { + rules.conflicts("address1", [ "justification", "trademark-number", "trademark-office", @@ -266,8 +341,8 @@ function builder(yargs: Argv) { "reg-who-request-reg-who-requested-data-elements", "reg-who-request-reg-who-requestor-type", "ncsei-subject-representation", - ]) - .implies("address1", [ + ]); + rules.implies("address1", [ "agent-name", "agree", "city", @@ -276,8 +351,8 @@ function builder(yargs: Argv) { "original-work", "signature", "state", - ]) - .conflicts("agent-name", [ + ]); + rules.conflicts("agent-name", [ "justification", "trademark-number", "trademark-office", @@ -294,8 +369,8 @@ function builder(yargs: Argv) { "reg-who-request-reg-who-requested-data-elements", "reg-who-request-reg-who-requestor-type", "ncsei-subject-representation", - ]) - .implies("agent-name", [ + ]); + rules.implies("agent-name", [ "address1", "agree", "city", @@ -304,8 +379,8 @@ function builder(yargs: Argv) { "original-work", "signature", "state", - ]) - .conflicts("agree", [ + ]); + rules.conflicts("agree", [ "justification", "trademark-number", "trademark-office", @@ -322,8 +397,8 @@ function builder(yargs: Argv) { "reg-who-request-reg-who-requested-data-elements", "reg-who-request-reg-who-requestor-type", "ncsei-subject-representation", - ]) - .implies("agree", [ + ]); + rules.implies("agree", [ "address1", "agent-name", "city", @@ -332,8 +407,8 @@ function builder(yargs: Argv) { "original-work", "signature", "state", - ]) - .conflicts("city", [ + ]); + rules.conflicts("city", [ "justification", "trademark-number", "trademark-office", @@ -350,8 +425,8 @@ function builder(yargs: Argv) { "reg-who-request-reg-who-requested-data-elements", "reg-who-request-reg-who-requestor-type", "ncsei-subject-representation", - ]) - .implies("city", [ + ]); + rules.implies("city", [ "address1", "agent-name", "agree", @@ -360,8 +435,8 @@ function builder(yargs: Argv) { "original-work", "signature", "state", - ]) - .conflicts("country", [ + ]); + rules.conflicts("country", [ "trademark-number", "trademark-office", "trademark-symbol", @@ -375,9 +450,9 @@ function builder(yargs: Argv) { "reg-who-request-reg-who-request-type", "reg-who-request-reg-who-requested-data-elements", "reg-who-request-reg-who-requestor-type", - ]) - .implies("country", ["host-notification"]) - .conflicts("host-notification", [ + ]); + rules.implies("country", ["host-notification"]); + rules.conflicts("host-notification", [ "reg-who-request-reg-who-authorization-statement", "reg-who-request-reg-who-good-faith-affirmation", "reg-who-request-reg-who-lawful-processing-agreement", @@ -385,8 +460,8 @@ function builder(yargs: Argv) { "reg-who-request-reg-who-request-type", "reg-who-request-reg-who-requested-data-elements", "reg-who-request-reg-who-requestor-type", - ]) - .conflicts("original-work", [ + ]); + rules.conflicts("original-work", [ "trademark-number", "trademark-office", "trademark-symbol", @@ -402,9 +477,9 @@ function builder(yargs: Argv) { "reg-who-request-reg-who-requested-data-elements", "reg-who-request-reg-who-requestor-type", "ncsei-subject-representation", - ]) - .implies("original-work", ["host-notification"]) - .conflicts("signature", [ + ]); + rules.implies("original-work", ["host-notification"]); + rules.conflicts("signature", [ "justification", "trademark-number", "trademark-office", @@ -421,8 +496,8 @@ function builder(yargs: Argv) { "reg-who-request-reg-who-requested-data-elements", "reg-who-request-reg-who-requestor-type", "ncsei-subject-representation", - ]) - .implies("signature", [ + ]); + rules.implies("signature", [ "address1", "agent-name", "agree", @@ -431,8 +506,8 @@ function builder(yargs: Argv) { "host-notification", "original-work", "state", - ]) - .conflicts("state", [ + ]); + rules.conflicts("state", [ "justification", "trademark-number", "trademark-office", @@ -449,8 +524,8 @@ function builder(yargs: Argv) { "reg-who-request-reg-who-requested-data-elements", "reg-who-request-reg-who-requestor-type", "ncsei-subject-representation", - ]) - .implies("state", [ + ]); + rules.implies("state", [ "address1", "agent-name", "agree", @@ -459,8 +534,8 @@ function builder(yargs: Argv) { "host-notification", "original-work", "signature", - ]) - .conflicts("justification", [ + ]); + rules.conflicts("justification", [ "address1", "agent-name", "agree", @@ -475,9 +550,9 @@ function builder(yargs: Argv) { "reg-who-request-reg-who-requested-data-elements", "reg-who-request-reg-who-requestor-type", "ncsei-subject-representation", - ]) - .implies("justification", ["host-notification"]) - .conflicts("trademark-number", [ + ]); + rules.implies("justification", ["host-notification"]); + rules.conflicts("trademark-number", [ "address1", "agent-name", "agree", @@ -498,14 +573,14 @@ function builder(yargs: Argv) { "reg-who-request-reg-who-requested-data-elements", "reg-who-request-reg-who-requestor-type", "ncsei-subject-representation", - ]) - .implies("trademark-number", [ + ]); + rules.implies("trademark-number", [ "host-notification", "justification", "trademark-office", "trademark-symbol", - ]) - .conflicts("trademark-office", [ + ]); + rules.conflicts("trademark-office", [ "address1", "agent-name", "agree", @@ -526,14 +601,14 @@ function builder(yargs: Argv) { "reg-who-request-reg-who-requested-data-elements", "reg-who-request-reg-who-requestor-type", "ncsei-subject-representation", - ]) - .implies("trademark-office", [ + ]); + rules.implies("trademark-office", [ "host-notification", "justification", "trademark-number", "trademark-symbol", - ]) - .conflicts("trademark-symbol", [ + ]); + rules.conflicts("trademark-symbol", [ "address1", "agent-name", "agree", @@ -554,14 +629,14 @@ function builder(yargs: Argv) { "reg-who-request-reg-who-requested-data-elements", "reg-who-request-reg-who-requestor-type", "ncsei-subject-representation", - ]) - .implies("trademark-symbol", [ + ]); + rules.implies("trademark-symbol", [ "host-notification", "justification", "trademark-number", "trademark-office", - ]) - .conflicts("destination-ips", [ + ]); + rules.conflicts("destination-ips", [ "address1", "agent-name", "agree", @@ -582,9 +657,9 @@ function builder(yargs: Argv) { "reg-who-request-reg-who-requested-data-elements", "reg-who-request-reg-who-requestor-type", "ncsei-subject-representation", - ]) - .implies("destination-ips", ["host-notification", "justification"]) - .conflicts("ports-protocols", [ + ]); + rules.implies("destination-ips", ["host-notification", "justification"]); + rules.conflicts("ports-protocols", [ "address1", "agent-name", "agree", @@ -605,9 +680,9 @@ function builder(yargs: Argv) { "reg-who-request-reg-who-requested-data-elements", "reg-who-request-reg-who-requestor-type", "ncsei-subject-representation", - ]) - .implies("ports-protocols", ["host-notification", "justification"]) - .conflicts("source-ips", [ + ]); + rules.implies("ports-protocols", ["host-notification", "justification"]); + rules.conflicts("source-ips", [ "address1", "agent-name", "agree", @@ -628,9 +703,9 @@ function builder(yargs: Argv) { "reg-who-request-reg-who-requested-data-elements", "reg-who-request-reg-who-requestor-type", "ncsei-subject-representation", - ]) - .implies("source-ips", ["host-notification", "justification"]) - .conflicts("ncmec-notification", [ + ]); + rules.implies("source-ips", ["host-notification", "justification"]); + rules.conflicts("ncmec-notification", [ "address1", "agent-name", "agree", @@ -652,9 +727,9 @@ function builder(yargs: Argv) { "reg-who-request-reg-who-requested-data-elements", "reg-who-request-reg-who-requestor-type", "ncsei-subject-representation", - ]) - .implies("ncmec-notification", ["host-notification", "justification"]) - .conflicts("reg-who-request-reg-who-authorization-statement", [ + ]); + rules.implies("ncmec-notification", ["host-notification", "justification"]); + rules.conflicts("reg-who-request-reg-who-authorization-statement", [ "address1", "agent-name", "agree", @@ -673,15 +748,15 @@ function builder(yargs: Argv) { "source-ips", "ncmec-notification", "ncsei-subject-representation", - ]) - .implies("reg-who-request-reg-who-authorization-statement", [ + ]); + rules.implies("reg-who-request-reg-who-authorization-statement", [ "reg-who-request-reg-who-good-faith-affirmation", "reg-who-request-reg-who-lawful-processing-agreement", "reg-who-request-reg-who-legal-basis", "reg-who-request-reg-who-request-type", "reg-who-request-reg-who-requested-data-elements", - ]) - .conflicts("reg-who-request-reg-who-good-faith-affirmation", [ + ]); + rules.conflicts("reg-who-request-reg-who-good-faith-affirmation", [ "address1", "agent-name", "agree", @@ -700,14 +775,14 @@ function builder(yargs: Argv) { "source-ips", "ncmec-notification", "ncsei-subject-representation", - ]) - .implies("reg-who-request-reg-who-good-faith-affirmation", [ + ]); + rules.implies("reg-who-request-reg-who-good-faith-affirmation", [ "reg-who-request-reg-who-lawful-processing-agreement", "reg-who-request-reg-who-legal-basis", "reg-who-request-reg-who-request-type", "reg-who-request-reg-who-requested-data-elements", - ]) - .conflicts("reg-who-request-reg-who-lawful-processing-agreement", [ + ]); + rules.conflicts("reg-who-request-reg-who-lawful-processing-agreement", [ "address1", "agent-name", "agree", @@ -726,14 +801,14 @@ function builder(yargs: Argv) { "source-ips", "ncmec-notification", "ncsei-subject-representation", - ]) - .implies("reg-who-request-reg-who-lawful-processing-agreement", [ + ]); + rules.implies("reg-who-request-reg-who-lawful-processing-agreement", [ "reg-who-request-reg-who-good-faith-affirmation", "reg-who-request-reg-who-legal-basis", "reg-who-request-reg-who-request-type", "reg-who-request-reg-who-requested-data-elements", - ]) - .conflicts("reg-who-request-reg-who-legal-basis", [ + ]); + rules.conflicts("reg-who-request-reg-who-legal-basis", [ "address1", "agent-name", "agree", @@ -752,14 +827,14 @@ function builder(yargs: Argv) { "source-ips", "ncmec-notification", "ncsei-subject-representation", - ]) - .implies("reg-who-request-reg-who-legal-basis", [ + ]); + rules.implies("reg-who-request-reg-who-legal-basis", [ "reg-who-request-reg-who-good-faith-affirmation", "reg-who-request-reg-who-lawful-processing-agreement", "reg-who-request-reg-who-request-type", "reg-who-request-reg-who-requested-data-elements", - ]) - .conflicts("reg-who-request-reg-who-request-type", [ + ]); + rules.conflicts("reg-who-request-reg-who-request-type", [ "address1", "agent-name", "agree", @@ -778,14 +853,14 @@ function builder(yargs: Argv) { "source-ips", "ncmec-notification", "ncsei-subject-representation", - ]) - .implies("reg-who-request-reg-who-request-type", [ + ]); + rules.implies("reg-who-request-reg-who-request-type", [ "reg-who-request-reg-who-good-faith-affirmation", "reg-who-request-reg-who-lawful-processing-agreement", "reg-who-request-reg-who-legal-basis", "reg-who-request-reg-who-requested-data-elements", - ]) - .conflicts("reg-who-request-reg-who-requested-data-elements", [ + ]); + rules.conflicts("reg-who-request-reg-who-requested-data-elements", [ "address1", "agent-name", "agree", @@ -804,14 +879,14 @@ function builder(yargs: Argv) { "source-ips", "ncmec-notification", "ncsei-subject-representation", - ]) - .implies("reg-who-request-reg-who-requested-data-elements", [ + ]); + rules.implies("reg-who-request-reg-who-requested-data-elements", [ "reg-who-request-reg-who-good-faith-affirmation", "reg-who-request-reg-who-lawful-processing-agreement", "reg-who-request-reg-who-legal-basis", "reg-who-request-reg-who-request-type", - ]) - .conflicts("reg-who-request-reg-who-requestor-type", [ + ]); + rules.conflicts("reg-who-request-reg-who-requestor-type", [ "address1", "agent-name", "agree", @@ -830,15 +905,15 @@ function builder(yargs: Argv) { "source-ips", "ncmec-notification", "ncsei-subject-representation", - ]) - .implies("reg-who-request-reg-who-requestor-type", [ + ]); + rules.implies("reg-who-request-reg-who-requestor-type", [ "reg-who-request-reg-who-good-faith-affirmation", "reg-who-request-reg-who-lawful-processing-agreement", "reg-who-request-reg-who-legal-basis", "reg-who-request-reg-who-request-type", "reg-who-request-reg-who-requested-data-elements", - ]) - .conflicts("ncsei-subject-representation", [ + ]); + rules.conflicts("ncsei-subject-representation", [ "address1", "agent-name", "agree", @@ -861,16 +936,9 @@ function builder(yargs: Argv) { "reg-who-request-reg-who-request-type", "reg-who-request-reg-who-requested-data-elements", "reg-who-request-reg-who-requestor-type", - ]) - .implies("ncsei-subject-representation", ["host-notification"]); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "create ", - describe: "Submit an abuse report", - builder, + ]); + rules.implies("ncsei-subject-representation", ["host-notification"]); + }, handler: async (argv): Promise => runWithTelemetry( { @@ -888,7 +956,7 @@ const command: CommandModule = { "ncsei-subject-representation", "dry-run", ], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -1462,6 +1530,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/abuse-reports/emails/index.ts b/packages/cli/src/commands/_generated/abuse-reports/emails/index.ts index 93b43d08b1..be85f2fb38 100644 --- a/packages/cli/src/commands/_generated/abuse-reports/emails/index.ts +++ b/packages/cli/src/commands/_generated/abuse-reports/emails/index.ts @@ -1,24 +1,19 @@ import $listsubmitted from "./list-submitted.js"; import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * emails command group * @generated from apis/overlays/abuse-reports.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "emails", describe: "Emails sent for abuse reports", - builder: (yargs) => { - return yargs - .command($list) - .command($listsubmitted) - .demandCommand(1, "Please specify a subcommand"); + routes: { + list: $list, + "list-submitted": $listsubmitted, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/abuse-reports/emails/list-submitted.ts b/packages/cli/src/commands/_generated/abuse-reports/emails/list-submitted.ts index cd4ebe1e26..23184a3974 100644 --- a/packages/cli/src/commands/_generated/abuse-reports/emails/list-submitted.ts +++ b/packages/cli/src/commands/_generated/abuse-reports/emails/list-submitted.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/abuse-reports/emails/list-submitted.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list-submitted command * @generated from apis/overlays/abuse-reports.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,44 +16,40 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 abuse-reports emails list-submitted \n\nList successful emails sent to the submitter of a report submitted by the account. Does not include emails sent to customers or hosts." - ) - .positional("report-id", { - type: "string", - description: "Public report code.", - demandOption: true, - }) - .option("page", { - type: "number", - description: "Page number to retrieve (default 1).", - }) - .option("per-page", { - type: "number", - description: "Number of emails per page (default 20, max 100).", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list-submitted ", describe: "List emails sent to an abuse report submitter", - builder, + usage: + "$0 abuse-reports emails list-submitted \n\nList successful emails sent to the submitter of a report submitted by the account. Does not include emails sent to customers or hosts.", + flags: { + page: { + kind: "parsed", + brief: "Page number to retrieve (default 1).", + optional: true, + parse: Number, + }, + "per-page": { + kind: "parsed", + brief: "Number of emails per page (default 20, max 100).", + optional: true, + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { placeholder: "report-id", brief: "Public report code.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "abuse-reports emails list-submitted", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -88,6 +83,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/abuse-reports/emails/list.ts b/packages/cli/src/commands/_generated/abuse-reports/emails/list.ts index 194f415fe5..de0f7f7168 100644 --- a/packages/cli/src/commands/_generated/abuse-reports/emails/list.ts +++ b/packages/cli/src/commands/_generated/abuse-reports/emails/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/abuse-reports/emails/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/abuse-reports.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,44 +16,39 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 abuse-reports emails list\n\nList emails sent to the customer for an abuse report. Returns all successful customer emails sent for the specified abuse report. Does not include emails sent to hosts or submitters." - ) - .option("report-id", { - type: "string", - description: "Abuse Report ID", - demandOption: true, - }) - .option("page", { - type: "number", - description: "Page number to retrieve (default 1)", - }) - .option("per-page", { - type: "number", - description: "Number of emails per page (default 20, max 100)", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List abuse report emails", - builder, + usage: + "$0 abuse-reports emails list\n\nList emails sent to the customer for an abuse report. Returns all successful customer emails sent for the specified abuse report. Does not include emails sent to hosts or submitters.", + flags: { + "report-id": { kind: "parsed", brief: "Abuse Report ID", parse: String }, + page: { + kind: "parsed", + brief: "Page number to retrieve (default 1)", + optional: true, + parse: Number, + }, + "per-page": { + kind: "parsed", + brief: "Number of emails per page (default 20, max 100)", + optional: true, + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "abuse-reports emails list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -88,6 +82,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/abuse-reports/get-submitted.ts b/packages/cli/src/commands/_generated/abuse-reports/get-submitted.ts index 693cb10f75..884c21877b 100644 --- a/packages/cli/src/commands/_generated/abuse-reports/get-submitted.ts +++ b/packages/cli/src/commands/_generated/abuse-reports/get-submitted.ts @@ -1,11 +1,10 @@ import operation from "../_operations/abuse-reports/get-submitted.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get-submitted command * @generated from apis/overlays/abuse-reports.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,28 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 abuse-reports get-submitted \n\nRetrieve a report submitted by the account." - ) - .positional("report-id", { - type: "string", - description: "Public report code.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get-submitted ", describe: "Get a submitted abuse report", - builder, + usage: + "$0 abuse-reports get-submitted \n\nRetrieve a report submitted by the account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { placeholder: "report-id", brief: "Public report code.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "abuse-reports get-submitted", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -74,6 +65,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/abuse-reports/get.ts b/packages/cli/src/commands/_generated/abuse-reports/get.ts index 20e9a34d59..de9bf029c2 100644 --- a/packages/cli/src/commands/_generated/abuse-reports/get.ts +++ b/packages/cli/src/commands/_generated/abuse-reports/get.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/abuse-reports.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,28 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 abuse-reports get \n\nRetrieve the details of an abuse report made against a domain or other content associated with the account. To retrieve a report that the account submitted, use the submitted abuse report endpoint instead." - ) - .positional("report-id", { - type: "string", - description: "Public report ID.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get an abuse report against the account", - builder, + usage: + "$0 abuse-reports get \n\nRetrieve the details of an abuse report made against a domain or other content associated with the account. To retrieve a report that the account submitted, use the submitted abuse report endpoint instead.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { placeholder: "report-id", brief: "Public report ID.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "abuse-reports get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -75,6 +66,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/abuse-reports/index.ts b/packages/cli/src/commands/_generated/abuse-reports/index.ts index 72b6eaaae5..f8bccab6a2 100644 --- a/packages/cli/src/commands/_generated/abuse-reports/index.ts +++ b/packages/cli/src/commands/_generated/abuse-reports/index.ts @@ -6,32 +6,27 @@ import $get from "./get.js"; import $listsubmitted from "./list-submitted.js"; import $list from "./list.js"; import $mitigations from "./mitigations/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * abuse-reports command * @generated from apis/overlays/abuse-reports.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "abuse-reports", describe: "Submit and track abuse reports for phishing, malware, and other policy violations on Cloudflare-proxied sites", - builder: (yargs) => { - return yargs - .command($create) - .command($get) - .command($getsubmitted) - .command($list) - .command($listsubmitted) - .command($appeals) - .command($emails) - .command($mitigations) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + get: $get, + "get-submitted": $getsubmitted, + list: $list, + "list-submitted": $listsubmitted, + appeals: $appeals, + emails: $emails, + mitigations: $mitigations, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/abuse-reports/list-submitted.ts b/packages/cli/src/commands/_generated/abuse-reports/list-submitted.ts index d615fe1e2b..759ee44cde 100644 --- a/packages/cli/src/commands/_generated/abuse-reports/list-submitted.ts +++ b/packages/cli/src/commands/_generated/abuse-reports/list-submitted.ts @@ -1,11 +1,10 @@ import operation from "../_operations/abuse-reports/list-submitted.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list-submitted command * @generated from apis/overlays/abuse-reports.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,54 +16,73 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 abuse-reports list-submitted\n\nList abuse reports submitted by the account." - ) - .option("page", { - type: "number", - description: "Page of submitted reports to return.", - }) - .option("per-page", { - type: "number", - description: "Number of submitted reports per page.", - }) - .option("sort", { - type: "string", - description: +const command = apiCommand({ + command: "list-submitted", + describe: "List submitted abuse reports", + usage: + "$0 abuse-reports list-submitted\n\nList abuse reports submitted by the account.", + flags: { + page: { + kind: "parsed", + brief: "Page of submitted reports to return.", + optional: true, + parse: Number, + }, + "per-page": { + kind: "parsed", + brief: "Number of submitted reports per page.", + optional: true, + parse: Number, + }, + sort: { + kind: "parsed", + brief: "A property and direction to sort by (id, cdate, domain, type, status).", - }) - .option("id", { type: "string", description: "Filter by report code." }) - .option("domain", { - type: "string", - array: true, - description: + optional: true, + parse: String, + }, + id: { + kind: "parsed", + brief: "Filter by report code.", + optional: true, + parse: String, + }, + domain: { + kind: "parsed", + brief: "Filter by reported domain. This parameter can be specified multiple times.", - }) - .option("created-before", { - type: "string", - description: "Return reports submitted before this time.", - }) - .option("created-after", { - type: "string", - description: "Return reports submitted after this time.", - }) - .option("status", { - type: "string", - array: true, - description: + variadic: true, + optional: true, + parse: String, + }, + "created-before": { + kind: "parsed", + brief: "Return reports submitted before this time.", + optional: true, + parse: String, + }, + "created-after": { + kind: "parsed", + brief: "Return reports submitted after this time.", + optional: true, + parse: String, + }, + status: { + kind: "parsed", + brief: "Filter by submitter-facing status. This parameter can be specified multiple times.", + variadic: true, + optional: true, choices: ["submitted", "accepted", "denied"], - }) - .coerce("status", (values: string[]) => - values.flatMap((value) => value.split(",")) - ) - .option("type", { - type: "string", - array: true, - description: + parse: String, + coerce: (values: string[]) => values.flatMap((value) => value.split(",")), + }, + type: { + kind: "parsed", + brief: "Filter by report type. This parameter can be specified multiple times.", + variadic: true, + optional: true, choices: [ "PHISH", "GEN", @@ -76,30 +94,23 @@ function builder(yargs: Argv) { "NCSEI", "NETWORK", ], - }) - .coerce("type", (values: string[]) => - values.flatMap((value) => value.split(",")) - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + parse: String, + coerce: (values: string[]) => values.flatMap((value) => value.split(",")), + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "list-submitted", - describe: "List submitted abuse reports", - builder, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "abuse-reports list-submitted", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -136,6 +147,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/abuse-reports/list.ts b/packages/cli/src/commands/_generated/abuse-reports/list.ts index 423176976b..cd6946d2c2 100644 --- a/packages/cli/src/commands/_generated/abuse-reports/list.ts +++ b/packages/cli/src/commands/_generated/abuse-reports/list.ts @@ -1,11 +1,10 @@ import operation from "../_operations/abuse-reports/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/abuse-reports.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,50 +16,66 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 abuse-reports list\n\nList abuse reports made against domains or other content associated with the account. To list reports that the account submitted, use the submitted abuse reports endpoint instead." - ) - .option("page", { - type: "number", - description: "Where in pagination to start listing abuse reports", - }) - .option("per-page", { - type: "number", - description: "How many abuse reports per page to list", - }) - .option("sort", { - type: "string", - description: +const command = apiCommand({ + command: "list", + describe: "List abuse reports against the account", + usage: + "$0 abuse-reports list\n\nList abuse reports made against domains or other content associated with the account. To list reports that the account submitted, use the submitted abuse reports endpoint instead.", + flags: { + page: { + kind: "parsed", + brief: "Where in pagination to start listing abuse reports", + optional: true, + parse: Number, + }, + "per-page": { + kind: "parsed", + brief: "How many abuse reports per page to list", + optional: true, + parse: Number, + }, + sort: { + kind: "parsed", + brief: "A property to sort by, followed by the order (id, cdate, domain, type, status)", - }) - .option("search", { - type: "string", - description: + optional: true, + parse: String, + }, + search: { + kind: "parsed", + brief: "Free-text search. Returns reports whose report ID starts with the term or whose domain contains the term, both case-insensitively. Surrounding whitespace is ignored, and an empty value is treated as absent. Combined with the other filters using AND.", - }) - .option("domain", { - type: "string", - description: "Filter by domain name related to the abuse report", - }) - .option("created-before", { - type: "string", - description: "Returns reports created before the specified date", - }) - .option("created-after", { - type: "string", - description: "Returns reports created after the specified date", - }) - .option("status", { - type: "string", - description: "Filter by the status of the report.", - choices: ["accepted", "in_review"], - }) - .option("type", { - type: "string", - description: "Filter by the type of the report.", - choices: [ + optional: true, + parse: String, + }, + domain: { + kind: "parsed", + brief: "Filter by domain name related to the abuse report", + optional: true, + parse: String, + }, + "created-before": { + kind: "parsed", + brief: "Returns reports created before the specified date", + optional: true, + parse: String, + }, + "created-after": { + kind: "parsed", + brief: "Returns reports created after the specified date", + optional: true, + parse: String, + }, + status: { + kind: "enum", + brief: "Filter by the status of the report.", + values: ["accepted", "in_review"], + optional: true, + }, + type: { + kind: "enum", + brief: "Filter by the type of the report.", + values: [ "PHISH", "GEN", "THREAT", @@ -71,31 +86,27 @@ function builder(yargs: Argv) { "NCSEI", "NETWORK", ], - }) - .option("mitigation-status", { - type: "string", - description: - "Filter reports that have any mitigations in the given status.", - choices: ["pending", "active", "in_review", "cancelled", "removed"], - }) - .option("pending-notice", { - type: "boolean", - description: + optional: true, + }, + "mitigation-status": { + kind: "enum", + brief: "Filter reports that have any mitigations in the given status.", + values: ["pending", "active", "in_review", "cancelled", "removed"], + optional: true, + }, + "pending-notice": { + kind: "boolean", + brief: "Also include reports in an open Notice and Takedown notice period. Combined with mitigation_status using OR, e.g. ?mitigation_status=active&pending_notice=true.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "list", - describe: "List abuse reports against the account", - builder, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { @@ -108,7 +119,7 @@ const command: CommandModule = { "pending-notice", "dry-run", ], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -147,6 +158,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/abuse-reports/mitigations/index.ts b/packages/cli/src/commands/_generated/abuse-reports/mitigations/index.ts index c06d993e61..ce965534cb 100644 --- a/packages/cli/src/commands/_generated/abuse-reports/mitigations/index.ts +++ b/packages/cli/src/commands/_generated/abuse-reports/mitigations/index.ts @@ -1,24 +1,19 @@ import $list from "./list.js"; import $review from "./review.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * mitigations command group * @generated from apis/overlays/abuse-reports.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "mitigations", describe: "Mitigation actions taken in response to abuse reports", - builder: (yargs) => { - return yargs - .command($list) - .command($review) - .demandCommand(1, "Please specify a subcommand"); + routes: { + list: $list, + review: $review, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/abuse-reports/mitigations/list.ts b/packages/cli/src/commands/_generated/abuse-reports/mitigations/list.ts index 4d2ab8f47f..23dd281391 100644 --- a/packages/cli/src/commands/_generated/abuse-reports/mitigations/list.ts +++ b/packages/cli/src/commands/_generated/abuse-reports/mitigations/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/abuse-reports/mitigations/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/abuse-reports.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,28 +16,29 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 abuse-reports mitigations list\n\nList mitigations done to remediate the abuse report." - ) - .option("report-id", { - type: "string", - description: "Abuse Report ID", - demandOption: true, - }) - .option("page", { - type: "number", - description: "Where in pagination to start listing abuse reports", - }) - .option("per-page", { - type: "number", - description: "How many abuse reports per page to list", - }) - .option("sort", { - type: "string", - description: "A property to sort by, followed by the order", - choices: [ +const command = apiCommand({ + command: "list", + describe: "List abuse report mitigations", + usage: + "$0 abuse-reports mitigations list\n\nList mitigations done to remediate the abuse report.", + flags: { + "report-id": { kind: "parsed", brief: "Abuse Report ID", parse: String }, + page: { + kind: "parsed", + brief: "Where in pagination to start listing abuse reports", + optional: true, + parse: Number, + }, + "per-page": { + kind: "parsed", + brief: "How many abuse reports per page to list", + optional: true, + parse: Number, + }, + sort: { + kind: "enum", + brief: "A property to sort by, followed by the order", + values: [ "type,asc", "type,desc", "effective_date,asc", @@ -48,58 +48,53 @@ function builder(yargs: Argv) { "entity_type,asc", "entity_type,desc", ], - }) - .option("type", { - type: "string", - description: + optional: true, + }, + type: { + kind: "parsed", + brief: "Filter by the type of mitigation. This filter parameter can be specified multiple times to include multiple types of mitigations in the result set.", - }) - .option("effective-before", { - type: "string", - description: - "Returns mitigations that were dispatched before the given date", - }) - .option("effective-after", { - type: "string", - description: - "Returns mitigation that were dispatched after the given date", - }) - .option("status", { - type: "string", - description: "Filter by the status of the mitigation.", - choices: ["pending", "active", "in_review", "cancelled", "removed"], - }) - .option("entity-type", { - type: "string", - description: "Filter by the type of entity the mitigation impacts.", - choices: [ - "url_pattern", - "account", - "zone", - "domain", - "custom_expression", - ], - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "effective-before": { + kind: "parsed", + brief: "Returns mitigations that were dispatched before the given date", + optional: true, + parse: String, + }, + "effective-after": { + kind: "parsed", + brief: "Returns mitigation that were dispatched after the given date", + optional: true, + parse: String, + }, + status: { + kind: "enum", + brief: "Filter by the status of the mitigation.", + values: ["pending", "active", "in_review", "cancelled", "removed"], + optional: true, + }, + "entity-type": { + kind: "enum", + brief: "Filter by the type of entity the mitigation impacts.", + values: ["url_pattern", "account", "zone", "domain", "custom_expression"], + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "list", - describe: "List abuse report mitigations", - builder, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "abuse-reports mitigations list", classification: { safeFlags: ["sort", "status", "entity-type", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -139,6 +134,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/abuse-reports/mitigations/review.ts b/packages/cli/src/commands/_generated/abuse-reports/mitigations/review.ts index 387c6b86fd..cb2ff43716 100644 --- a/packages/cli/src/commands/_generated/abuse-reports/mitigations/review.ts +++ b/packages/cli/src/commands/_generated/abuse-reports/mitigations/review.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/abuse-reports/mitigations/review.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * review command * @generated from apis/overlays/abuse-reports.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,97 +18,135 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 abuse-reports mitigations review \n\nRequest a review of mitigations applied because of an abuse report, or submit a report-level appeal. - To request a review of specific mitigations, send `appeals` with the mitigation IDs and reasons. Repeating a request for a mitigation with an unresolved appeal is idempotent and returns that mitigation in the in-review state. - To submit a report-level appeal, send `type` and, for a `counter_notice`, the counter-notice details in `data`. Report-level appeals are currently available only for DMCA (copyright) reports." - ) - .positional("report-id", { - type: "string", - description: "Abuse Report ID", - demandOption: true, - }) - .option("appeals", { - type: "string", - description: +const command = apiCommand({ + command: "review ", + describe: "Request review on mitigations", + usage: + "$0 abuse-reports mitigations review \n\nRequest a review of mitigations applied because of an abuse report, or submit a report-level appeal. - To request a review of specific mitigations, send `appeals` with the mitigation IDs and reasons. Repeating a request for a mitigation with an unresolved appeal is idempotent and returns that mitigation in the in-review state. - To submit a report-level appeal, send `type` and, for a `counter_notice`, the counter-notice details in `data`. Report-level appeals are currently available only for DMCA (copyright) reports.", + flags: { + appeals: { + kind: "parsed", + brief: 'List of mitigations to appeal. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"id": string, "reason": "removed" | "misclassified"}].', - }) - .option("data-city", { type: "string", description: "The data.city field" }) - .option("data-company", { - type: "string", - description: "The data.company field", - }) - .option("data-counter-notice-response", { - type: "string", - description: "The data.counter_notice_response field", - }) - .option("data-country", { - type: "string", - description: "The data.country field", - }) - .option("data-email", { - type: "string", - description: "The data.email field", - }) - .option("data-full-name", { - type: "string", - description: "The data.full_name field", - }) - .option("data-jurisdiction-consent", { - type: "boolean", - description: "The data.jurisdiction_consent field", - }) - .option("data-perjury-attestation", { - type: "boolean", - description: "The data.perjury_attestation field", - }) - .option("data-phone-number", { - type: "string", - description: "The data.phone_number field", - }) - .option("data-signature", { - type: "string", - description: "The data.signature field", - }) - .option("data-state", { - type: "string", - description: "The data.state field", - }) - .option("data-street-address", { - type: "string", - description: "The data.street_address field", - }) - .option("data-urls", { - type: "string", - array: true, - description: "The data.urls field", - }) - .option("data-zip-code", { - type: "string", - description: "The data.zip_code field", - }) - .option("explanation", { - type: "string", - description: + optional: true, + parse: String, + }, + "data-city": { + kind: "parsed", + brief: "The data.city field", + optional: true, + parse: String, + }, + "data-company": { + kind: "parsed", + brief: "The data.company field", + optional: true, + parse: String, + }, + "data-counter-notice-response": { + kind: "parsed", + brief: "The data.counter_notice_response field", + optional: true, + parse: String, + }, + "data-country": { + kind: "parsed", + brief: "The data.country field", + optional: true, + parse: String, + }, + "data-email": { + kind: "parsed", + brief: "The data.email field", + optional: true, + parse: String, + }, + "data-full-name": { + kind: "parsed", + brief: "The data.full_name field", + optional: true, + parse: String, + }, + "data-jurisdiction-consent": { + kind: "boolean", + brief: "The data.jurisdiction_consent field", + optional: true, + }, + "data-perjury-attestation": { + kind: "boolean", + brief: "The data.perjury_attestation field", + optional: true, + }, + "data-phone-number": { + kind: "parsed", + brief: "The data.phone_number field", + optional: true, + parse: String, + }, + "data-signature": { + kind: "parsed", + brief: "The data.signature field", + optional: true, + parse: String, + }, + "data-state": { + kind: "parsed", + brief: "The data.state field", + optional: true, + parse: String, + }, + "data-street-address": { + kind: "parsed", + brief: "The data.street_address field", + optional: true, + parse: String, + }, + "data-urls": { + kind: "parsed", + brief: "The data.urls field", + variadic: true, + optional: true, + parse: String, + }, + "data-zip-code": { + kind: "parsed", + brief: "The data.zip_code field", + optional: true, + parse: String, + }, + explanation: { + kind: "parsed", + brief: 'Optional explanation for a "content_removed" appeal, such as how the content was removed. Not accepted for other appeal types.', - }) - .option("type", { - type: "string", - description: "The type of appeal being submitted.", + optional: true, + parse: String, + }, + type: { + kind: "parsed", + brief: "The type of appeal being submitted.", + optional: true, choices: ["counter_notice", "content_removed"], - }) - .coerce("type", (value) => resolveFileToken(value, "type", "text")) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + parse: String, + coerce: (value: string) => resolveFileToken(value, "type", "text"), + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: - 'Submit an appeal for a report. Provide either a list of mitigations to appeal, or an appeal type with its supporting details, but not both. When type is "counter_notice", the counter-notice details are required. A "content_removed" appeal takes an optional explanation instead and is accepted only while the report is in its Notice and Takedown notice period (\`has_pending_notice\` on the eligibility response). Reports that allow a single appeal (\`max_appeals\` of 1) never have a notice period and accept it whenever \`appealable\` is true.', - }) - .check((argv) => { + }, + body: { + kind: "parsed", + brief: + 'Submit an appeal for a report. Provide either a list of mitigations to appeal, or an appeal type with its supporting details, but not both. When type is "counter_notice", the counter-notice details are required. A "content_removed" appeal takes an optional explanation instead and is accepted only while the report is in its Notice and Takedown notice period (`has_pending_notice` on the eligibility response). Reports that allow a single appeal (`max_appeals` of 1) never have a notice period and accept it whenever `appealable` is true.', + optional: true, + parse: String, + }, + }, + operands: [ + { placeholder: "report-id", brief: "Abuse Report ID", parse: String }, + ], + rules(rules) { + rules.check((argv) => { const groupSet = [ "data-city", "data-company", @@ -149,14 +186,7 @@ function builder(yargs: Argv) { } return true; }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "review ", - describe: "Request review on mitigations", - builder, + }, handler: async (argv): Promise => runWithTelemetry( { @@ -168,7 +198,7 @@ const command: CommandModule = { "type", "dry-run", ], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -356,6 +386,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/access/index.ts b/packages/cli/src/commands/_generated/access/index.ts index 770fe340bc..8ec686062d 100644 --- a/packages/cli/src/commands/_generated/access/index.ts +++ b/packages/cli/src/commands/_generated/access/index.ts @@ -1,33 +1,28 @@ -import type { CommonYargsOptions } from "#lib/cli-types.js"; -/** - * access command - * @generated from apis/overlays/access.ts - */ -import type { CommandModule } from "yargs"; import $curl from "#commands/access/curl/index.js"; import $login from "#commands/access/login/index.js"; import $sshconfig from "#commands/access/ssh-config/index.js"; import $sshgen from "#commands/access/ssh-gen/index.js"; import $tcp from "#commands/access/tcp/index.js"; import $token from "#commands/access/token/index.js"; +/** + * access command + * @generated from apis/overlays/access.ts + */ +import { apiGroup } from "#lib/api-command.js"; import { withHandWrittenDryRun } from "#lib/hand-written-dry-run.js"; -const command: CommandModule = { +const command = apiGroup({ command: "access", describe: "Access protected applications and services", - builder: (yargs) => { - return yargs - .command(withHandWrittenDryRun($curl, "preview")) - .command(withHandWrittenDryRun($login, "preview")) - .command(withHandWrittenDryRun($sshconfig, "preview")) - .command(withHandWrittenDryRun($sshgen, "preview")) - .command(withHandWrittenDryRun($tcp, "preview")) - .command(withHandWrittenDryRun($token, "preview")) - .demandCommand(1, "Please specify a subcommand"); + routes: { + curl: withHandWrittenDryRun($curl, "preview"), + login: withHandWrittenDryRun($login, "preview"), + "ssh-config": withHandWrittenDryRun($sshconfig, "preview"), + "ssh-gen": withHandWrittenDryRun($sshgen, "preview"), + tcp: withHandWrittenDryRun($tcp, "preview"), + token: withHandWrittenDryRun($token, "preview"), }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/applications/create.ts b/packages/cli/src/commands/_generated/accounts/applications/create.ts index d6b395ae05..5888e0f741 100644 --- a/packages/cli/src/commands/_generated/accounts/applications/create.ts +++ b/packages/cli/src/commands/_generated/accounts/applications/create.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/applications/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,67 +19,81 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts applications create\n\nCreate a custom application for an account from a name, category, and optional network matchers." - ) - .option("category-id", { - type: "number", - description: "Numeric identifier for an application category.", - }) - .option("hostnames", { - type: "string", - array: true, - description: "Hostnames matched by the application.", - }) - .option("human-id", { - type: "string", - description: "Human-readable identifier for the application.", - }) - .option("ip-subnets", { - type: "string", - array: true, - description: +const command = apiCommand({ + command: "create", + describe: "Create application", + usage: + "$0 accounts applications create\n\nCreate a custom application for an account from a name, category, and optional network matchers.", + flags: { + "category-id": { + kind: "parsed", + brief: "Numeric identifier for an application category.", + optional: true, + parse: Number, + }, + hostnames: { + kind: "parsed", + brief: "Hostnames matched by the application.", + variadic: true, + optional: true, + parse: String, + }, + "human-id": { + kind: "parsed", + brief: "Human-readable identifier for the application.", + optional: true, + parse: String, + }, + "ip-subnets": { + kind: "parsed", + brief: "IP subnets for this application. Custom application create and update requests accept IPv4 prefix lengths /8 through /32 and IPv6 prefix lengths /32 through /128.", - }) - .option("name", { type: "string", description: "Application name." }) - .option("port-protocols", { - type: "string", - array: true, - description: + variadic: true, + optional: true, + parse: String, + }, + name: { + kind: "parsed", + brief: "Application name.", + optional: true, + parse: String, + }, + "port-protocols": { + kind: "parsed", + brief: "Ports matched by the application, in `protocol/port` or inclusive `protocol/start-end` format (for example, `tcp/443` or `udp/10000-20000`). TCP and UDP ports must be between 0 and 65535.", - }) - .option("support-domains", { - type: "string", - array: true, - description: "Support domains matched by the application.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + variadic: true, + optional: true, + parse: String, + }, + "support-domains": { + kind: "parsed", + brief: "Support domains matched by the application.", + variadic: true, + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: - "Defines a custom application. At least one hostname or IP subnet is required. Support domains and port/protocol pairs do not satisfy this requirement. A NUL character (U+0000) in any string value returns \`400\`. ", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "create", - describe: "Create application", - builder, + }, + body: { + kind: "parsed", + brief: + "Defines a custom application. At least one hostname or IP subnet is required. Support domains and port/protocol pairs do not satisfy this requirement. A NUL character (U+0000) in any string value returns `400`. ", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts applications create", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -177,6 +190,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/applications/delete.ts b/packages/cli/src/commands/_generated/accounts/applications/delete.ts index c33ea56191..cda3510cff 100644 --- a/packages/cli/src/commands/_generated/accounts/applications/delete.ts +++ b/packages/cli/src/commands/_generated/accounts/applications/delete.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/applications/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,35 +17,25 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts applications delete \n\nDelete a custom application and all of its versions. Deletion is rejected when other resources reference the application." - ) - .positional("id", { - type: "string", - description: "Application ID.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete application", + usage: + "$0 accounts applications delete \n\nDelete a custom application and all of its versions. Deletion is rejected when other resources reference the application.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete application", - builder, + }, + }, + operands: [{ placeholder: "id", brief: "Application ID.", parse: String }], handler: async (argv): Promise => runWithTelemetry( { @@ -54,7 +43,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -88,6 +77,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/applications/get.ts b/packages/cli/src/commands/_generated/accounts/applications/get.ts index 886f95ada3..5f724d09f4 100644 --- a/packages/cli/src/commands/_generated/accounts/applications/get.ts +++ b/packages/cli/src/commands/_generated/accounts/applications/get.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/applications/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts applications get \n\nRetrieve an application available to the account by its numeric application ID." - ) - .positional("id", { - type: "string", - description: "Application ID.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get application", - builder, + usage: + "$0 accounts applications get \n\nRetrieve an application available to the account by its numeric application ID.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [{ placeholder: "id", brief: "Application ID.", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "accounts applications get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -71,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/applications/index.ts b/packages/cli/src/commands/_generated/accounts/applications/index.ts index 387e1b2602..338985f467 100644 --- a/packages/cli/src/commands/_generated/accounts/applications/index.ts +++ b/packages/cli/src/commands/_generated/accounts/applications/index.ts @@ -5,31 +5,26 @@ import $list from "./list.js"; import $lookup from "./lookup.js"; import $references from "./references.js"; import $update from "./update.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * applications command group * @generated from apis/overlays/accounts.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "applications", describe: "List Cloudflare-curated and custom applications, and manage custom applications", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($get) - .command($list) - .command($lookup) - .command($references) - .command($update) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + get: $get, + list: $list, + lookup: $lookup, + references: $references, + update: $update, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/applications/list.ts b/packages/cli/src/commands/_generated/accounts/applications/list.ts index 7e46fdbfb1..d7fb3fbc92 100644 --- a/packages/cli/src/commands/_generated/accounts/applications/list.ts +++ b/packages/cli/src/commands/_generated/accounts/applications/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/applications/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,71 +16,82 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts applications list\n\nList the applications available to an account, both the applications Cloudflare curates and the custom applications the account has defined. Results are paginated. Page with `cursor` so that applications added or removed between requests do not make other results repeat or go missing; `offset` paging can repeat or miss results when the list changes between requests. Use `filter` and `search` to narrow the list, `order_by` to sort it, and `fields` to reduce each result to only the properties you need. Use `lookup` to find complete application names mentioned in a rule sentence, ignoring case. Lookup does not correct misspellings. It ranks matches by relevance and uses the same filters, fields, and pagination as listing. `lookup` cannot be combined with `search`. Invalid UTF-8 or a NUL character (U+0000) in any query parameter name or value returns `400`. The authenticated principal must have access to the account identified by `account_id`." - ) - .option("filter", { - type: "string", - description: +const command = apiCommand({ + command: "list", + describe: "List applications", + usage: + "$0 accounts applications list\n\nList the applications available to an account, both the applications Cloudflare curates and the custom applications the account has defined. Results are paginated. Page with `cursor` so that applications added or removed between requests do not make other results repeat or go missing; `offset` paging can repeat or miss results when the list changes between requests. Use `filter` and `search` to narrow the list, `order_by` to sort it, and `fields` to reduce each result to only the properties you need. Use `lookup` to find complete application names mentioned in a rule sentence, ignoring case. Lookup does not correct misspellings. It ranks matches by relevance and uses the same filters, fields, and pagination as listing. `lookup` cannot be combined with `search`. Invalid UTF-8 or a NUL character (U+0000) in any query parameter name or value returns `400`. The authenticated principal must have access to the account identified by `account_id`.", + flags: { + filter: { + kind: "parsed", + brief: "Filter applications using `key:value` format. Supported filter keys:\n- `name`: application name (for example, `name:HR`).\n- `id`: application ID (for example, `id:498`).\n- `human_id`: human-readable ID (for example, `human_id:HR`).\n- `hostname`: hostname or support domain (for example, `hostname:portal.example.com`).\n- `source`: application source name (for example, `source:cloudflare`).\n- `ip_subnet`: CIDR containment; returns applications where a stored subnet contains the search value (for example, `ip_subnet:10.0.1.5/32` matches `10.0.0.0/16`).\n- `category_id`: category ID (for example, `category_id:12`).\n- `category_name`: category name (for example, `category_name:HR`).\n- `supported`: supported Cloudflare product. Values: `GATEWAY`, `ACCESS`, `CASB`.\n- `review_status`: account-specific Gateway review status. Values: `approved`, `unapproved`, `in_review`, `unreviewed`.", - }) - .option("limit", { - type: "number", - description: + optional: true, + parse: String, + }, + limit: { + kind: "parsed", + brief: "Number of results to return. Defaults to 25; values are clamped to 1–250.", - }) - .option("offset", { - type: "number", - description: + optional: true, + parse: Number, + }, + offset: { + kind: "parsed", + brief: "Number of results to skip. Defaults to 0; negative values are clamped to 0. Ignored when `cursor` is provided.", - }) - .option("cursor", { - type: "string", - description: + optional: true, + parse: Number, + }, + cursor: { + kind: "parsed", + brief: "Opaque value from `result_info.cursor` of the previous response. Returns the\nresults that follow it. Send the same `filter`, `search`, `lookup`, and\n`order_by` values as the request that returned it; `limit` and `fields` may\nchange. An empty value is the same as no cursor. A modified cursor, or one used\nwith different values, returns `400`.", - }) - .option("order-by", { - type: "string", - description: + optional: true, + parse: String, + }, + "order-by": { + kind: "parsed", + brief: "Order results using field:direction format. Supported fields are name, id, human_id,\ncategory_id, application_type, application_confidence_score, and gen_ai_score.\nSupported directions are asc and desc. name and application_type ignore the case of\nthe letters A to Z, and ties sort by id. Ignored when search is provided; results are\nranked by relevance instead. Also ignored when lookup is provided.", - }) - .option("search", { - type: "string", - description: + optional: true, + parse: String, + }, + search: { + kind: "parsed", + brief: "Fuzzy search across application name and hostnames. Results are ranked by relevance. Must be between 2 and 200 characters. Can be combined with filter parameters.", - }) - .option("lookup", { - type: "string", - description: + optional: true, + parse: String, + }, + lookup: { + kind: "parsed", + brief: "Find complete, case-insensitive application name mentions in a phrase or\nrule sentence. Misspelled names do not match. Returns matching applications\nranked by relevance. Must be between 2 and 1000 characters, with no control\ncharacters other than tab and line breaks. Uses the same\nfilters, fields, and pagination as listing. `search` cannot be combined\nwith lookup. Results are ranked by relevance, so `order_by` is ignored.\nTo keep the text out of URLs, send it to `POST .../applications/lookup` instead.", - }) - .option("fields", { - type: "string", - description: + optional: true, + parse: String, + }, + fields: { + kind: "parsed", + brief: "Return only the listed properties on each application, as a comma-separated list.\nUse this to keep responses small when you only need part of each application, for\nexample populating a picker with `fields=id,name` instead of downloading every\nhostname and IP subnet.\n\nOmit this parameter to receive the full application object, including\nwhen lookup is used.\n\n`id` is always returned.\n\nSelectable properties: `id`, `name`, `human_id`, `version`, `hostnames`,\n`support_domains`, `ip_subnets`, `port_protocols`, `supported`, `gen_ai_score`,\n`application_confidence_score`, `created_at`, `updated_at`, `review_status`.\n\nUnknown or empty property names return `400`.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "list", - describe: "List applications", - builder, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts applications list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -117,6 +127,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/applications/lookup.ts b/packages/cli/src/commands/_generated/accounts/applications/lookup.ts index f6ecb580fa..4f302e00f5 100644 --- a/packages/cli/src/commands/_generated/accounts/applications/lookup.ts +++ b/packages/cli/src/commands/_generated/accounts/applications/lookup.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/applications/lookup.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * lookup command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,55 +19,60 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts applications lookup\n\nFind complete application names mentioned in a rule sentence, ignoring case. Lookup does not correct misspellings. Matches are ranked by relevance. This endpoint takes the rule sentence in the request body, so the text stays out of URLs and request logs. Use it instead of the `lookup` query parameter on the list endpoint when the text may contain sensitive content. `fields`, `limit`, and `filter` work the same way as on the list endpoint and are passed as query parameters. Results are not paged: `offset`, `cursor`, `order_by`, `search`, and `lookup` query parameters return `400`. Unknown request body properties also return `400`. Invalid UTF-8 or a NUL character (U+0000) in any query parameter name or value returns `400`. The authenticated principal must have access to the account identified by `account_id`." - ) - .option("filter", { - type: "string", - description: +const command = apiCommand({ + command: "lookup", + describe: "Look up applications in a rule sentence", + usage: + "$0 accounts applications lookup\n\nFind complete application names mentioned in a rule sentence, ignoring case. Lookup does not correct misspellings. Matches are ranked by relevance. This endpoint takes the rule sentence in the request body, so the text stays out of URLs and request logs. Use it instead of the `lookup` query parameter on the list endpoint when the text may contain sensitive content. `fields`, `limit`, and `filter` work the same way as on the list endpoint and are passed as query parameters. Results are not paged: `offset`, `cursor`, `order_by`, `search`, and `lookup` query parameters return `400`. Unknown request body properties also return `400`. Invalid UTF-8 or a NUL character (U+0000) in any query parameter name or value returns `400`. The authenticated principal must have access to the account identified by `account_id`.", + flags: { + filter: { + kind: "parsed", + brief: "Filter matches using the same `key:value` filters as the list endpoint.", - }) - .option("limit", { - type: "number", - description: + optional: true, + parse: String, + }, + limit: { + kind: "parsed", + brief: "Maximum number of matches to return. Defaults to 25; values are clamped to 1–250.", - }) - .option("fields", { - type: "string", - description: + optional: true, + parse: Number, + }, + fields: { + kind: "parsed", + brief: "Return only the listed properties on each application, as a comma-separated list.\nAccepts the same properties as the list endpoint. `id` is always returned.\nOmit this parameter to receive the full application object.", - }) - .option("lookup", { - type: "string", - description: + optional: true, + parse: String, + }, + lookup: { + kind: "parsed", + brief: "Rule sentence to search for complete application names. Leading and trailing\nwhitespace is trimmed before the length is checked. Control characters other\nthan tab and line breaks return `400`.\n", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "lookup", - describe: "Look up applications in a rule sentence", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts applications lookup", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -158,6 +162,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/applications/references.ts b/packages/cli/src/commands/_generated/accounts/applications/references.ts index f0dd4cbb93..36cd8a262c 100644 --- a/packages/cli/src/commands/_generated/accounts/applications/references.ts +++ b/packages/cli/src/commands/_generated/accounts/applications/references.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/applications/references.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * references command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,32 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts applications references \n\nList the resources in the account that reference a custom application, such as Gateway rules. This is the same list a delete of the application returns when it is rejected. A delete checks the references again, so the list can change before the delete runs." - ) - .positional("id", { - type: "string", - description: "Application ID of a custom application in the account.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "references ", describe: "Get application references", - builder, + usage: + "$0 accounts applications references \n\nList the resources in the account that reference a custom application, such as Gateway rules. This is the same list a delete of the application returns when it is rejected. A delete checks the references again, so the list can change before the delete runs.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "id", + brief: "Application ID of a custom application in the account.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "accounts applications references", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -71,6 +66,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/applications/update.ts b/packages/cli/src/commands/_generated/accounts/applications/update.ts index 28004d2282..d761e78353 100644 --- a/packages/cli/src/commands/_generated/accounts/applications/update.ts +++ b/packages/cli/src/commands/_generated/accounts/applications/update.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/applications/update.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,63 +17,63 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts applications update \n\nReplace the supplied network matchers for a custom application and create a new version. Omitted matcher lists remain unchanged; send an empty list to clear a matcher type." - ) - .positional("id", { - type: "string", - description: "Application ID.", - demandOption: true, - }) - .option("hostnames", { - type: "string", - array: true, - description: "Hostnames matched by the application.", - }) - .option("ip-subnets", { - type: "string", - array: true, - description: +const command = apiCommand({ + command: "update ", + describe: "Update application", + usage: + "$0 accounts applications update \n\nReplace the supplied network matchers for a custom application and create a new version. Omitted matcher lists remain unchanged; send an empty list to clear a matcher type.", + flags: { + hostnames: { + kind: "parsed", + brief: "Hostnames matched by the application.", + variadic: true, + optional: true, + parse: String, + }, + "ip-subnets": { + kind: "parsed", + brief: "IP subnets for this application. Custom application create and update requests accept IPv4 prefix lengths /8 through /32 and IPv6 prefix lengths /32 through /128.", - }) - .option("port-protocols", { - type: "string", - array: true, - description: + variadic: true, + optional: true, + parse: String, + }, + "port-protocols": { + kind: "parsed", + brief: "Ports matched by the application, in `protocol/port` or inclusive `protocol/start-end` format (for example, `tcp/443` or `udp/10000-20000`). TCP and UDP ports must be between 0 and 65535.", - }) - .option("support-domains", { - type: "string", - array: true, - description: "Support domains matched by the application.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + variadic: true, + optional: true, + parse: String, + }, + "support-domains": { + kind: "parsed", + brief: "Support domains matched by the application.", + variadic: true, + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: - "Update the network matchers for the application. The service preserves omitted matcher lists; send an empty array to clear a list. The resulting application must contain at least one hostname or IP subnet. Support domains and port/protocol pairs do not satisfy this requirement. A NUL character (U+0000) in any string value returns \`400\`. ", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "update ", - describe: "Update application", - builder, + }, + body: { + kind: "parsed", + brief: + "Update the network matchers for the application. The service preserves omitted matcher lists; send an empty array to clear a list. The resulting application must contain at least one hostname or IP subnet. Support domains and port/protocol pairs do not satisfy this requirement. A NUL character (U+0000) in any string value returns `400`. ", + optional: true, + parse: String, + }, + }, + operands: [{ placeholder: "id", brief: "Application ID.", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "accounts applications update", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -134,6 +133,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/billing/create-setup-intent.ts b/packages/cli/src/commands/_generated/accounts/billing/create-setup-intent.ts index 6826cda8c7..01e7a0653d 100644 --- a/packages/cli/src/commands/_generated/accounts/billing/create-setup-intent.ts +++ b/packages/cli/src/commands/_generated/accounts/billing/create-setup-intent.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/billing/create-setup-intent.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create-setup-intent command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts billing create-setup-intent\n\nCreates a Stripe setup intent for adding a payment method to an account. Returns a client secret for frontend payment method collection." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create-setup-intent", describe: "Create Setup Intent", - builder, + usage: + "$0 accounts billing create-setup-intent\n\nCreates a Stripe setup intent for adding a payment method to an account. Returns a client secret for frontend payment method collection.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts billing create-setup-intent", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/billing/get-bad-debt.ts b/packages/cli/src/commands/_generated/accounts/billing/get-bad-debt.ts index dfbab77b6c..3a2ee91485 100644 --- a/packages/cli/src/commands/_generated/accounts/billing/get-bad-debt.ts +++ b/packages/cli/src/commands/_generated/accounts/billing/get-bad-debt.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/billing/get-bad-debt.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get-bad-debt command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts billing get-bad-debt\n\nGets bad debt information for an account, including outstanding invoices and total debt amount." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get-bad-debt", describe: "Get Account Bad Debt", - builder, + usage: + "$0 accounts billing get-bad-debt\n\nGets bad debt information for an account, including outstanding invoices and total debt amount.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts billing get-bad-debt", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/billing/get-credits.ts b/packages/cli/src/commands/_generated/accounts/billing/get-credits.ts index b33e4800d5..5933117fec 100644 --- a/packages/cli/src/commands/_generated/accounts/billing/get-credits.ts +++ b/packages/cli/src/commands/_generated/accounts/billing/get-credits.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/billing/get-credits.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get-credits command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts billing get-credits\n\nGets the credit balance and eligibility for an account." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get-credits", describe: "Get Account Credits", - builder, + usage: + "$0 accounts billing get-credits\n\nGets the credit balance and eligibility for an account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts billing get-credits", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/billing/get-receipt-pdf.ts b/packages/cli/src/commands/_generated/accounts/billing/get-receipt-pdf.ts index eacd75aee6..aeffb1c544 100644 --- a/packages/cli/src/commands/_generated/accounts/billing/get-receipt-pdf.ts +++ b/packages/cli/src/commands/_generated/accounts/billing/get-receipt-pdf.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get-receipt-pdf command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,46 +16,40 @@ import { withProgress } from "#lib/progress.js"; import { fetchRawBytes, writeRawOutput } from "#lib/raw-fetch.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts billing get-receipt-pdf \n\nDownloads a receipt as a PDF document." - ) - .positional("receipt-id", { - type: "string", - description: "Receipt identifier.", - demandOption: true, - }) - .option("doctype", { - type: "string", - description: "The document type to generate.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "get-receipt-pdf ", + describe: "Get Receipt PDF", + usage: + "$0 accounts billing get-receipt-pdf \n\nDownloads a receipt as a PDF document.", + flags: { + doctype: { + kind: "parsed", + brief: "The document type to generate.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("text", { - type: "boolean", - description: + }, + text: { + kind: "boolean", + brief: "Decode the response body as UTF-8 text instead of writing raw bytes", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "get-receipt-pdf ", - describe: "Get Receipt PDF", - builder, + }, + }, + operands: [ + { placeholder: "receipt-id", brief: "Receipt identifier.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "accounts billing get-receipt-pdf", classification: { safeFlags: ["dry-run", "text"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -100,6 +93,6 @@ const command: CommandModule = { return; } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/billing/get-unpaid-invoices.ts b/packages/cli/src/commands/_generated/accounts/billing/get-unpaid-invoices.ts index baafbc1141..8cf16003db 100644 --- a/packages/cli/src/commands/_generated/accounts/billing/get-unpaid-invoices.ts +++ b/packages/cli/src/commands/_generated/accounts/billing/get-unpaid-invoices.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/billing/get-unpaid-invoices.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get-unpaid-invoices command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts billing get-unpaid-invoices\n\nGets unpaid invoice information for an account." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get-unpaid-invoices", describe: "Get Unpaid Invoices", - builder, + usage: + "$0 accounts billing get-unpaid-invoices\n\nGets unpaid invoice information for an account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts billing get-unpaid-invoices", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/billing/history/index.ts b/packages/cli/src/commands/_generated/accounts/billing/history/index.ts index 686486e6ce..e9deab3946 100644 --- a/packages/cli/src/commands/_generated/accounts/billing/history/index.ts +++ b/packages/cli/src/commands/_generated/accounts/billing/history/index.ts @@ -1,20 +1,17 @@ import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * history command group * @generated from apis/overlays/accounts.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "history", describe: "Operations for billing.history", - builder: (yargs) => { - return yargs.command($list).demandCommand(1, "Please specify a subcommand"); + routes: { + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/billing/history/list.ts b/packages/cli/src/commands/_generated/accounts/billing/history/list.ts index 9347ceca7a..9624aaae3a 100644 --- a/packages/cli/src/commands/_generated/accounts/billing/history/list.ts +++ b/packages/cli/src/commands/_generated/accounts/billing/history/list.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/accounts/billing/history/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,43 +16,44 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts billing history list\n\nGets the billing history for an account." - ) - .option("page", { - type: "number", - description: "Page number of paginated results.", - }) - .option("per-page", { - type: "number", - description: "Number of items per page.", - }) - .option("status", { - type: "string", - description: "Filter billing history by status.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "Get Account Billing History", - builder, + usage: + "$0 accounts billing history list\n\nGets the billing history for an account.", + flags: { + page: { + kind: "parsed", + brief: "Page number of paginated results.", + optional: true, + parse: Number, + }, + "per-page": { + kind: "parsed", + brief: "Number of items per page.", + optional: true, + parse: Number, + }, + status: { + kind: "parsed", + brief: "Filter billing history by status.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts billing history list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -84,6 +84,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/billing/index.ts b/packages/cli/src/commands/_generated/accounts/billing/index.ts index d9a8b05458..b20ceed183 100644 --- a/packages/cli/src/commands/_generated/accounts/billing/index.ts +++ b/packages/cli/src/commands/_generated/accounts/billing/index.ts @@ -7,32 +7,27 @@ import $history from "./history/index.js"; import $payinvoice from "./pay-invoice.js"; import $paymentmethods from "./payment-methods/index.js"; import $togglepdfinvoices from "./toggle-pdf-invoices.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * billing command group * @generated from apis/overlays/accounts.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "billing", describe: "Operations for billing", - builder: (yargs) => { - return yargs - .command($createsetupintent) - .command($getbaddebt) - .command($getcredits) - .command($getreceiptpdf) - .command($getunpaidinvoices) - .command($payinvoice) - .command($togglepdfinvoices) - .command($history) - .command($paymentmethods) - .demandCommand(1, "Please specify a subcommand"); + routes: { + "create-setup-intent": $createsetupintent, + "get-bad-debt": $getbaddebt, + "get-credits": $getcredits, + "get-receipt-pdf": $getreceiptpdf, + "get-unpaid-invoices": $getunpaidinvoices, + "pay-invoice": $payinvoice, + "toggle-pdf-invoices": $togglepdfinvoices, + history: $history, + "payment-methods": $paymentmethods, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/billing/pay-invoice.ts b/packages/cli/src/commands/_generated/accounts/billing/pay-invoice.ts index e623cc34ee..13e003f115 100644 --- a/packages/cli/src/commands/_generated/accounts/billing/pay-invoice.ts +++ b/packages/cli/src/commands/_generated/accounts/billing/pay-invoice.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/billing/pay-invoice.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * pay-invoice command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,48 +18,50 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts billing pay-invoice\n\nPays an outstanding invoice for an account. Returns a Stripe client secret when Strong Customer Authentication (SCA) is required to complete the payment." - ) - .option("invoice-id", { - type: "string", - description: "The identifier of the invoice to pay.", - }) - .option("payment-method-id", { - type: "string", - description: - "The payment method to use. If omitted, the default payment method is used.", - }) - .option("validate-payment-method", { - type: "boolean", - description: "Whether to validate the payment method before processing.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "pay-invoice", describe: "Pay Invoice", - builder, + usage: + "$0 accounts billing pay-invoice\n\nPays an outstanding invoice for an account. Returns a Stripe client secret when Strong Customer Authentication (SCA) is required to complete the payment.", + flags: { + "invoice-id": { + kind: "parsed", + brief: "The identifier of the invoice to pay.", + optional: true, + parse: String, + }, + "payment-method-id": { + kind: "parsed", + brief: + "The payment method to use. If omitted, the default payment method is used.", + optional: true, + parse: String, + }, + "validate-payment-method": { + kind: "boolean", + brief: "Whether to validate the payment method before processing.", + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts billing pay-invoice", classification: { safeFlags: ["validate-payment-method", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -126,6 +127,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/billing/payment-methods/create.ts b/packages/cli/src/commands/_generated/accounts/billing/payment-methods/create.ts index 244be71854..48c025279f 100644 --- a/packages/cli/src/commands/_generated/accounts/billing/payment-methods/create.ts +++ b/packages/cli/src/commands/_generated/accounts/billing/payment-methods/create.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/accounts/billing/payment-methods/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,76 +18,135 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts billing payment-methods create\n\nCreates a new payment method for an account." - ) - .option("address", { - type: "string", - description: "Billing address line 1.", - }) - .option("address2", { - type: "string", - description: "Billing address line 2.", - }) - .option("bank-account-type", { - type: "string", - description: "Bank account type.", - }) - .option("bank-code", { type: "string", description: "Bank code." }) - .option("bank-country", { type: "string", description: "Bank country." }) - .option("bank-name", { - type: "string", - description: "Bank name for bank-based payment methods.", - }) - .option("bank-routing-number", { - type: "string", - description: "Bank routing number.", - }) - .option("cashapp-cash-tag", { - type: "string", - description: "Cash App cash tag.", - }) - .option("city", { type: "string", description: "Billing city." }) - .option("country", { type: "string", description: "Billing country." }) - .option("default", { - type: "boolean", - description: "Whether this is the default payment method.", - }) - .option("device-data", { - type: "string", - description: "Device data for fraud prevention.", - }) - .option("first-name", { - type: "string", - description: "Billing first name.", - }) - .option("last-name", { type: "string", description: "Billing last name." }) - .option("nick-name", { - type: "string", - description: "A nickname for the payment method.", - }) - .option("payment-account-email", { - type: "string", - description: "Email associated with the payment account.", - }) - .option("payment-email", { - type: "string", - description: "Payment email address.", - }) - .option("payment-gateway", { - type: "string", - description: "The payment gateway used.", - }) - .option("payment-nonce", { - type: "string", - description: "Payment nonce for tokenized payments.", - }) - .option("state", { type: "string", description: "Billing state." }) - .option("type", { - type: "string", - description: "The payment method type.", +const command = apiCommand({ + command: "create", + describe: "Create Payment Method", + usage: + "$0 accounts billing payment-methods create\n\nCreates a new payment method for an account.", + flags: { + address: { + kind: "parsed", + brief: "Billing address line 1.", + optional: true, + parse: String, + }, + address2: { + kind: "parsed", + brief: "Billing address line 2.", + optional: true, + parse: String, + }, + "bank-account-type": { + kind: "parsed", + brief: "Bank account type.", + optional: true, + parse: String, + }, + "bank-code": { + kind: "parsed", + brief: "Bank code.", + optional: true, + parse: String, + }, + "bank-country": { + kind: "parsed", + brief: "Bank country.", + optional: true, + parse: String, + }, + "bank-name": { + kind: "parsed", + brief: "Bank name for bank-based payment methods.", + optional: true, + parse: String, + }, + "bank-routing-number": { + kind: "parsed", + brief: "Bank routing number.", + optional: true, + parse: String, + }, + "cashapp-cash-tag": { + kind: "parsed", + brief: "Cash App cash tag.", + optional: true, + parse: String, + }, + city: { + kind: "parsed", + brief: "Billing city.", + optional: true, + parse: String, + }, + country: { + kind: "parsed", + brief: "Billing country.", + optional: true, + parse: String, + }, + default: { + kind: "boolean", + brief: "Whether this is the default payment method.", + optional: true, + }, + "device-data": { + kind: "parsed", + brief: "Device data for fraud prevention.", + optional: true, + parse: String, + }, + "first-name": { + kind: "parsed", + brief: "Billing first name.", + optional: true, + parse: String, + }, + "last-name": { + kind: "parsed", + brief: "Billing last name.", + optional: true, + parse: String, + }, + "nick-name": { + kind: "parsed", + brief: "A nickname for the payment method.", + optional: true, + parse: String, + }, + "payment-account-email": { + kind: "parsed", + brief: "Email associated with the payment account.", + optional: true, + parse: String, + }, + "payment-email": { + kind: "parsed", + brief: "Payment email address.", + optional: true, + parse: String, + }, + "payment-gateway": { + kind: "parsed", + brief: "The payment gateway used.", + optional: true, + parse: String, + }, + "payment-nonce": { + kind: "parsed", + brief: "Payment nonce for tokenized payments.", + optional: true, + parse: String, + }, + state: { + kind: "parsed", + brief: "Billing state.", + optional: true, + parse: String, + }, + type: { + kind: "parsed", + brief: "The payment method type.", + optional: true, choices: [ "CREDIT_CARD", "PAYPAL", @@ -97,33 +155,35 @@ function builder(yargs: Argv) { "LINK", "ACH_DIRECT_DEBIT", ], - }) - .coerce("type", (value) => resolveFileToken(value, "type", "text")) - .option("zipcode", { type: "string", description: "Billing zip code." }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + parse: String, + coerce: (value: string) => resolveFileToken(value, "type", "text"), + }, + zipcode: { + kind: "parsed", + brief: "Billing zip code.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "create", - describe: "Create Payment Method", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts billing payment-methods create", classification: { safeFlags: ["default", "type", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -371,6 +431,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/billing/payment-methods/delete.ts b/packages/cli/src/commands/_generated/accounts/billing/payment-methods/delete.ts index 505432c5b0..4d051abc5b 100644 --- a/packages/cli/src/commands/_generated/accounts/billing/payment-methods/delete.ts +++ b/packages/cli/src/commands/_generated/accounts/billing/payment-methods/delete.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/accounts/billing/payment-methods/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,35 +17,31 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts billing payment-methods delete \n\nDeletes a payment method from an account." - ) - .positional("payment-method-id", { - type: "string", - description: "Payment method identifier.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete Payment Method", + usage: + "$0 accounts billing payment-methods delete \n\nDeletes a payment method from an account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete Payment Method", - builder, + }, + }, + operands: [ + { + placeholder: "payment-method-id", + brief: "Payment method identifier.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -54,7 +49,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -88,6 +83,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/billing/payment-methods/get.ts b/packages/cli/src/commands/_generated/accounts/billing/payment-methods/get.ts index 5ad81f0b48..c8a13aead3 100644 --- a/packages/cli/src/commands/_generated/accounts/billing/payment-methods/get.ts +++ b/packages/cli/src/commands/_generated/accounts/billing/payment-methods/get.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/accounts/billing/payment-methods/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,32 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts billing payment-methods get \n\nGets a specific payment method for an account." - ) - .positional("payment-method-id", { - type: "string", - description: "Payment method identifier.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get Payment Method", - builder, + usage: + "$0 accounts billing payment-methods get \n\nGets a specific payment method for an account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "payment-method-id", + brief: "Payment method identifier.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "accounts billing payment-methods get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -76,6 +71,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/billing/payment-methods/index.ts b/packages/cli/src/commands/_generated/accounts/billing/payment-methods/index.ts index e39499b1bd..671e789c8d 100644 --- a/packages/cli/src/commands/_generated/accounts/billing/payment-methods/index.ts +++ b/packages/cli/src/commands/_generated/accounts/billing/payment-methods/index.ts @@ -4,29 +4,24 @@ import $get from "./get.js"; import $list from "./list.js"; import $setdefault from "./set-default.js"; import $update from "./update.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * payment-methods command group * @generated from apis/overlays/accounts.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "payment-methods", describe: "Operations for billing.payment-methods", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($get) - .command($list) - .command($setdefault) - .command($update) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + get: $get, + list: $list, + "set-default": $setdefault, + update: $update, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/billing/payment-methods/list.ts b/packages/cli/src/commands/_generated/accounts/billing/payment-methods/list.ts index 031a558b15..ef23cd0d09 100644 --- a/packages/cli/src/commands/_generated/accounts/billing/payment-methods/list.ts +++ b/packages/cli/src/commands/_generated/accounts/billing/payment-methods/list.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/accounts/billing/payment-methods/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,39 +16,38 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts billing payment-methods list\n\nLists all payment methods for an account." - ) - .option("page", { - type: "number", - description: "Page number of paginated results.", - }) - .option("per-page", { - type: "number", - description: "Number of items per page.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List Payment Methods", - builder, + usage: + "$0 accounts billing payment-methods list\n\nLists all payment methods for an account.", + flags: { + page: { + kind: "parsed", + brief: "Page number of paginated results.", + optional: true, + parse: Number, + }, + "per-page": { + kind: "parsed", + brief: "Number of items per page.", + optional: true, + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts billing payment-methods list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -79,6 +77,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/billing/payment-methods/set-default.ts b/packages/cli/src/commands/_generated/accounts/billing/payment-methods/set-default.ts index 0dd4145331..a0febad17f 100644 --- a/packages/cli/src/commands/_generated/accounts/billing/payment-methods/set-default.ts +++ b/packages/cli/src/commands/_generated/accounts/billing/payment-methods/set-default.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/accounts/billing/payment-methods/set-default.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * set-default command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,32 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts billing payment-methods set-default \n\nSets a payment method as the default for an account." - ) - .positional("payment-method-id", { - type: "string", - description: "Payment method identifier.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "set-default ", describe: "Set Default Payment Method", - builder, + usage: + "$0 accounts billing payment-methods set-default \n\nSets a payment method as the default for an account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "payment-method-id", + brief: "Payment method identifier.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "accounts billing payment-methods set-default", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -76,6 +71,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/billing/payment-methods/update.ts b/packages/cli/src/commands/_generated/accounts/billing/payment-methods/update.ts index 713896d1b9..42733d4e8a 100644 --- a/packages/cli/src/commands/_generated/accounts/billing/payment-methods/update.ts +++ b/packages/cli/src/commands/_generated/accounts/billing/payment-methods/update.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/accounts/billing/payment-methods/update.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,81 +18,135 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts billing payment-methods update \n\nUpdates a payment method for an account." - ) - .positional("payment-method-id", { - type: "string", - description: "Payment method identifier.", - demandOption: true, - }) - .option("address", { - type: "string", - description: "Billing address line 1.", - }) - .option("address2", { - type: "string", - description: "Billing address line 2.", - }) - .option("bank-account-type", { - type: "string", - description: "Bank account type.", - }) - .option("bank-code", { type: "string", description: "Bank code." }) - .option("bank-country", { type: "string", description: "Bank country." }) - .option("bank-name", { - type: "string", - description: "Bank name for bank-based payment methods.", - }) - .option("bank-routing-number", { - type: "string", - description: "Bank routing number.", - }) - .option("cashapp-cash-tag", { - type: "string", - description: "Cash App cash tag.", - }) - .option("city", { type: "string", description: "Billing city." }) - .option("country", { type: "string", description: "Billing country." }) - .option("default", { - type: "boolean", - description: "Whether this is the default payment method.", - }) - .option("device-data", { - type: "string", - description: "Device data for fraud prevention.", - }) - .option("first-name", { - type: "string", - description: "Billing first name.", - }) - .option("last-name", { type: "string", description: "Billing last name." }) - .option("nick-name", { - type: "string", - description: "A nickname for the payment method.", - }) - .option("payment-account-email", { - type: "string", - description: "Email associated with the payment account.", - }) - .option("payment-email", { - type: "string", - description: "Payment email address.", - }) - .option("payment-gateway", { - type: "string", - description: "The payment gateway used.", - }) - .option("payment-nonce", { - type: "string", - description: "Payment nonce for tokenized payments.", - }) - .option("state", { type: "string", description: "Billing state." }) - .option("type", { - type: "string", - description: "The payment method type.", +const command = apiCommand({ + command: "update ", + describe: "Update Payment Method", + usage: + "$0 accounts billing payment-methods update \n\nUpdates a payment method for an account.", + flags: { + address: { + kind: "parsed", + brief: "Billing address line 1.", + optional: true, + parse: String, + }, + address2: { + kind: "parsed", + brief: "Billing address line 2.", + optional: true, + parse: String, + }, + "bank-account-type": { + kind: "parsed", + brief: "Bank account type.", + optional: true, + parse: String, + }, + "bank-code": { + kind: "parsed", + brief: "Bank code.", + optional: true, + parse: String, + }, + "bank-country": { + kind: "parsed", + brief: "Bank country.", + optional: true, + parse: String, + }, + "bank-name": { + kind: "parsed", + brief: "Bank name for bank-based payment methods.", + optional: true, + parse: String, + }, + "bank-routing-number": { + kind: "parsed", + brief: "Bank routing number.", + optional: true, + parse: String, + }, + "cashapp-cash-tag": { + kind: "parsed", + brief: "Cash App cash tag.", + optional: true, + parse: String, + }, + city: { + kind: "parsed", + brief: "Billing city.", + optional: true, + parse: String, + }, + country: { + kind: "parsed", + brief: "Billing country.", + optional: true, + parse: String, + }, + default: { + kind: "boolean", + brief: "Whether this is the default payment method.", + optional: true, + }, + "device-data": { + kind: "parsed", + brief: "Device data for fraud prevention.", + optional: true, + parse: String, + }, + "first-name": { + kind: "parsed", + brief: "Billing first name.", + optional: true, + parse: String, + }, + "last-name": { + kind: "parsed", + brief: "Billing last name.", + optional: true, + parse: String, + }, + "nick-name": { + kind: "parsed", + brief: "A nickname for the payment method.", + optional: true, + parse: String, + }, + "payment-account-email": { + kind: "parsed", + brief: "Email associated with the payment account.", + optional: true, + parse: String, + }, + "payment-email": { + kind: "parsed", + brief: "Payment email address.", + optional: true, + parse: String, + }, + "payment-gateway": { + kind: "parsed", + brief: "The payment gateway used.", + optional: true, + parse: String, + }, + "payment-nonce": { + kind: "parsed", + brief: "Payment nonce for tokenized payments.", + optional: true, + parse: String, + }, + state: { + kind: "parsed", + brief: "Billing state.", + optional: true, + parse: String, + }, + type: { + kind: "parsed", + brief: "The payment method type.", + optional: true, choices: [ "CREDIT_CARD", "PAYPAL", @@ -102,33 +155,41 @@ function builder(yargs: Argv) { "LINK", "ACH_DIRECT_DEBIT", ], - }) - .coerce("type", (value) => resolveFileToken(value, "type", "text")) - .option("zipcode", { type: "string", description: "Billing zip code." }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + parse: String, + coerce: (value: string) => resolveFileToken(value, "type", "text"), + }, + zipcode: { + kind: "parsed", + brief: "Billing zip code.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "update ", - describe: "Update Payment Method", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "payment-method-id", + brief: "Payment method identifier.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "accounts billing payment-methods update", classification: { safeFlags: ["default", "type", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -386,6 +447,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/billing/toggle-pdf-invoices.ts b/packages/cli/src/commands/_generated/accounts/billing/toggle-pdf-invoices.ts index 342ac13570..176567e850 100644 --- a/packages/cli/src/commands/_generated/accounts/billing/toggle-pdf-invoices.ts +++ b/packages/cli/src/commands/_generated/accounts/billing/toggle-pdf-invoices.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/billing/toggle-pdf-invoices.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * toggle-pdf-invoices command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,39 +17,37 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts billing toggle-pdf-invoices\n\nToggles PDF invoice generation for an account." - ) - .option("toggle", { - type: "boolean", - description: "Whether to enable or disable PDF invoice generation.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "toggle-pdf-invoices", describe: "Toggle PDF Invoices", - builder, + usage: + "$0 accounts billing toggle-pdf-invoices\n\nToggles PDF invoice generation for an account.", + flags: { + toggle: { + kind: "boolean", + brief: "Whether to enable or disable PDF invoice generation.", + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts billing toggle-pdf-invoices", classification: { safeFlags: ["toggle", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -96,6 +93,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/categories/get.ts b/packages/cli/src/commands/_generated/accounts/categories/get.ts index d25a318e99..1d6e82fd2d 100644 --- a/packages/cli/src/commands/_generated/accounts/categories/get.ts +++ b/packages/cli/src/commands/_generated/accounts/categories/get.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/categories/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,28 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts categories get \n\nRetrieve an application category by its numeric ID." - ) - .positional("id", { - type: "string", - description: "Application category ID.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get application category", - builder, + usage: + "$0 accounts categories get \n\nRetrieve an application category by its numeric ID.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { placeholder: "id", brief: "Application category ID.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "accounts categories get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -71,6 +62,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/categories/index.ts b/packages/cli/src/commands/_generated/accounts/categories/index.ts index 2b53f0c117..19584457fe 100644 --- a/packages/cli/src/commands/_generated/accounts/categories/index.ts +++ b/packages/cli/src/commands/_generated/accounts/categories/index.ts @@ -1,24 +1,19 @@ import $get from "./get.js"; import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * categories command group * @generated from apis/overlays/accounts.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "categories", describe: "Browse the categories used to classify applications", - builder: (yargs) => { - return yargs - .command($get) - .command($list) - .demandCommand(1, "Please specify a subcommand"); + routes: { + get: $get, + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/categories/list.ts b/packages/cli/src/commands/_generated/accounts/categories/list.ts index 458950452e..6c207b1d76 100644 --- a/packages/cli/src/commands/_generated/accounts/categories/list.ts +++ b/packages/cli/src/commands/_generated/accounts/categories/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/categories/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,46 +16,47 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts categories list\n\nList the categories available for classifying applications, ordered by name, ignoring the case of the letters A to Z. Results are paginated by `offset` or `cursor`." - ) - .option("limit", { - type: "number", - description: +const command = apiCommand({ + command: "list", + describe: "List application categories", + usage: + "$0 accounts categories list\n\nList the categories available for classifying applications, ordered by name, ignoring the case of the letters A to Z. Results are paginated by `offset` or `cursor`.", + flags: { + limit: { + kind: "parsed", + brief: "Number of results to return. Defaults to 25; values are clamped to 1–250.", - }) - .option("offset", { - type: "number", - description: + optional: true, + parse: Number, + }, + offset: { + kind: "parsed", + brief: "Number of results to skip. Defaults to 0; negative values are clamped to 0. Ignored when `cursor` is provided.", - }) - .option("cursor", { - type: "string", - description: + optional: true, + parse: Number, + }, + cursor: { + kind: "parsed", + brief: "Opaque value from `result_info.cursor` of the previous response. Returns the\ncategories that follow it. `limit` may change between requests. An empty value\nis the same as no cursor. A modified cursor, or one returned by a different list,\nreturns `400`.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "list", - describe: "List application categories", - builder, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts categories list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -87,6 +87,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/create.ts b/packages/cli/src/commands/_generated/accounts/create.ts index fde8bd38b0..ee89f4902c 100644 --- a/packages/cli/src/commands/_generated/accounts/create.ts +++ b/packages/cli/src/commands/_generated/accounts/create.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, requestApi } from "#lib/auth.js"; import { compactBody, parseBody, setNestedValue } from "#lib/body-parser.js"; import { formatDryRun } from "#lib/dry-run.js"; @@ -14,58 +13,66 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts create\n\nCreate an Account. To create the Account within an Organization, provide `unit.id` and omit `standalone`. To create a standalone Free Account, provide `standalone: true` and omit `unit`. Providing both fields is invalid. If you omit both fields, Cloudflare can determine the destination only when the User is an administrator of exactly one Organization. Cloudflare creates the Account in that Organization; otherwise, the request returns an error. Account names are limited to 65 UTF-8 bytes." - ) - .option("idempotency-key", { - type: "string", - description: +const command = apiCommand({ + command: "create", + describe: "Create an Account", + usage: + "$0 accounts create\n\nCreate an Account. To create the Account within an Organization, provide `unit.id` and omit `standalone`. To create a standalone Free Account, provide `standalone: true` and omit `unit`. Providing both fields is invalid. If you omit both fields, Cloudflare can determine the destination only when the User is an administrator of exactly one Organization. Cloudflare creates the Account in that Organization; otherwise, the request returns an error. Account names are limited to 65 UTF-8 bytes.", + flags: { + "idempotency-key": { + kind: "parsed", + brief: "Optional key that identifies an Account-creation request. Free Account creation can require exactly one valid key, so API clients should send a key with every Account-creation request. Reuse the same key when retrying the same request.", - }) - .option("name", { - type: "string", - description: "Account name, limited to 65 UTF-8 bytes.", - }) - .option("standalone", { - type: "boolean", - description: + optional: true, + parse: String, + }, + name: { + kind: "parsed", + brief: "Account name, limited to 65 UTF-8 bytes.", + optional: true, + parse: String, + }, + standalone: { + kind: "boolean", + brief: "Set to `true` and omit `unit` to create a standalone Free Account. If provided, this field must be `true`.", - }) - .option("type", { - type: "string", - description: + optional: true, + }, + type: { + kind: "parsed", + brief: "the type of account being created. For self-serve customers, use standard. for enterprise customers, use enterprise.", - choices: ["standard", "enterprise"], default: "standard", - }) - .coerce("type", (value) => resolveFileToken(value, "type", "text")) - .option("unit-id", { type: "string", description: "Tenant unit ID" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + choices: ["standard", "enterprise"], + parse: String, + coerce: (value: string) => resolveFileToken(value, "type", "text"), + }, + "unit-id": { + kind: "parsed", + brief: "Tenant unit ID", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Parameters for account creation", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "create", - describe: "Create an Account", - builder, + }, + body: { + kind: "parsed", + brief: "Parameters for account creation", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts create", classification: { safeFlags: ["standalone", "type", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -160,6 +167,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/delete.ts b/packages/cli/src/commands/_generated/accounts/delete.ts index 863f84ee32..96c70448b7 100644 --- a/packages/cli/src/commands/_generated/accounts/delete.ts +++ b/packages/cli/src/commands/_generated/accounts/delete.ts @@ -1,11 +1,10 @@ import operation from "../_operations/accounts/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,30 +17,25 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts delete\n\nDelete a specific account (only available for tenant admins at this time). This is a permanent operation that will delete any zones or other resources under the account" - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete", + describe: "Delete a specific account", + usage: + "$0 accounts delete\n\nDelete a specific account (only available for tenant admins at this time). This is a permanent operation that will delete any zones or other resources under the account", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete", - describe: "Delete a specific account", - builder, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { @@ -49,7 +43,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -83,6 +77,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/entitlements/get.ts b/packages/cli/src/commands/_generated/accounts/entitlements/get.ts index 1d18fdc4e6..b7bf7f0be0 100644 --- a/packages/cli/src/commands/_generated/accounts/entitlements/get.ts +++ b/packages/cli/src/commands/_generated/accounts/entitlements/get.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/entitlements/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,31 +17,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts entitlements get\n\nReturns the list of entitlements (features and their allocations) for a given account or zone. Each entitlement describes a product feature the account or zone is permitted to use and the allocation value (boolean, count, range, enum, or string) that governs its behaviour.\n\nRuns against your account. Pass --zone to run against a zone instead. CLOUDFLARE_ZONE_ID is ignored." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get", describe: "Get account or zone Entitlements", - builder, + usage: + "$0 accounts entitlements get\n\nReturns the list of entitlements (features and their allocations) for a given account or zone. Each entitlement describes a product feature the account or zone is permitted to use and the allocation value (boolean, count, range, enum, or string) that governs its behaviour.\n\nRuns against your account. Pass --zone to run against a zone instead. CLOUDFLARE_ZONE_ID is ignored.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts entitlements get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -91,6 +85,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/entitlements/index.ts b/packages/cli/src/commands/_generated/accounts/entitlements/index.ts index 335b9d6433..8ca6d1763d 100644 --- a/packages/cli/src/commands/_generated/accounts/entitlements/index.ts +++ b/packages/cli/src/commands/_generated/accounts/entitlements/index.ts @@ -1,20 +1,17 @@ import $get from "./get.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * entitlements command group * @generated from apis/overlays/accounts.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "entitlements", describe: "Operations for entitlements", - builder: (yargs) => { - return yargs.command($get).demandCommand(1, "Please specify a subcommand"); + routes: { + get: $get, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/get.ts b/packages/cli/src/commands/_generated/accounts/get.ts index c683ee0901..4f7806edbf 100644 --- a/packages/cli/src/commands/_generated/accounts/get.ts +++ b/packages/cli/src/commands/_generated/accounts/get.ts @@ -1,11 +1,10 @@ import operation from "../_operations/accounts/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts get\n\nGet information about a specific account that you are a member of." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get", describe: "Account Details", - builder, + usage: + "$0 accounts get\n\nGet information about a specific account that you are a member of.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/index.ts b/packages/cli/src/commands/_generated/accounts/index.ts index cfba7e6254..ac3b85392a 100644 --- a/packages/cli/src/commands/_generated/accounts/index.ts +++ b/packages/cli/src/commands/_generated/accounts/index.ts @@ -16,42 +16,37 @@ import $tokens from "./tokens/index.js"; import $transformations from "./transformations/index.js"; import $update from "./update.js"; import $utbilling from "./ut-billing/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * accounts command * @generated from apis/overlays/accounts.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "accounts", describe: "Account settings, members, roles, subscriptions, and API tokens for your Cloudflare account", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($get) - .command($list) - .command($move) - .command($update) - .command($applications) - .command($billing) - .command($categories) - .command($entitlements) - .command($logs) - .command($members) - .command($organizations) - .command($profile) - .command($subscriptions) - .command($tokens) - .command($transformations) - .command($utbilling) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + get: $get, + list: $list, + move: $move, + update: $update, + applications: $applications, + billing: $billing, + categories: $categories, + entitlements: $entitlements, + logs: $logs, + members: $members, + organizations: $organizations, + profile: $profile, + subscriptions: $subscriptions, + tokens: $tokens, + transformations: $transformations, + "ut-billing": $utbilling, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/list.ts b/packages/cli/src/commands/_generated/accounts/list.ts index 630d1278f6..df5c60968c 100644 --- a/packages/cli/src/commands/_generated/accounts/list.ts +++ b/packages/cli/src/commands/_generated/accounts/list.ts @@ -1,56 +1,60 @@ import operation from "../_operations/accounts/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts list\n\nList all accounts you have ownership or verified access to." - ) - .option("name", { type: "string", description: "Name of the account." }) - .option("page", { - type: "number", - description: "Page number of paginated results.", - }) - .option("per-page", { - type: "number", - description: "Maximum number of results per page.", - }) - .option("direction", { - type: "string", - description: "Direction to order results.", - choices: ["asc", "desc"], - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List Accounts", - builder, + usage: + "$0 accounts list\n\nList all accounts you have ownership or verified access to.", + flags: { + name: { + kind: "parsed", + brief: "Name of the account.", + optional: true, + parse: String, + }, + page: { + kind: "parsed", + brief: "Page number of paginated results.", + optional: true, + parse: Number, + }, + "per-page": { + kind: "parsed", + brief: "Maximum number of results per page.", + optional: true, + parse: Number, + }, + direction: { + kind: "enum", + brief: "Direction to order results.", + values: ["asc", "desc"], + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts list", classification: { safeFlags: ["direction", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -79,6 +83,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/logs/audit/history.ts b/packages/cli/src/commands/_generated/accounts/logs/audit/history.ts index 9b27e3ec73..b4bad24bd5 100644 --- a/packages/cli/src/commands/_generated/accounts/logs/audit/history.ts +++ b/packages/cli/src/commands/_generated/accounts/logs/audit/history.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/accounts/logs/audit/history.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * history command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,70 +16,71 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts logs audit history \n\nReturns the chronological change history for the resource identified by the given audit log entry. The endpoint first locates the source audit log entry by `id` (using `action_time` to narrow the lookup window), derives identifying filters from that entry, and then returns matching audit logs within the `since`/`before` window. The `result_info.history_status` field indicates the quality of the resource identification used: - `exact`: Resource was identified by the resource URI. - `approximate`: Resource was identified without the resource URI. - `unavailable`: The source audit log entry did not contain enough information to identify the resource; an empty result is returned." - ) - .positional("id", { - type: "string", - description: "The ID of the audit log to fetch resource history for.", - demandOption: true, - }) - .option("action-time", { - type: "string", - description: +const command = apiCommand({ + command: "history ", + describe: + "Get resource change history from an account audit log entry (Version 2)", + usage: + "$0 accounts logs audit history \n\nReturns the chronological change history for the resource identified by the given audit log entry. The endpoint first locates the source audit log entry by `id` (using `action_time` to narrow the lookup window), derives identifying filters from that entry, and then returns matching audit logs within the `since`/`before` window. The `result_info.history_status` field indicates the quality of the resource identification used: - `exact`: Resource was identified by the resource URI. - `approximate`: Resource was identified without the resource URI. - `unavailable`: The source audit log entry did not contain enough information to identify the resource; an empty result is returned.", + flags: { + "action-time": { + kind: "parsed", + brief: "RFC3339 timestamp of the source audit log entry's action time. Used to narrow the source-entry lookup window. Provide the `action.time` value from the audit log identified by `id`.", - demandOption: true, - }) - .option("since", { - type: "string", - description: + parse: String, + }, + since: { + kind: "parsed", + brief: "Limits the returned results to logs newer than the specified date. This can be a date string 2019-04-30 (interpreted in UTC) or an absolute timestamp that conforms to RFC3339.", - demandOption: true, - }) - .option("before", { - type: "string", - description: + parse: String, + }, + before: { + kind: "parsed", + brief: "Limits the returned results to logs older than the specified date. This can be a date string 2019-04-30 (interpreted in UTC) or an absolute timestamp that conforms to RFC3339.", - demandOption: true, - }) - .option("direction", { - type: "string", - description: "Sets sorting order.", - choices: ["desc", "asc"], - }) - .option("limit", { - type: "number", - description: + parse: String, + }, + direction: { + kind: "enum", + brief: "Sets sorting order.", + values: ["desc", "asc"], + optional: true, + }, + limit: { + kind: "parsed", + brief: "The number limits the objects to return. The cursor attribute may be used to iterate over the next batch of objects if there are more than the limit.", - }) - .option("cursor", { - type: "string", - description: + optional: true, + parse: Number, + }, + cursor: { + kind: "parsed", + brief: "The cursor is an opaque token used to paginate through large sets of records. It indicates the position from which to continue when requesting the next set of records. A valid cursor value can be obtained from the cursor object in the result_info structure of a previous response.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "history ", - describe: - "Get resource change history from an account audit log entry (Version 2)", - builder, + }, + }, + operands: [ + { + placeholder: "id", + brief: "The ID of the audit log to fetch resource history for.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "accounts logs audit history", classification: { safeFlags: ["direction", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -118,6 +118,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/logs/audit/index.ts b/packages/cli/src/commands/_generated/accounts/logs/audit/index.ts index 14e4539240..9a11c9b75e 100644 --- a/packages/cli/src/commands/_generated/accounts/logs/audit/index.ts +++ b/packages/cli/src/commands/_generated/accounts/logs/audit/index.ts @@ -1,26 +1,21 @@ import $history from "./history.js"; import $list from "./list.js"; import $productcategories from "./product-categories.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * audit command group * @generated from apis/overlays/accounts.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "audit", describe: "Operations for logs.audit", - builder: (yargs) => { - return yargs - .command($history) - .command($list) - .command($productcategories) - .demandCommand(1, "Please specify a subcommand"); + routes: { + history: $history, + list: $list, + "product-categories": $productcategories, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/logs/audit/list.ts b/packages/cli/src/commands/_generated/accounts/logs/audit/list.ts index bf4ea3e262..64c5aba648 100644 --- a/packages/cli/src/commands/_generated/accounts/logs/audit/list.ts +++ b/packages/cli/src/commands/_generated/accounts/logs/audit/list.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/accounts/logs/audit/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,39 +16,43 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts logs audit list\n\nGets a list of audit logs for an account." - ) - .option("account-name", { - type: "string", - array: true, - description: "Filters by the account name.", - }) - .option("action-result", { - type: "string", - array: true, - description: "Filters by whether the action was successful or not.", +const command = apiCommand({ + command: "list", + describe: "Get account audit logs (Version 2)", + usage: + "$0 accounts logs audit list\n\nGets a list of audit logs for an account.", + flags: { + "account-name": { + kind: "parsed", + brief: "Filters by the account name.", + variadic: true, + optional: true, + parse: String, + }, + "action-result": { + kind: "parsed", + brief: "Filters by whether the action was successful or not.", + variadic: true, + optional: true, choices: ["success", "failure"], - }) - .coerce("action-result", (values: string[]) => - values.flatMap((value) => value.split(",")) - ) - .option("action-type", { - type: "string", - array: true, - description: "Filters by the action type.", + parse: String, + coerce: (values: string[]) => values.flatMap((value) => value.split(",")), + }, + "action-type": { + kind: "parsed", + brief: "Filters by the action type.", + variadic: true, + optional: true, choices: ["create", "delete", "view", "update"], - }) - .coerce("action-type", (values: string[]) => - values.flatMap((value) => value.split(",")) - ) - .option("actor-context", { - type: "string", - array: true, - description: + parse: String, + coerce: (values: string[]) => values.flatMap((value) => value.split(",")), + }, + "actor-context": { + kind: "parsed", + brief: "Filters by the actor context.\n- `api`: The action was performed through the API. The specific credential type was not recorded.\n- `api_key`: The action was authenticated with a Cloudflare Global API Key.\n- `api_token`: The action was authenticated with an API token.\n- `dash`: The action was performed through the Cloudflare dashboard.\n- `oauth`: The action was authenticated with an OAuth token.\n- `origin_ca_key`: The action was authenticated with an Origin CA key.", + variadic: true, + optional: true, choices: [ "api", "api_key", @@ -58,42 +61,52 @@ function builder(yargs: Argv) { "oauth", "origin_ca_key", ], - }) - .coerce("actor-context", (values: string[]) => - values.flatMap((value) => value.split(",")) - ) - .option("actor-email", { - type: "string", - array: true, - description: "Filters by the actor's email address.", - }) - .option("actor-id", { - type: "string", - array: true, - description: + parse: String, + coerce: (values: string[]) => values.flatMap((value) => value.split(",")), + }, + "actor-email": { + kind: "parsed", + brief: "Filters by the actor's email address.", + variadic: true, + optional: true, + parse: String, + }, + "actor-id": { + kind: "parsed", + brief: "Filters by the actor ID. This can be either the Account ID or User ID.", - }) - .option("actor-ip-address", { - type: "string", - array: true, - description: "The IP address where the action was initiated.", - }) - .option("actor-token-id", { - type: "string", - array: true, - description: + variadic: true, + optional: true, + parse: String, + }, + "actor-ip-address": { + kind: "parsed", + brief: "The IP address where the action was initiated.", + variadic: true, + optional: true, + parse: String, + }, + "actor-token-id": { + kind: "parsed", + brief: "Filters by the API token ID when the actor context is an api_token or oauth.", - }) - .option("actor-token-name", { - type: "string", - array: true, - description: + variadic: true, + optional: true, + parse: String, + }, + "actor-token-name": { + kind: "parsed", + brief: "Filters by the API token name when the actor context is an api_token or oauth.", - }) - .option("actor-type", { - type: "string", - array: true, - description: "Filters by the actor type.", + variadic: true, + optional: true, + parse: String, + }, + "actor-type": { + kind: "parsed", + brief: "Filters by the actor type.", + variadic: true, + optional: true, choices: [ "account", "cloudflare_admin", @@ -101,112 +114,138 @@ function builder(yargs: Argv) { "system", "user", ], - }) - .coerce("actor-type", (values: string[]) => - values.flatMap((value) => value.split(",")) - ) - .option("audit-log-id", { - type: "string", - array: true, - description: "Finds a specific log by its ID.", - }) - .option("id", { - type: "string", - array: true, - description: "Finds a specific log by its ID.", - }) - .option("raw-cf-ray-id", { - type: "string", - array: true, - description: "Filters by the response CF Ray ID.", - }) - .option("raw-method", { - type: "string", - array: true, - description: "The HTTP method for the API call.", - }) - .option("raw-status-code", { - type: "string", - array: true, - description: "The response status code that was returned.", - }) - .option("raw-uri", { - type: "string", - array: true, - description: "Filters by the request URI.", - }) - .option("resource-id", { - type: "string", - array: true, - description: "Filters by the resource ID.", - }) - .option("resource-product", { - type: "string", - array: true, - description: + parse: String, + coerce: (values: string[]) => values.flatMap((value) => value.split(",")), + }, + "audit-log-id": { + kind: "parsed", + brief: "Finds a specific log by its ID.", + variadic: true, + optional: true, + parse: String, + }, + id: { + kind: "parsed", + brief: "Finds a specific log by its ID.", + variadic: true, + optional: true, + parse: String, + }, + "raw-cf-ray-id": { + kind: "parsed", + brief: "Filters by the response CF Ray ID.", + variadic: true, + optional: true, + parse: String, + }, + "raw-method": { + kind: "parsed", + brief: "The HTTP method for the API call.", + variadic: true, + optional: true, + parse: String, + }, + "raw-status-code": { + kind: "parsed", + brief: "The response status code that was returned.", + variadic: true, + optional: true, + parse: String, + }, + "raw-uri": { + kind: "parsed", + brief: "Filters by the request URI.", + variadic: true, + optional: true, + parse: String, + }, + "resource-id": { + kind: "parsed", + brief: "Filters by the resource ID.", + variadic: true, + optional: true, + parse: String, + }, + "resource-product": { + kind: "parsed", + brief: "Filters audit logs by the Cloudflare product associated with the changed resource.", - }) - .option("resource-type", { - type: "string", - array: true, - description: + variadic: true, + optional: true, + parse: String, + }, + "resource-type": { + kind: "parsed", + brief: "Filters audit logs based on the unique type of resource changed by the action.", - }) - .option("resource-scope", { - type: "string", - array: true, - description: + variadic: true, + optional: true, + parse: String, + }, + "resource-scope": { + kind: "parsed", + brief: "Filters by the resource scope, specifying whether the resource is associated with an user, an account, a zone, or a membership.", + variadic: true, + optional: true, choices: ["accounts", "user", "zones", "memberships"], - }) - .coerce("resource-scope", (values: string[]) => - values.flatMap((value) => value.split(",")) - ) - .option("product-category", { - type: "string", - array: true, - description: + parse: String, + coerce: (values: string[]) => values.flatMap((value) => value.split(",")), + }, + "product-category": { + kind: "parsed", + brief: "Filters audit logs by one or more predefined product categories. Each product category expands into a curated set of resource_product values and is unioned with any explicit resource_product filter. Matched case-insensitively; unknown product categories return 400. Repeatable. Use the audit log product categories endpoint to discover the available values.", - }) - .option("zone-id", { - type: "string", - array: true, - description: "Filters by the zone ID.", - }) - .option("zone-name", { - type: "string", - array: true, - description: "Filters by the zone name associated with the change.", - }) - .option("account-name-not", { - type: "string", - array: true, - description: "Filters out audit logs by the account name.", - }) - .option("action-result-not", { - type: "string", - array: true, - description: + variadic: true, + optional: true, + parse: String, + }, + "zone-id": { + kind: "parsed", + brief: "Filters by the zone ID.", + variadic: true, + optional: true, + parse: String, + }, + "zone-name": { + kind: "parsed", + brief: "Filters by the zone name associated with the change.", + variadic: true, + optional: true, + parse: String, + }, + "account-name-not": { + kind: "parsed", + brief: "Filters out audit logs by the account name.", + variadic: true, + optional: true, + parse: String, + }, + "action-result-not": { + kind: "parsed", + brief: "Filters out audit logs by whether the action was successful or not.", + variadic: true, + optional: true, choices: ["success", "failure"], - }) - .coerce("action-result-not", (values: string[]) => - values.flatMap((value) => value.split(",")) - ) - .option("action-type-not", { - type: "string", - array: true, - description: "Filters out audit logs by the action type.", + parse: String, + coerce: (values: string[]) => values.flatMap((value) => value.split(",")), + }, + "action-type-not": { + kind: "parsed", + brief: "Filters out audit logs by the action type.", + variadic: true, + optional: true, choices: ["create", "delete", "view", "update"], - }) - .coerce("action-type-not", (values: string[]) => - values.flatMap((value) => value.split(",")) - ) - .option("actor-context-not", { - type: "string", - array: true, - description: + parse: String, + coerce: (values: string[]) => values.flatMap((value) => value.split(",")), + }, + "actor-context-not": { + kind: "parsed", + brief: "Filters out audit logs by the actor context.\n- `api`: The action was performed through the API. The specific credential type was not recorded.\n- `api_key`: The action was authenticated with a Cloudflare Global API Key.\n- `api_token`: The action was authenticated with an API token.\n- `dash`: The action was performed through the Cloudflare dashboard.\n- `oauth`: The action was authenticated with an OAuth token.\n- `origin_ca_key`: The action was authenticated with an Origin CA key.", + variadic: true, + optional: true, choices: [ "api", "api_key", @@ -215,43 +254,53 @@ function builder(yargs: Argv) { "oauth", "origin_ca_key", ], - }) - .coerce("actor-context-not", (values: string[]) => - values.flatMap((value) => value.split(",")) - ) - .option("actor-email-not", { - type: "string", - array: true, - description: "Filters out audit logs by the actor's email address.", - }) - .option("actor-id-not", { - type: "string", - array: true, - description: + parse: String, + coerce: (values: string[]) => values.flatMap((value) => value.split(",")), + }, + "actor-email-not": { + kind: "parsed", + brief: "Filters out audit logs by the actor's email address.", + variadic: true, + optional: true, + parse: String, + }, + "actor-id-not": { + kind: "parsed", + brief: "Filters out audit logs by the actor ID. This can be either the Account ID or User ID.", - }) - .option("actor-ip-address-not", { - type: "string", - array: true, - description: + variadic: true, + optional: true, + parse: String, + }, + "actor-ip-address-not": { + kind: "parsed", + brief: "Filters out audit logs IP address where the action was initiated.", - }) - .option("actor-token-id-not", { - type: "string", - array: true, - description: + variadic: true, + optional: true, + parse: String, + }, + "actor-token-id-not": { + kind: "parsed", + brief: "Filters out audit logs by the API token ID when the actor context is an api_token or oauth.", - }) - .option("actor-token-name-not", { - type: "string", - array: true, - description: + variadic: true, + optional: true, + parse: String, + }, + "actor-token-name-not": { + kind: "parsed", + brief: "Filters out audit logs by the API token name when the actor context is an api_token or oauth.", - }) - .option("actor-type-not", { - type: "string", - array: true, - description: "Filters out audit logs by the actor type.", + variadic: true, + optional: true, + parse: String, + }, + "actor-type-not": { + kind: "parsed", + brief: "Filters out audit logs by the actor type.", + variadic: true, + optional: true, choices: [ "account", "cloudflare_admin", @@ -259,127 +308,146 @@ function builder(yargs: Argv) { "system", "user", ], - }) - .coerce("actor-type-not", (values: string[]) => - values.flatMap((value) => value.split(",")) - ) - .option("audit-log-id-not", { - type: "string", - array: true, - description: "Filters out audit logs by their IDs.", - }) - .option("id-not", { - type: "string", - array: true, - description: "Filters out audit logs by their IDs.", - }) - .option("raw-cf-ray-id-not", { - type: "string", - array: true, - description: "Filters out audit logs by the response CF Ray ID.", - }) - .option("raw-method-not", { - type: "string", - array: true, - description: - "Filters out audit logs by the HTTP method for the API call.", - }) - .option("raw-status-code-not", { - type: "string", - array: true, - description: + parse: String, + coerce: (values: string[]) => values.flatMap((value) => value.split(",")), + }, + "audit-log-id-not": { + kind: "parsed", + brief: "Filters out audit logs by their IDs.", + variadic: true, + optional: true, + parse: String, + }, + "id-not": { + kind: "parsed", + brief: "Filters out audit logs by their IDs.", + variadic: true, + optional: true, + parse: String, + }, + "raw-cf-ray-id-not": { + kind: "parsed", + brief: "Filters out audit logs by the response CF Ray ID.", + variadic: true, + optional: true, + parse: String, + }, + "raw-method-not": { + kind: "parsed", + brief: "Filters out audit logs by the HTTP method for the API call.", + variadic: true, + optional: true, + parse: String, + }, + "raw-status-code-not": { + kind: "parsed", + brief: "Filters out audit logs by the response status code that was returned.", - }) - .option("raw-uri-not", { - type: "string", - array: true, - description: "Filters out audit logs by the request URI.", - }) - .option("resource-id-not", { - type: "string", - array: true, - description: "Filters out audit logs by the resource ID.", - }) - .option("resource-product-not", { - type: "string", - array: true, - description: + variadic: true, + optional: true, + parse: String, + }, + "raw-uri-not": { + kind: "parsed", + brief: "Filters out audit logs by the request URI.", + variadic: true, + optional: true, + parse: String, + }, + "resource-id-not": { + kind: "parsed", + brief: "Filters out audit logs by the resource ID.", + variadic: true, + optional: true, + parse: String, + }, + "resource-product-not": { + kind: "parsed", + brief: "Filters out audit logs by the Cloudflare product associated with the changed resource.", - }) - .option("resource-type-not", { - type: "string", - array: true, - description: + variadic: true, + optional: true, + parse: String, + }, + "resource-type-not": { + kind: "parsed", + brief: "Filters out audit logs based on the unique type of resource changed by the action.", - }) - .option("resource-scope-not", { - type: "string", - array: true, - description: + variadic: true, + optional: true, + parse: String, + }, + "resource-scope-not": { + kind: "parsed", + brief: "Filters out audit logs by the resource scope, specifying whether the resource is associated with an user, an account, a zone, or a membership.", + variadic: true, + optional: true, choices: ["accounts", "user", "zones", "memberships"], - }) - .coerce("resource-scope-not", (values: string[]) => - values.flatMap((value) => value.split(",")) - ) - .option("zone-id-not", { - type: "string", - array: true, - description: "Filters out audit logs by the zone ID.", - }) - .option("zone-name-not", { - type: "string", - array: true, - description: + parse: String, + coerce: (values: string[]) => values.flatMap((value) => value.split(",")), + }, + "zone-id-not": { + kind: "parsed", + brief: "Filters out audit logs by the zone ID.", + variadic: true, + optional: true, + parse: String, + }, + "zone-name-not": { + kind: "parsed", + brief: "Filters out audit logs by the zone name associated with the change.", - }) - .option("since", { - type: "string", - description: + variadic: true, + optional: true, + parse: String, + }, + since: { + kind: "parsed", + brief: "Limits the returned results to logs newer than the specified date. This can be a date string 2019-04-30 (interpreted in UTC) or an absolute timestamp that conforms to RFC3339.", - demandOption: true, - }) - .option("before", { - type: "string", - description: + parse: String, + }, + before: { + kind: "parsed", + brief: "Limits the returned results to logs older than the specified date. This can be a date string 2019-04-30 (interpreted in UTC) or an absolute timestamp that conforms to RFC3339.", - demandOption: true, - }) - .option("direction", { - type: "string", - description: "Sets sorting order.", - choices: ["desc", "asc"], - }) - .option("limit", { - type: "number", - description: + parse: String, + }, + direction: { + kind: "enum", + brief: "Sets sorting order.", + values: ["desc", "asc"], + optional: true, + }, + limit: { + kind: "parsed", + brief: "The number limits the objects to return. The cursor attribute may be used to iterate over the next batch of objects if there are more than the limit.", - }) - .option("cursor", { - type: "string", - description: + optional: true, + parse: Number, + }, + cursor: { + kind: "parsed", + brief: "The cursor is an opaque token used to paginate through large sets of records. It indicates the position from which to continue when requesting the next set of records. A valid cursor value can be obtained from the cursor object in the result_info structure of a previous response.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "list", - describe: "Get account audit logs (Version 2)", - builder, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts logs audit list", classification: { safeFlags: ["direction", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -457,6 +525,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/logs/audit/product-categories.ts b/packages/cli/src/commands/_generated/accounts/logs/audit/product-categories.ts index 56f9eb55ab..1da61da61b 100644 --- a/packages/cli/src/commands/_generated/accounts/logs/audit/product-categories.ts +++ b/packages/cli/src/commands/_generated/accounts/logs/audit/product-categories.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/accounts/logs/audit/product-categories.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * product-categories command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts logs audit product-categories\n\nLists the available audit log product categories and the resource products each one expands to. Use these values with the product_category filter on the account audit logs endpoint." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "product-categories", describe: "List account audit log product categories (Version 2)", - builder, + usage: + "$0 accounts logs audit product-categories\n\nLists the available audit log product categories and the resource products each one expands to. Use these values with the product_category filter on the account audit logs endpoint.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts logs audit product-categories", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/logs/index.ts b/packages/cli/src/commands/_generated/accounts/logs/index.ts index 8315ac19d8..e31109bae8 100644 --- a/packages/cli/src/commands/_generated/accounts/logs/index.ts +++ b/packages/cli/src/commands/_generated/accounts/logs/index.ts @@ -1,22 +1,17 @@ import $audit from "./audit/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * logs command group * @generated from apis/overlays/accounts.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "logs", describe: "Operations for logs", - builder: (yargs) => { - return yargs - .command($audit) - .demandCommand(1, "Please specify a subcommand"); + routes: { + audit: $audit, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/members/create.ts b/packages/cli/src/commands/_generated/accounts/members/create.ts index e118faf817..45dfd91e5d 100644 --- a/packages/cli/src/commands/_generated/accounts/members/create.ts +++ b/packages/cli/src/commands/_generated/accounts/members/create.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/members/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,58 +19,65 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts members create\n\nAdd a user to the list of members for this account." - ) - .option("email", { - type: "string", - description: "The contact email address of the user.", - }) - .option("roles", { - type: "string", - array: true, - description: "Array of roles associated with this member.", - }) - .option("status", { - type: "string", - description: +const command = apiCommand({ + command: "create", + describe: "Add Member", + usage: + "$0 accounts members create\n\nAdd a user to the list of members for this account.", + flags: { + email: { + kind: "parsed", + brief: "The contact email address of the user.", + optional: true, + parse: String, + }, + roles: { + kind: "parsed", + brief: "Array of roles associated with this member.", + variadic: true, + optional: true, + parse: String, + }, + status: { + kind: "parsed", + brief: "Status of the member invitation. If not provided during creation, defaults to 'pending'.\nChanging from 'accepted' back to 'pending' will trigger a replacement of the member resource in Terraform.", + optional: true, choices: ["accepted", "pending"], - }) - .coerce("status", (value) => resolveFileToken(value, "status", "text")) - .option("policies", { - type: "string", - description: + parse: String, + coerce: (value: string) => resolveFileToken(value, "status", "text"), + }, + policies: { + kind: "parsed", + brief: 'Array of policies associated with this member. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"access": "allow" | "deny", "permission_groups": [{...}], "resource_groups": [{...}]}].', - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }) - .conflicts("roles", ["policies"]) - .conflicts("policies", ["roles"]); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "create", - describe: "Add Member", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], + rules(rules) { + rules.conflicts("roles", ["policies"]); + rules.conflicts("policies", ["roles"]); + }, handler: async (argv): Promise => runWithTelemetry( { command: "accounts members create", classification: { safeFlags: ["status", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -143,6 +149,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/members/delete.ts b/packages/cli/src/commands/_generated/accounts/members/delete.ts index d27759aaa8..7d198b23f4 100644 --- a/packages/cli/src/commands/_generated/accounts/members/delete.ts +++ b/packages/cli/src/commands/_generated/accounts/members/delete.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/members/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,35 +17,31 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts members delete \n\nRemove a member from an account." - ) - .positional("member-id", { - type: "string", - description: "Membership identifier tag.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Remove Member", + usage: + "$0 accounts members delete \n\nRemove a member from an account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Remove Member", - builder, + }, + }, + operands: [ + { + placeholder: "member-id", + brief: "Membership identifier tag.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -54,7 +49,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -91,6 +86,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/members/get.ts b/packages/cli/src/commands/_generated/accounts/members/get.ts index 557019f61a..3ce251245f 100644 --- a/packages/cli/src/commands/_generated/accounts/members/get.ts +++ b/packages/cli/src/commands/_generated/accounts/members/get.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/members/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,32 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts members get \n\nGet information about a specific member of an account." - ) - .positional("member-id", { - type: "string", - description: "Membership identifier tag.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Member Details", - builder, + usage: + "$0 accounts members get \n\nGet information about a specific member of an account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "member-id", + brief: "Membership identifier tag.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "accounts members get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -74,6 +69,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/members/index.ts b/packages/cli/src/commands/_generated/accounts/members/index.ts index 747ab5e424..2b6c877183 100644 --- a/packages/cli/src/commands/_generated/accounts/members/index.ts +++ b/packages/cli/src/commands/_generated/accounts/members/index.ts @@ -3,28 +3,23 @@ import $delete from "./delete.js"; import $get from "./get.js"; import $list from "./list.js"; import $update from "./update.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * members command group * @generated from apis/overlays/accounts.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "members", describe: "Operations for members", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($get) - .command($list) - .command($update) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + get: $get, + list: $list, + update: $update, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/members/list.ts b/packages/cli/src/commands/_generated/accounts/members/list.ts index 725ed66860..13bd856e24 100644 --- a/packages/cli/src/commands/_generated/accounts/members/list.ts +++ b/packages/cli/src/commands/_generated/accounts/members/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/members/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,52 +16,55 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage("$0 accounts members list\n\nList all members of an account.") - .option("order", { - type: "string", - description: "Field to order results by.", - choices: ["user.first_name", "user.last_name", "user.email", "status"], - }) - .option("status", { - type: "string", - description: "A member's status in the account.", - choices: ["accepted", "pending", "rejected"], - }) - .option("page", { - type: "number", - description: "Page number of paginated results.", - }) - .option("per-page", { - type: "number", - description: "Maximum number of results per page.", - }) - .option("direction", { - type: "string", - description: "Direction to order results.", - choices: ["asc", "desc"], - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List Members", - builder, + usage: "$0 accounts members list\n\nList all members of an account.", + flags: { + order: { + kind: "enum", + brief: "Field to order results by.", + values: ["user.first_name", "user.last_name", "user.email", "status"], + optional: true, + }, + status: { + kind: "enum", + brief: "A member's status in the account.", + values: ["accepted", "pending", "rejected"], + optional: true, + }, + page: { + kind: "parsed", + brief: "Page number of paginated results.", + optional: true, + parse: Number, + }, + "per-page": { + kind: "parsed", + brief: "Maximum number of results per page.", + optional: true, + parse: Number, + }, + direction: { + kind: "enum", + brief: "Direction to order results.", + values: ["asc", "desc"], + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts members list", classification: { safeFlags: ["order", "status", "direction", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -95,6 +97,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/members/update.ts b/packages/cli/src/commands/_generated/accounts/members/update.ts index d68f4a39e0..94843fb219 100644 --- a/packages/cli/src/commands/_generated/accounts/members/update.ts +++ b/packages/cli/src/commands/_generated/accounts/members/update.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/members/update.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,52 +17,55 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts members update \n\nModify an account member." - ) - .positional("member-id", { - type: "string", - description: "Membership identifier tag.", - demandOption: true, - }) - .option("roles", { - type: "string", - description: +const command = apiCommand({ + command: "update ", + describe: "Update Member", + usage: "$0 accounts members update \n\nModify an account member.", + flags: { + roles: { + kind: "parsed", + brief: 'Roles assigned to this member. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"id": string}].', - }) - .option("policies", { - type: "string", - description: + optional: true, + parse: String, + }, + policies: { + kind: "parsed", + brief: 'Array of policies associated with this member. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"access": "allow" | "deny", "permission_groups": [{...}], "resource_groups": [{...}]}].', - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }) - .conflicts("roles", ["policies"]) - .conflicts("policies", ["roles"]); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "update ", - describe: "Update Member", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "member-id", + brief: "Membership identifier tag.", + parse: String, + }, + ], + rules(rules) { + rules.conflicts("roles", ["policies"]); + rules.conflicts("policies", ["roles"]); + }, handler: async (argv): Promise => runWithTelemetry( { command: "accounts members update", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -119,6 +121,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/move.ts b/packages/cli/src/commands/_generated/accounts/move.ts index 05259d5b4a..4ebfa1534b 100644 --- a/packages/cli/src/commands/_generated/accounts/move.ts +++ b/packages/cli/src/commands/_generated/accounts/move.ts @@ -1,11 +1,10 @@ import operation from "../_operations/accounts/move.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * move command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,40 +19,39 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts move\n\nMove an account into a destination organization, either assigning a standalone account to an organization or moving it between organizations in the same hierarchy. Availability depends on the organization's capabilities." - ) - .option("destination-organization-id", { - type: "string", - description: "The ID of the organization to move the account into.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: - "The destination organization ID is where the account is to be moved.", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "move", describe: "Move account to organization", - builder, + usage: + "$0 accounts move\n\nMove an account into a destination organization, either assigning a standalone account to an organization or moving it between organizations in the same hierarchy. Availability depends on the organization's capabilities.", + flags: { + "destination-organization-id": { + kind: "parsed", + brief: "The ID of the organization to move the account into.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: + "The destination organization ID is where the account is to be moved.", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts move", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -119,6 +117,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/organizations/index.ts b/packages/cli/src/commands/_generated/accounts/organizations/index.ts index cddca408bf..5a13239e7c 100644 --- a/packages/cli/src/commands/_generated/accounts/organizations/index.ts +++ b/packages/cli/src/commands/_generated/accounts/organizations/index.ts @@ -1,20 +1,17 @@ import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * organizations command group * @generated from apis/overlays/accounts.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "organizations", describe: "View organizations associated with a Cloudflare account", - builder: (yargs) => { - return yargs.command($list).demandCommand(1, "Please specify a subcommand"); + routes: { + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/organizations/list.ts b/packages/cli/src/commands/_generated/accounts/organizations/list.ts index 1c5bf9eb8f..03166f9e31 100644 --- a/packages/cli/src/commands/_generated/accounts/organizations/list.ts +++ b/packages/cli/src/commands/_generated/accounts/organizations/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/organizations/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - '$0 accounts organizations list\n\nRetrieve a list of the organizations that "contain" this account or are managing it. The returned list will be in order from "root" to "leaf", where the "leaf" will be the organization that _immediately_ contains the specified account.' - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List account organizations", - builder, + usage: + '$0 accounts organizations list\n\nRetrieve a list of the organizations that "contain" this account or are managing it. The returned list will be in order from "root" to "leaf", where the "leaf" will be the organization that _immediately_ contains the specified account.', + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts organizations list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/profile/get.ts b/packages/cli/src/commands/_generated/accounts/profile/get.ts index c2143f82ab..3bed5f603c 100644 --- a/packages/cli/src/commands/_generated/accounts/profile/get.ts +++ b/packages/cli/src/commands/_generated/accounts/profile/get.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/profile/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts profile get\n\nRetrieves the business profile (name, email, phone, address, and external metadata) associated with this account's customer record. Profiles can be shared across accounts and organizations. Only available to members of an organization that contains the account." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get", describe: "Get account profile", - builder, + usage: + "$0 accounts profile get\n\nRetrieves the business profile (name, email, phone, address, and external metadata) associated with this account's customer record. Profiles can be shared across accounts and organizations. Only available to members of an organization that contains the account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts profile get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/profile/index.ts b/packages/cli/src/commands/_generated/accounts/profile/index.ts index 036aa7be72..e53b0ed108 100644 --- a/packages/cli/src/commands/_generated/accounts/profile/index.ts +++ b/packages/cli/src/commands/_generated/accounts/profile/index.ts @@ -1,24 +1,19 @@ import $get from "./get.js"; import $update from "./update.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * profile command group * @generated from apis/overlays/accounts.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "profile", describe: "View and manage the profile for a Cloudflare account", - builder: (yargs) => { - return yargs - .command($get) - .command($update) - .demandCommand(1, "Please specify a subcommand"); + routes: { + get: $get, + update: $update, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/profile/update.ts b/packages/cli/src/commands/_generated/accounts/profile/update.ts index 7d90b0556d..55c9e6aaba 100644 --- a/packages/cli/src/commands/_generated/accounts/profile/update.ts +++ b/packages/cli/src/commands/_generated/accounts/profile/update.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/profile/update.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,56 +18,63 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts profile update\n\nPartially updates the business profile (name, email, phone, address, and external metadata) associated with this account's parent organization customer record, creating the profile if it does not exist. Changes apply to every account and organization sharing that profile. Omitted, empty, or null fields are left unchanged. Each profile field is limited to 1,000 UTF-8 bytes. Only available to members of an organization that contains the account." - ) - .option("business-address", { - type: "string", - description: "The business_address field", - }) - .option("business-email", { - type: "string", - description: "The business_email field", - }) - .option("business-name", { - type: "string", - description: "The business_name field", - }) - .option("business-phone", { - type: "string", - description: "The business_phone field", - }) - .option("external-metadata", { - type: "string", - description: "The external_metadata field", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: - "Partial business profile update. Omitted, empty, or null fields remain unchanged. At least one of business name, address, phone, or email must be non-empty.", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "update", describe: "Update account profile", - builder, + usage: + "$0 accounts profile update\n\nPartially updates the business profile (name, email, phone, address, and external metadata) associated with this account's parent organization customer record, creating the profile if it does not exist. Changes apply to every account and organization sharing that profile. Omitted, empty, or null fields are left unchanged. Each profile field is limited to 1,000 UTF-8 bytes. Only available to members of an organization that contains the account.", + flags: { + "business-address": { + kind: "parsed", + brief: "The business_address field", + optional: true, + parse: String, + }, + "business-email": { + kind: "parsed", + brief: "The business_email field", + optional: true, + parse: String, + }, + "business-name": { + kind: "parsed", + brief: "The business_name field", + optional: true, + parse: String, + }, + "business-phone": { + kind: "parsed", + brief: "The business_phone field", + optional: true, + parse: String, + }, + "external-metadata": { + kind: "parsed", + brief: "The external_metadata field", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: + "Partial business profile update. Omitted, empty, or null fields remain unchanged. At least one of business name, address, phone, or email must be non-empty.", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts profile update", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -162,6 +168,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/subscriptions/cancel-delayed-downgrade.ts b/packages/cli/src/commands/_generated/accounts/subscriptions/cancel-delayed-downgrade.ts index a64b3c3b45..e22626836e 100644 --- a/packages/cli/src/commands/_generated/accounts/subscriptions/cancel-delayed-downgrade.ts +++ b/packages/cli/src/commands/_generated/accounts/subscriptions/cancel-delayed-downgrade.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/subscriptions/cancel-delayed-downgrade.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * cancel-delayed-downgrade command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,40 +17,39 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts subscriptions cancel-delayed-downgrade\n\nCancels pending delayed downgrades for the specified subscriptions." - ) - .option("subscription-ids", { - type: "string", - array: true, - description: "List of subscription identifiers to cancel downgrades for.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "cancel-delayed-downgrade", describe: "Cancel Delayed Downgrade", - builder, + usage: + "$0 accounts subscriptions cancel-delayed-downgrade\n\nCancels pending delayed downgrades for the specified subscriptions.", + flags: { + "subscription-ids": { + kind: "parsed", + brief: "List of subscription identifiers to cancel downgrades for.", + variadic: true, + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts subscriptions cancel-delayed-downgrade", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -97,6 +95,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/subscriptions/create-cancel-reason.ts b/packages/cli/src/commands/_generated/accounts/subscriptions/create-cancel-reason.ts index 75c1896f22..09ea7b9339 100644 --- a/packages/cli/src/commands/_generated/accounts/subscriptions/create-cancel-reason.ts +++ b/packages/cli/src/commands/_generated/accounts/subscriptions/create-cancel-reason.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/subscriptions/create-cancel-reason.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create-cancel-reason command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,49 +18,51 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts subscriptions create-cancel-reason \n\nRecords a cancellation reason for an account subscription." - ) - .positional("subscription-identifier", { - type: "string", - description: "Subscription identifier tag.", - demandOption: true, - }) - .option("other", { - type: "string", - description: "Additional cancellation details.", - }) - .option("reason-code", { - type: "string", - array: true, - description: "The cancellation reason codes.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create-cancel-reason ", describe: "Create Cancel Reason", - builder, + usage: + "$0 accounts subscriptions create-cancel-reason \n\nRecords a cancellation reason for an account subscription.", + flags: { + other: { + kind: "parsed", + brief: "Additional cancellation details.", + optional: true, + parse: String, + }, + "reason-code": { + kind: "parsed", + brief: "The cancellation reason codes.", + variadic: true, + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "subscription-identifier", + brief: "Subscription identifier tag.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "accounts subscriptions create-cancel-reason", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -129,6 +130,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/subscriptions/create.ts b/packages/cli/src/commands/_generated/accounts/subscriptions/create.ts index b5bf34138f..36dfdb276e 100644 --- a/packages/cli/src/commands/_generated/accounts/subscriptions/create.ts +++ b/packages/cli/src/commands/_generated/accounts/subscriptions/create.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/subscriptions/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,77 +19,89 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts subscriptions create\n\nCreates an account or zone subscription.\n\nRuns against your account. Pass --zone to run against a zone instead. CLOUDFLARE_ZONE_ID is ignored." - ) - .option("app-install-id", { - type: "string", - description: "app install id.", - }) - .option("component-values", { - type: "string", - description: +const command = apiCommand({ + command: "create", + describe: "Create Subscription", + usage: + "$0 accounts subscriptions create\n\nCreates an account or zone subscription.\n\nRuns against your account. Pass --zone to run against a zone instead. CLOUDFLARE_ZONE_ID is ignored.", + flags: { + "app-install-id": { + kind: "parsed", + brief: "app install id.", + optional: true, + parse: String, + }, + "component-values": { + kind: "parsed", + brief: 'Configurable component values for the subscription. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"default"?: number, "display_name"?: string, "kind"?: "enum" | "sum" | "usage", "name"?: string, "price"?: number, ...more}]. ? marks optional keys.', - }) - .option("frequency", { - type: "string", - description: "How often the subscription is renewed automatically.", + optional: true, + parse: String, + }, + frequency: { + kind: "parsed", + brief: "How often the subscription is renewed automatically.", + optional: true, choices: ["weekly", "monthly", "quarterly", "yearly"], - }) - .coerce("frequency", (value) => - resolveFileToken(value, "frequency", "text") - ) - .option("rate-plan-currency", { - type: "string", - description: "The currency applied to the rate plan subscription.", - }) - .option("rate-plan-externally-managed", { - type: "boolean", - description: - "Whether this rate plan is managed externally from Cloudflare.", - }) - .option("rate-plan-id", { - type: "string", - description: "The ID of the rate plan.", - }) - .option("rate-plan-is-contract", { - type: "boolean", - description: + parse: String, + coerce: (value: string) => resolveFileToken(value, "frequency", "text"), + }, + "rate-plan-currency": { + kind: "parsed", + brief: "The currency applied to the rate plan subscription.", + optional: true, + parse: String, + }, + "rate-plan-externally-managed": { + kind: "boolean", + brief: "Whether this rate plan is managed externally from Cloudflare.", + optional: true, + }, + "rate-plan-id": { + kind: "parsed", + brief: "The ID of the rate plan.", + optional: true, + parse: String, + }, + "rate-plan-is-contract": { + kind: "boolean", + brief: "Whether a rate plan is enterprise-based (or newly adopted term contract).", - }) - .option("rate-plan-public-name", { - type: "string", - description: "The full name of the rate plan.", - }) - .option("rate-plan-scope", { - type: "string", - description: "The scope that this rate plan applies to.", - }) - .option("rate-plan-sets", { - type: "string", - array: true, - description: + optional: true, + }, + "rate-plan-public-name": { + kind: "parsed", + brief: "The full name of the rate plan.", + optional: true, + parse: String, + }, + "rate-plan-scope": { + kind: "parsed", + brief: "The scope that this rate plan applies to.", + optional: true, + parse: String, + }, + "rate-plan-sets": { + kind: "parsed", + brief: "The list of sets this rate plan applies to. Returns array of strings.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + variadic: true, + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "create", - describe: "Create Subscription", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { @@ -102,7 +113,7 @@ const command: CommandModule = { "rate-plan-is-contract", "dry-run", ], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -249,6 +260,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/subscriptions/delete.ts b/packages/cli/src/commands/_generated/accounts/subscriptions/delete.ts index 9b4cd04156..cf10eec31e 100644 --- a/packages/cli/src/commands/_generated/accounts/subscriptions/delete.ts +++ b/packages/cli/src/commands/_generated/accounts/subscriptions/delete.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/subscriptions/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,35 +17,31 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts subscriptions delete \n\nDeletes an account's subscription." - ) - .positional("subscription-identifier", { - type: "string", - description: "Subscription identifier tag.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete Subscription", + usage: + "$0 accounts subscriptions delete \n\nDeletes an account's subscription.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete Subscription", - builder, + }, + }, + operands: [ + { + placeholder: "subscription-identifier", + brief: "Subscription identifier tag.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -54,7 +49,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -90,6 +85,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/subscriptions/get-by-identifier.ts b/packages/cli/src/commands/_generated/accounts/subscriptions/get-by-identifier.ts index dcc89c2e7f..931d5e7176 100644 --- a/packages/cli/src/commands/_generated/accounts/subscriptions/get-by-identifier.ts +++ b/packages/cli/src/commands/_generated/accounts/subscriptions/get-by-identifier.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/subscriptions/get-by-identifier.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get-by-identifier command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,32 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts subscriptions get-by-identifier \n\nGets an account subscription by identifier." - ) - .positional("subscription-identifier", { - type: "string", - description: "Subscription identifier tag.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get-by-identifier ", describe: "Get Subscription", - builder, + usage: + "$0 accounts subscriptions get-by-identifier \n\nGets an account subscription by identifier.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "subscription-identifier", + brief: "Subscription identifier tag.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "accounts subscriptions get-by-identifier", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -78,6 +73,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/subscriptions/get-cancel-reason.ts b/packages/cli/src/commands/_generated/accounts/subscriptions/get-cancel-reason.ts index 5f0f94c58f..f53e15b9f7 100644 --- a/packages/cli/src/commands/_generated/accounts/subscriptions/get-cancel-reason.ts +++ b/packages/cli/src/commands/_generated/accounts/subscriptions/get-cancel-reason.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/subscriptions/get-cancel-reason.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get-cancel-reason command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,32 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts subscriptions get-cancel-reason \n\nGets the cancellation reason for an account subscription." - ) - .positional("subscription-identifier", { - type: "string", - description: "Subscription identifier tag.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get-cancel-reason ", describe: "Get Cancel Reason", - builder, + usage: + "$0 accounts subscriptions get-cancel-reason \n\nGets the cancellation reason for an account subscription.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "subscription-identifier", + brief: "Subscription identifier tag.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "accounts subscriptions get-cancel-reason", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -78,6 +73,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/subscriptions/get.ts b/packages/cli/src/commands/_generated/accounts/subscriptions/get.ts index 0c795d5405..6623528c37 100644 --- a/packages/cli/src/commands/_generated/accounts/subscriptions/get.ts +++ b/packages/cli/src/commands/_generated/accounts/subscriptions/get.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/subscriptions/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,31 +17,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts subscriptions get\n\nLists all of an account or zone's subscriptions.\n\nRuns against your account. Pass --zone to run against a zone instead. CLOUDFLARE_ZONE_ID is ignored." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get", describe: "List Subscriptions", - builder, + usage: + "$0 accounts subscriptions get\n\nLists all of an account or zone's subscriptions.\n\nRuns against your account. Pass --zone to run against a zone instead. CLOUDFLARE_ZONE_ID is ignored.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts subscriptions get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -91,6 +85,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/subscriptions/index.ts b/packages/cli/src/commands/_generated/accounts/subscriptions/index.ts index f7ea3a6ceb..a4a17cb101 100644 --- a/packages/cli/src/commands/_generated/accounts/subscriptions/index.ts +++ b/packages/cli/src/commands/_generated/accounts/subscriptions/index.ts @@ -6,31 +6,26 @@ import $getbyidentifier from "./get-by-identifier.js"; import $getcancelreason from "./get-cancel-reason.js"; import $get from "./get.js"; import $update from "./update.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * subscriptions command group * @generated from apis/overlays/accounts.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "subscriptions", describe: "View and manage plan subscriptions attached to this account", - builder: (yargs) => { - return yargs - .command($canceldelayeddowngrade) - .command($create) - .command($createcancelreason) - .command($delete) - .command($get) - .command($getbyidentifier) - .command($getcancelreason) - .command($update) - .demandCommand(1, "Please specify a subcommand"); + routes: { + "cancel-delayed-downgrade": $canceldelayeddowngrade, + create: $create, + "create-cancel-reason": $createcancelreason, + delete: $delete, + get: $get, + "get-by-identifier": $getbyidentifier, + "get-cancel-reason": $getcancelreason, + update: $update, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/subscriptions/update.ts b/packages/cli/src/commands/_generated/accounts/subscriptions/update.ts index d825addf27..860dd86e77 100644 --- a/packages/cli/src/commands/_generated/accounts/subscriptions/update.ts +++ b/packages/cli/src/commands/_generated/accounts/subscriptions/update.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/subscriptions/update.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,82 +18,95 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts subscriptions update \n\nUpdates an account subscription." - ) - .positional("subscription-identifier", { - type: "string", - description: "Subscription identifier tag.", - demandOption: true, - }) - .option("app-install-id", { - type: "string", - description: "app install id.", - }) - .option("component-values", { - type: "string", - description: +const command = apiCommand({ + command: "update ", + describe: "Update Subscription", + usage: + "$0 accounts subscriptions update \n\nUpdates an account subscription.", + flags: { + "app-install-id": { + kind: "parsed", + brief: "app install id.", + optional: true, + parse: String, + }, + "component-values": { + kind: "parsed", + brief: 'Configurable component values for the subscription. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"default"?: number, "display_name"?: string, "kind"?: "enum" | "sum" | "usage", "name"?: string, "price"?: number, ...more}]. ? marks optional keys.', - }) - .option("frequency", { - type: "string", - description: "How often the subscription is renewed automatically.", + optional: true, + parse: String, + }, + frequency: { + kind: "parsed", + brief: "How often the subscription is renewed automatically.", + optional: true, choices: ["weekly", "monthly", "quarterly", "yearly"], - }) - .coerce("frequency", (value) => - resolveFileToken(value, "frequency", "text") - ) - .option("rate-plan-currency", { - type: "string", - description: "The currency applied to the rate plan subscription.", - }) - .option("rate-plan-externally-managed", { - type: "boolean", - description: - "Whether this rate plan is managed externally from Cloudflare.", - }) - .option("rate-plan-id", { - type: "string", - description: "The ID of the rate plan.", - }) - .option("rate-plan-is-contract", { - type: "boolean", - description: + parse: String, + coerce: (value: string) => resolveFileToken(value, "frequency", "text"), + }, + "rate-plan-currency": { + kind: "parsed", + brief: "The currency applied to the rate plan subscription.", + optional: true, + parse: String, + }, + "rate-plan-externally-managed": { + kind: "boolean", + brief: "Whether this rate plan is managed externally from Cloudflare.", + optional: true, + }, + "rate-plan-id": { + kind: "parsed", + brief: "The ID of the rate plan.", + optional: true, + parse: String, + }, + "rate-plan-is-contract": { + kind: "boolean", + brief: "Whether a rate plan is enterprise-based (or newly adopted term contract).", - }) - .option("rate-plan-public-name", { - type: "string", - description: "The full name of the rate plan.", - }) - .option("rate-plan-scope", { - type: "string", - description: "The scope that this rate plan applies to.", - }) - .option("rate-plan-sets", { - type: "string", - array: true, - description: + optional: true, + }, + "rate-plan-public-name": { + kind: "parsed", + brief: "The full name of the rate plan.", + optional: true, + parse: String, + }, + "rate-plan-scope": { + kind: "parsed", + brief: "The scope that this rate plan applies to.", + optional: true, + parse: String, + }, + "rate-plan-sets": { + kind: "parsed", + brief: "The list of sets this rate plan applies to. Returns array of strings.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + variadic: true, + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "update ", - describe: "Update Subscription", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "subscription-identifier", + brief: "Subscription identifier tag.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -106,7 +118,7 @@ const command: CommandModule = { "rate-plan-is-contract", "dry-run", ], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -236,6 +248,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/tokens/create.ts b/packages/cli/src/commands/_generated/accounts/tokens/create.ts index 4ad2622241..684232628f 100644 --- a/packages/cli/src/commands/_generated/accounts/tokens/create.ts +++ b/packages/cli/src/commands/_generated/accounts/tokens/create.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/tokens/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,59 +19,72 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage("$0 accounts tokens create\n\nCreate a new Account Owned API token.") - .option("condition-request-ip-in", { - type: "string", - array: true, - description: "List of IPv4/IPv6 CIDR addresses.", - }) - .option("condition-request-ip-not-in", { - type: "string", - array: true, - description: "List of IPv4/IPv6 CIDR addresses.", - }) - .option("expires-on", { - type: "string", - description: +const command = apiCommand({ + command: "create", + describe: "Create Token", + usage: "$0 accounts tokens create\n\nCreate a new Account Owned API token.", + flags: { + "condition-request-ip-in": { + kind: "parsed", + brief: "List of IPv4/IPv6 CIDR addresses.", + variadic: true, + optional: true, + parse: String, + }, + "condition-request-ip-not-in": { + kind: "parsed", + brief: "List of IPv4/IPv6 CIDR addresses.", + variadic: true, + optional: true, + parse: String, + }, + "expires-on": { + kind: "parsed", + brief: "The expiration time on or after which the JWT MUST NOT be accepted for processing.", - }) - .option("name", { type: "string", description: "Token name." }) - .option("not-before", { - type: "string", - description: + optional: true, + parse: String, + }, + name: { + kind: "parsed", + brief: "Token name.", + optional: true, + parse: String, + }, + "not-before": { + kind: "parsed", + brief: "The time before which the token MUST NOT be accepted for processing.", - }) - .option("policies", { - type: "string", - description: + optional: true, + parse: String, + }, + policies: { + kind: "parsed", + brief: 'List of access policies assigned to the token. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"effect": "allow" | "deny", "permission_groups": [{...}], "resources": {...}}].', - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "create", - describe: "Create Token", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts tokens create", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -174,6 +186,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/tokens/delete.ts b/packages/cli/src/commands/_generated/accounts/tokens/delete.ts index 4125ce4502..9925b42d69 100644 --- a/packages/cli/src/commands/_generated/accounts/tokens/delete.ts +++ b/packages/cli/src/commands/_generated/accounts/tokens/delete.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/tokens/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,35 +17,27 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts tokens delete \n\nDestroy an Account Owned API token." - ) - .positional("token-id", { - type: "string", - description: "Token identifier tag.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete Token", + usage: + "$0 accounts tokens delete \n\nDestroy an Account Owned API token.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete Token", - builder, + }, + }, + operands: [ + { placeholder: "token-id", brief: "Token identifier tag.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -54,7 +45,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -91,6 +82,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/tokens/get.ts b/packages/cli/src/commands/_generated/accounts/tokens/get.ts index f68456effa..8019e56863 100644 --- a/packages/cli/src/commands/_generated/accounts/tokens/get.ts +++ b/packages/cli/src/commands/_generated/accounts/tokens/get.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/tokens/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,28 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts tokens get \n\nGet information about a specific Account Owned API token." - ) - .positional("token-id", { - type: "string", - description: "Token identifier tag.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Token Details", - builder, + usage: + "$0 accounts tokens get \n\nGet information about a specific Account Owned API token.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { placeholder: "token-id", brief: "Token identifier tag.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "accounts tokens get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -74,6 +65,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/tokens/index.ts b/packages/cli/src/commands/_generated/accounts/tokens/index.ts index a88a22d463..6007bcea6b 100644 --- a/packages/cli/src/commands/_generated/accounts/tokens/index.ts +++ b/packages/cli/src/commands/_generated/accounts/tokens/index.ts @@ -6,32 +6,27 @@ import $permissiongroups from "./permission-groups/index.js"; import $roll from "./roll.js"; import $update from "./update.js"; import $verify from "./verify.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * tokens command group * @generated from apis/overlays/accounts.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "tokens", describe: "Create and manage scoped API tokens for programmatic access to the Cloudflare API", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($get) - .command($list) - .command($roll) - .command($update) - .command($verify) - .command($permissiongroups) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + get: $get, + list: $list, + roll: $roll, + update: $update, + verify: $verify, + "permission-groups": $permissiongroups, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/tokens/list.ts b/packages/cli/src/commands/_generated/accounts/tokens/list.ts index 746e295420..39bebc57f5 100644 --- a/packages/cli/src/commands/_generated/accounts/tokens/list.ts +++ b/packages/cli/src/commands/_generated/accounts/tokens/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/tokens/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,49 +16,49 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts tokens list\n\nList Account Owned API tokens created for this account. Callers with `com.cloudflare.api.account.token.list_self` permission only receive tokens they created. Results include active, disabled, and recently-expired tokens when `include_expired` is set to true." - ) - .option("page", { - type: "number", - description: "Page number of paginated results.", - }) - .option("per-page", { - type: "number", - description: "Maximum number of results per page.", - }) - .option("direction", { - type: "string", - description: "Direction to order results.", - choices: ["asc", "desc"], - }) - .option("include-expired", { - type: "boolean", - description: - "When true, includes recently-expired tokens in the response.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List Tokens", - builder, + usage: + "$0 accounts tokens list\n\nList Account Owned API tokens created for this account. Callers with `com.cloudflare.api.account.token.list_self` permission only receive tokens they created. Results include active, disabled, and recently-expired tokens when `include_expired` is set to true.", + flags: { + page: { + kind: "parsed", + brief: "Page number of paginated results.", + optional: true, + parse: Number, + }, + "per-page": { + kind: "parsed", + brief: "Maximum number of results per page.", + optional: true, + parse: Number, + }, + direction: { + kind: "enum", + brief: "Direction to order results.", + values: ["asc", "desc"], + optional: true, + }, + "include-expired": { + kind: "boolean", + brief: "When true, includes recently-expired tokens in the response.", + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts tokens list", classification: { safeFlags: ["direction", "include-expired", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -91,6 +90,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/tokens/permission-groups/index.ts b/packages/cli/src/commands/_generated/accounts/tokens/permission-groups/index.ts index 3b60d2eaff..e740d40a0b 100644 --- a/packages/cli/src/commands/_generated/accounts/tokens/permission-groups/index.ts +++ b/packages/cli/src/commands/_generated/accounts/tokens/permission-groups/index.ts @@ -1,20 +1,17 @@ import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * permission-groups command group * @generated from apis/overlays/accounts.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "permission-groups", describe: "Operations for tokens.permission-groups", - builder: (yargs) => { - return yargs.command($list).demandCommand(1, "Please specify a subcommand"); + routes: { + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/tokens/permission-groups/list.ts b/packages/cli/src/commands/_generated/accounts/tokens/permission-groups/list.ts index c9e03f968c..700dee3e65 100644 --- a/packages/cli/src/commands/_generated/accounts/tokens/permission-groups/list.ts +++ b/packages/cli/src/commands/_generated/accounts/tokens/permission-groups/list.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/accounts/tokens/permission-groups/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,41 +16,40 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts tokens permission-groups list\n\nFind all available permission groups for Account Owned API Tokens. Each permission group indicates whether the caller can select it when creating a token. Token creation performs the authoritative permission check." - ) - .option("name", { - type: "string", - description: +const command = apiCommand({ + command: "list", + describe: "List Permission Groups", + usage: + "$0 accounts tokens permission-groups list\n\nFind all available permission groups for Account Owned API Tokens. Each permission group indicates whether the caller can select it when creating a token. Token creation performs the authoritative permission check.", + flags: { + name: { + kind: "parsed", + brief: "Filter by the name of the permission group.\nThe value must be URL-encoded.", - }) - .option("scope", { - type: "string", - description: + optional: true, + parse: String, + }, + scope: { + kind: "parsed", + brief: "Filter by the scope of the permission group.\nThe value must be URL-encoded.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "list", - describe: "List Permission Groups", - builder, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts tokens permission-groups list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -81,6 +79,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/tokens/roll.ts b/packages/cli/src/commands/_generated/accounts/tokens/roll.ts index cb161b5a38..3489491a4e 100644 --- a/packages/cli/src/commands/_generated/accounts/tokens/roll.ts +++ b/packages/cli/src/commands/_generated/accounts/tokens/roll.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/tokens/roll.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * roll command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,35 +17,27 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts tokens roll \n\nRoll the Account Owned API token secret." - ) - .positional("token-id", { - type: "string", - description: "Token identifier tag.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "roll ", + describe: "Roll Token", + usage: + "$0 accounts tokens roll \n\nRoll the Account Owned API token secret.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "roll ", - describe: "Roll Token", - builder, + }, + }, + operands: [ + { placeholder: "token-id", brief: "Token identifier tag.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -54,7 +45,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -91,6 +82,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/tokens/update.ts b/packages/cli/src/commands/_generated/accounts/tokens/update.ts index ac9f7c704a..e8413a72b2 100644 --- a/packages/cli/src/commands/_generated/accounts/tokens/update.ts +++ b/packages/cli/src/commands/_generated/accounts/tokens/update.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/tokens/update.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,70 +19,82 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage("$0 accounts tokens update \n\nUpdate an existing token.") - .positional("token-id", { - type: "string", - description: "Token identifier tag.", - demandOption: true, - }) - .option("condition-request-ip-in", { - type: "string", - array: true, - description: "List of IPv4/IPv6 CIDR addresses.", - }) - .option("condition-request-ip-not-in", { - type: "string", - array: true, - description: "List of IPv4/IPv6 CIDR addresses.", - }) - .option("expires-on", { - type: "string", - description: +const command = apiCommand({ + command: "update ", + describe: "Update Token", + usage: "$0 accounts tokens update \n\nUpdate an existing token.", + flags: { + "condition-request-ip-in": { + kind: "parsed", + brief: "List of IPv4/IPv6 CIDR addresses.", + variadic: true, + optional: true, + parse: String, + }, + "condition-request-ip-not-in": { + kind: "parsed", + brief: "List of IPv4/IPv6 CIDR addresses.", + variadic: true, + optional: true, + parse: String, + }, + "expires-on": { + kind: "parsed", + brief: "The expiration time on or after which the JWT MUST NOT be accepted for processing.", - }) - .option("name", { type: "string", description: "Token name." }) - .option("not-before", { - type: "string", - description: + optional: true, + parse: String, + }, + name: { + kind: "parsed", + brief: "Token name.", + optional: true, + parse: String, + }, + "not-before": { + kind: "parsed", + brief: "The time before which the token MUST NOT be accepted for processing.", - }) - .option("policies", { - type: "string", - description: + optional: true, + parse: String, + }, + policies: { + kind: "parsed", + brief: 'List of access policies assigned to the token. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"effect": "allow" | "deny", "permission_groups": [{...}], "resources": {...}}].', - }) - .option("status", { - type: "string", - description: "Status of the token.", + optional: true, + parse: String, + }, + status: { + kind: "parsed", + brief: "Status of the token.", + optional: true, choices: ["active", "disabled", "expired"], - }) - .coerce("status", (value) => resolveFileToken(value, "status", "text")) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + parse: String, + coerce: (value: string) => resolveFileToken(value, "status", "text"), + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "update ", - describe: "Update Token", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { placeholder: "token-id", brief: "Token identifier tag.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "accounts tokens update", classification: { safeFlags: ["status", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -195,6 +206,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/tokens/verify.ts b/packages/cli/src/commands/_generated/accounts/tokens/verify.ts index e3a198bd89..8845e8ef92 100644 --- a/packages/cli/src/commands/_generated/accounts/tokens/verify.ts +++ b/packages/cli/src/commands/_generated/accounts/tokens/verify.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/tokens/verify.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * verify command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,29 +16,25 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage("$0 accounts tokens verify\n\nTest whether a token works.") - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "verify", describe: "Verify Token", - builder, + usage: "$0 accounts tokens verify\n\nTest whether a token works.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts tokens verify", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -64,6 +59,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/transformations/index.ts b/packages/cli/src/commands/_generated/accounts/transformations/index.ts index 2451ccff97..8dcd2d0734 100644 --- a/packages/cli/src/commands/_generated/accounts/transformations/index.ts +++ b/packages/cli/src/commands/_generated/accounts/transformations/index.ts @@ -1,20 +1,17 @@ import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * transformations command group * @generated from apis/overlays/accounts.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "transformations", describe: "Operations for transformations", - builder: (yargs) => { - return yargs.command($list).demandCommand(1, "Please specify a subcommand"); + routes: { + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/transformations/list.ts b/packages/cli/src/commands/_generated/accounts/transformations/list.ts index 727bc8c2cf..e5cba9dd69 100644 --- a/packages/cli/src/commands/_generated/accounts/transformations/list.ts +++ b/packages/cli/src/commands/_generated/accounts/transformations/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/transformations/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts transformations list\n\nReturns a list of Image Resizing configurations across all zones for the account. This endpoint is useful for retrieving the transformations (image_resizing) state for all zones belonging to an account." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List Image Resizing configurations for account", - builder, + usage: + "$0 accounts transformations list\n\nReturns a list of Image Resizing configurations across all zones for the account. This endpoint is useful for retrieving the transformations (image_resizing) state for all zones belonging to an account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts transformations list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/update.ts b/packages/cli/src/commands/_generated/accounts/update.ts index 93679682b0..f2b3914941 100644 --- a/packages/cli/src/commands/_generated/accounts/update.ts +++ b/packages/cli/src/commands/_generated/accounts/update.ts @@ -1,11 +1,10 @@ import operation from "../_operations/accounts/update.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,50 +19,52 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts update\n\nUpdate an existing account. Account names are limited to 65 UTF-8 bytes." - ) - .option("id", { type: "string", description: "Identifier" }) - .option("name", { - type: "string", - description: +const command = apiCommand({ + command: "update", + describe: "Update Account", + usage: + "$0 accounts update\n\nUpdate an existing account. Account names are limited to 65 UTF-8 bytes.", + flags: { + id: { kind: "parsed", brief: "Identifier", optional: true, parse: String }, + name: { + kind: "parsed", + brief: "Account name. When creating or updating an account, the name is limited to 65 UTF-8 bytes.", - }) - .option("settings-abuse-contact-email", { - type: "string", - description: "Sets an abuse contact email to notify for abuse reports.", - }) - .option("settings-enforce-twofactor", { - type: "boolean", - description: + optional: true, + parse: String, + }, + "settings-abuse-contact-email": { + kind: "parsed", + brief: "Sets an abuse contact email to notify for abuse reports.", + optional: true, + parse: String, + }, + "settings-enforce-twofactor": { + kind: "boolean", + brief: "Indicates whether membership in this account requires that\nTwo-Factor Authentication is enabled", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "update", - describe: "Update Account", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts update", classification: { safeFlags: ["settings-enforce-twofactor", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -156,6 +157,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/ut-billing/edit.ts b/packages/cli/src/commands/_generated/accounts/ut-billing/edit.ts index b3cc350220..c5e195088e 100644 --- a/packages/cli/src/commands/_generated/accounts/ut-billing/edit.ts +++ b/packages/cli/src/commands/_generated/accounts/ut-billing/edit.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/ut-billing/edit.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * edit command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,42 +19,41 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredEnumField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - '$0 accounts ut-billing edit\n\nUpdates the Unique Transformations billing configuration for an account. When enabled, billing data is directed to the Transformations pipeline. Note: setting the value to "off" is not permitted once enabled.' - ) - .option("value", { - type: "string", - description: +const command = apiCommand({ + command: "edit", + describe: "Change Unique Transformations billing setting", + usage: + '$0 accounts ut-billing edit\n\nUpdates the Unique Transformations billing configuration for an account. When enabled, billing data is directed to the Transformations pipeline. Note: setting the value to "off" is not permitted once enabled.', + flags: { + value: { + kind: "parsed", + brief: 'Enables Unique Transformations billing for the account.\nNote: once enabled, this setting cannot be set back to "off".\n', + optional: true, choices: ["on"], - }) - .coerce("value", (value) => resolveFileToken(value, "value", "text")) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + parse: String, + coerce: (value: string) => resolveFileToken(value, "value", "text"), + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "edit", - describe: "Change Unique Transformations billing setting", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts ut-billing edit", classification: { safeFlags: ["value", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -114,6 +112,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/ut-billing/get.ts b/packages/cli/src/commands/_generated/accounts/ut-billing/get.ts index 12596e0b5b..4fea537b9c 100644 --- a/packages/cli/src/commands/_generated/accounts/ut-billing/get.ts +++ b/packages/cli/src/commands/_generated/accounts/ut-billing/get.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/accounts/ut-billing/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/accounts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 accounts ut-billing get\n\nRetrieves the Unique Transformations billing configuration for an account. When enabled, billing data is directed to the Transformations pipeline." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get", describe: "Get Unique Transformations billing setting", - builder, + usage: + "$0 accounts ut-billing get\n\nRetrieves the Unique Transformations billing configuration for an account. When enabled, billing data is directed to the Transformations pipeline.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "accounts ut-billing get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/accounts/ut-billing/index.ts b/packages/cli/src/commands/_generated/accounts/ut-billing/index.ts index 15955ea677..9580b0c2cf 100644 --- a/packages/cli/src/commands/_generated/accounts/ut-billing/index.ts +++ b/packages/cli/src/commands/_generated/accounts/ut-billing/index.ts @@ -1,24 +1,19 @@ import $edit from "./edit.js"; import $get from "./get.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * ut-billing command group * @generated from apis/overlays/accounts.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "ut-billing", describe: "Operations for ut-billing", - builder: (yargs) => { - return yargs - .command($edit) - .command($get) - .demandCommand(1, "Please specify a subcommand"); + routes: { + edit: $edit, + get: $get, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/acm/custom-trust-store/create.ts b/packages/cli/src/commands/_generated/acm/custom-trust-store/create.ts index 5c27a52675..ab7f53463f 100644 --- a/packages/cli/src/commands/_generated/acm/custom-trust-store/create.ts +++ b/packages/cli/src/commands/_generated/acm/custom-trust-store/create.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/acm/custom-trust-store/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/acm.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { compactBody, parseBody } from "#lib/body-parser.js"; import { formatDryRun } from "#lib/dry-run.js"; @@ -15,40 +14,39 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 acm custom-trust-store create\n\nUpload a root CA certificate to the Custom Origin Trust Store for a Zone. Only root CA certificates are accepted." - ) - .option("certificate", { - type: "string", - description: - "The root CA certificate in PEM format. Only root CA certificates are accepted; intermediate and leaf certificates are not supported.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create", describe: "Upload Custom Origin Trust Store", - builder, + usage: + "$0 acm custom-trust-store create\n\nUpload a root CA certificate to the Custom Origin Trust Store for a Zone. Only root CA certificates are accepted.", + flags: { + certificate: { + kind: "parsed", + brief: + "The root CA certificate in PEM format. Only root CA certificates are accepted; intermediate and leaf certificates are not supported.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "acm custom-trust-store create", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -117,6 +115,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/acm/custom-trust-store/delete.ts b/packages/cli/src/commands/_generated/acm/custom-trust-store/delete.ts index 3d13efc1d3..b50cef8dfa 100644 --- a/packages/cli/src/commands/_generated/acm/custom-trust-store/delete.ts +++ b/packages/cli/src/commands/_generated/acm/custom-trust-store/delete.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/acm/custom-trust-store/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/acm.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; @@ -13,35 +12,31 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 acm custom-trust-store delete \n\nRemoves a root CA certificate from the custom origin trust store. Origins using certificates signed by this CA will no longer be trusted." - ) - .positional("custom-origin-trust-store-id", { - type: "string", - description: "Certificate identifier tag.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete Custom Origin Trust Store", + usage: + "$0 acm custom-trust-store delete \n\nRemoves a root CA certificate from the custom origin trust store. Origins using certificates signed by this CA will no longer be trusted.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete Custom Origin Trust Store", - builder, + }, + }, + operands: [ + { + placeholder: "custom-origin-trust-store-id", + brief: "Certificate identifier tag.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -49,7 +44,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -87,6 +82,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/acm/custom-trust-store/get.ts b/packages/cli/src/commands/_generated/acm/custom-trust-store/get.ts index 044b855ff1..e21d031831 100644 --- a/packages/cli/src/commands/_generated/acm/custom-trust-store/get.ts +++ b/packages/cli/src/commands/_generated/acm/custom-trust-store/get.ts @@ -1,47 +1,42 @@ import operation from "../../_operations/acm/custom-trust-store/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/acm.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 acm custom-trust-store get \n\nRetrieves details about a specific root CA certificate in the custom origin trust store, including expiration and subject information." - ) - .positional("custom-origin-trust-store-id", { - type: "string", - description: "Certificate identifier tag.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Custom Origin Trust Store Details", - builder, + usage: + "$0 acm custom-trust-store get \n\nRetrieves details about a specific root CA certificate in the custom origin trust store, including expiration and subject information.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "custom-origin-trust-store-id", + brief: "Certificate identifier tag.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "acm custom-trust-store get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -75,6 +70,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/acm/custom-trust-store/index.ts b/packages/cli/src/commands/_generated/acm/custom-trust-store/index.ts index 46d2dfebe8..406e4bd23b 100644 --- a/packages/cli/src/commands/_generated/acm/custom-trust-store/index.ts +++ b/packages/cli/src/commands/_generated/acm/custom-trust-store/index.ts @@ -2,27 +2,22 @@ import $create from "./create.js"; import $delete from "./delete.js"; import $get from "./get.js"; import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * custom-trust-store command group * @generated from apis/overlays/acm.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "custom-trust-store", describe: "Operations for custom-trust-store", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($get) - .command($list) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + get: $get, + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/acm/custom-trust-store/list.ts b/packages/cli/src/commands/_generated/acm/custom-trust-store/list.ts index 24e826a6a3..c7cf4e2735 100644 --- a/packages/cli/src/commands/_generated/acm/custom-trust-store/list.ts +++ b/packages/cli/src/commands/_generated/acm/custom-trust-store/list.ts @@ -1,55 +1,60 @@ import operation from "../../_operations/acm/custom-trust-store/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/acm.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 acm custom-trust-store list\n\nGet Custom Origin Trust Store for a Zone." - ) - .option("page", { - type: "number", - description: "Page number of paginated results.", - }) - .option("per-page", { - type: "number", - description: "Number of records per page.", - }) - .option("limit", { - type: "number", - description: "Limit to the number of records returned.", - }) - .option("offset", { type: "number", description: "Offset the results." }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List Custom Origin Trust Store Details", - builder, + usage: + "$0 acm custom-trust-store list\n\nGet Custom Origin Trust Store for a Zone.", + flags: { + page: { + kind: "parsed", + brief: "Page number of paginated results.", + optional: true, + parse: Number, + }, + "per-page": { + kind: "parsed", + brief: "Number of records per page.", + optional: true, + parse: Number, + }, + limit: { + kind: "parsed", + brief: "Limit to the number of records returned.", + optional: true, + parse: Number, + }, + offset: { + kind: "parsed", + brief: "Offset the results.", + optional: true, + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "acm custom-trust-store list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -84,6 +89,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/acm/index.ts b/packages/cli/src/commands/_generated/acm/index.ts index d8b6d9fbb3..c848664093 100644 --- a/packages/cli/src/commands/_generated/acm/index.ts +++ b/packages/cli/src/commands/_generated/acm/index.ts @@ -1,24 +1,19 @@ import $customtruststore from "./custom-trust-store/index.js"; import $totaltls from "./total-tls/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * acm command * @generated from apis/overlays/acm.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "acm", describe: "acm", - builder: (yargs) => { - return yargs - .command($customtruststore) - .command($totaltls) - .demandCommand(1, "Please specify a subcommand"); + routes: { + "custom-trust-store": $customtruststore, + "total-tls": $totaltls, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/acm/total-tls/edit.ts b/packages/cli/src/commands/_generated/acm/total-tls/edit.ts index ee6a28ade6..6cba2c513b 100644 --- a/packages/cli/src/commands/_generated/acm/total-tls/edit.ts +++ b/packages/cli/src/commands/_generated/acm/total-tls/edit.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/acm/total-tls/edit.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * edit command * @generated from apis/overlays/acm.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { compactBody, parseBody } from "#lib/body-parser.js"; import { formatDryRun } from "#lib/dry-run.js"; @@ -14,49 +13,48 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 acm total-tls edit\n\nSet Total TLS Settings or disable the feature for a Zone." - ) - .option("certificate-authority", { - type: "string", - description: +const command = apiCommand({ + command: "edit", + describe: "Enable or Disable Total TLS", + usage: + "$0 acm total-tls edit\n\nSet Total TLS Settings or disable the feature for a Zone.", + flags: { + "certificate-authority": { + kind: "parsed", + brief: "The Certificate Authority that Total TLS certificates will be issued through. Not returned in responses when Total TLS is disabled.", + optional: true, choices: ["google", "lets_encrypt", "ssl_com"], - }) - .coerce("certificate-authority", (value) => - resolveFileToken(value, "certificate-authority", "text") - ) - .option("enabled", { - type: "boolean", - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "certificate-authority", "text"), + }, + enabled: { + kind: "boolean", + brief: "If enabled, Total TLS will order a hostname specific TLS certificate for any proxied A, AAAA, or CNAME record in your zone.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "edit", - describe: "Enable or Disable Total TLS", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "acm total-tls edit", classification: { safeFlags: ["certificate-authority", "enabled", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -118,6 +116,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/acm/total-tls/get.ts b/packages/cli/src/commands/_generated/acm/total-tls/get.ts index b342c0c7a5..50dcc9c540 100644 --- a/packages/cli/src/commands/_generated/acm/total-tls/get.ts +++ b/packages/cli/src/commands/_generated/acm/total-tls/get.ts @@ -1,40 +1,35 @@ import operation from "../../_operations/acm/total-tls/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/acm.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage("$0 acm total-tls get\n\nGet Total TLS Settings for a Zone.") - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get", describe: "Total TLS Settings Details", - builder, + usage: "$0 acm total-tls get\n\nGet Total TLS Settings for a Zone.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "acm total-tls get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -62,6 +57,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/acm/total-tls/index.ts b/packages/cli/src/commands/_generated/acm/total-tls/index.ts index c264bed62b..7367485e15 100644 --- a/packages/cli/src/commands/_generated/acm/total-tls/index.ts +++ b/packages/cli/src/commands/_generated/acm/total-tls/index.ts @@ -1,24 +1,19 @@ import $edit from "./edit.js"; import $get from "./get.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * total-tls command group * @generated from apis/overlays/acm.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "total-tls", describe: "Operations for total-tls", - builder: (yargs) => { - return yargs - .command($edit) - .command($get) - .demandCommand(1, "Please specify a subcommand"); + routes: { + edit: $edit, + get: $get, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/address-maps/accounts/create.ts b/packages/cli/src/commands/_generated/addressing/address-maps/accounts/create.ts index baf86470fd..1dc20bae52 100644 --- a/packages/cli/src/commands/_generated/addressing/address-maps/accounts/create.ts +++ b/packages/cli/src/commands/_generated/addressing/address-maps/accounts/create.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/addressing/address-maps/accounts/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,41 +16,37 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing address-maps accounts create \n\nAdd an account as a member of a particular address map." - ) - .positional("member-account-id", { - type: "string", - description: "Identifier of a Cloudflare account.", - demandOption: true, - }) - .option("address-map-id", { - type: "string", - description: "Identifier of an Address Map.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create ", describe: "Add an account membership to an Address Map", - builder, + usage: + "$0 addressing address-maps accounts create \n\nAdd an account as a member of a particular address map.", + flags: { + "address-map-id": { + kind: "parsed", + brief: "Identifier of an Address Map.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "member-account-id", + brief: "Identifier of a Cloudflare account.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "addressing address-maps accounts create", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -83,6 +78,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/address-maps/accounts/delete.ts b/packages/cli/src/commands/_generated/addressing/address-maps/accounts/delete.ts index f15dace858..e6b86c59b4 100644 --- a/packages/cli/src/commands/_generated/addressing/address-maps/accounts/delete.ts +++ b/packages/cli/src/commands/_generated/addressing/address-maps/accounts/delete.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/addressing/address-maps/accounts/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,40 +17,36 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing address-maps accounts delete \n\nRemove an account as a member of a particular address map." - ) - .positional("member-account-id", { - type: "string", - description: "Identifier of a Cloudflare account.", - demandOption: true, - }) - .option("address-map-id", { - type: "string", - description: "Identifier of an Address Map.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Remove an account membership from an Address Map", + usage: + "$0 addressing address-maps accounts delete \n\nRemove an account as a member of a particular address map.", + flags: { + "address-map-id": { + kind: "parsed", + brief: "Identifier of an Address Map.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Remove an account membership from an Address Map", - builder, + }, + }, + operands: [ + { + placeholder: "member-account-id", + brief: "Identifier of a Cloudflare account.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -59,7 +54,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -95,6 +90,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/address-maps/accounts/index.ts b/packages/cli/src/commands/_generated/addressing/address-maps/accounts/index.ts index 76096b0378..974f25e45f 100644 --- a/packages/cli/src/commands/_generated/addressing/address-maps/accounts/index.ts +++ b/packages/cli/src/commands/_generated/addressing/address-maps/accounts/index.ts @@ -1,24 +1,19 @@ import $create from "./create.js"; import $delete from "./delete.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * accounts command group * @generated from apis/overlays/addressing.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "accounts", describe: "Operations for address-maps.accounts", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/address-maps/create.ts b/packages/cli/src/commands/_generated/addressing/address-maps/create.ts index eaa7528113..187b930a90 100644 --- a/packages/cli/src/commands/_generated/addressing/address-maps/create.ts +++ b/packages/cli/src/commands/_generated/addressing/address-maps/create.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/addressing/address-maps/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,56 +18,59 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing address-maps create\n\nCreate a new address map under the account." - ) - .option("description", { - type: "string", - description: +const command = apiCommand({ + command: "create", + describe: "Create Address Map", + usage: + "$0 addressing address-maps create\n\nCreate a new address map under the account.", + flags: { + description: { + kind: "parsed", + brief: "An optional description field which may be used to describe the types of IPs or zones on the map.", - }) - .option("enabled", { - type: "boolean", - description: + optional: true, + parse: String, + }, + enabled: { + kind: "boolean", + brief: "Whether the Address Map is enabled or not. Cloudflare's DNS will not respond with IP addresses on an Address Map until the map is enabled.", default: false, - }) - .option("ips", { - type: "string", - array: true, - description: "The ips field", - }) - .option("memberships", { - type: "string", - description: + }, + ips: { + kind: "parsed", + brief: "The ips field", + variadic: true, + optional: true, + parse: String, + }, + memberships: { + kind: "parsed", + brief: 'Zones and Accounts which will be assigned IPs on this Address Map. A zone membership will take priority over an account membership. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"identifier"?: string, "kind"?: "zone" | "account"}]. ? marks optional keys.', - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "create", - describe: "Create Address Map", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "addressing address-maps create", classification: { safeFlags: ["enabled", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -131,6 +133,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/address-maps/delete.ts b/packages/cli/src/commands/_generated/addressing/address-maps/delete.ts index 4f56d9d60b..d1c5b700bd 100644 --- a/packages/cli/src/commands/_generated/addressing/address-maps/delete.ts +++ b/packages/cli/src/commands/_generated/addressing/address-maps/delete.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/addressing/address-maps/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,35 +17,31 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing address-maps delete \n\nDelete a particular address map owned by the account. An Address Map must be disabled before it can be deleted." - ) - .positional("address-map-id", { - type: "string", - description: "Identifier of an Address Map.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete Address Map", + usage: + "$0 addressing address-maps delete \n\nDelete a particular address map owned by the account. An Address Map must be disabled before it can be deleted.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete Address Map", - builder, + }, + }, + operands: [ + { + placeholder: "address-map-id", + brief: "Identifier of an Address Map.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -54,7 +49,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -88,6 +83,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/address-maps/edit.ts b/packages/cli/src/commands/_generated/addressing/address-maps/edit.ts index fc52828d9b..3262e13314 100644 --- a/packages/cli/src/commands/_generated/addressing/address-maps/edit.ts +++ b/packages/cli/src/commands/_generated/addressing/address-maps/edit.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/addressing/address-maps/edit.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * edit command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,55 +18,58 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing address-maps edit \n\nModify properties of an address map owned by the account." - ) - .positional("address-map-id", { - type: "string", - description: "Identifier of an Address Map.", - demandOption: true, - }) - .option("default-sni", { - type: "string", - description: +const command = apiCommand({ + command: "edit ", + describe: "Update Address Map", + usage: + "$0 addressing address-maps edit \n\nModify properties of an address map owned by the account.", + flags: { + "default-sni": { + kind: "parsed", + brief: "If you have legacy TLS clients which do not send the TLS server name indicator, then you can specify one default SNI on the map. If Cloudflare receives a TLS handshake from a client without an SNI, it will respond with the default SNI on those IPs. The default SNI can be any valid zone or subdomain owned by the account.", - }) - .option("description", { - type: "string", - description: + optional: true, + parse: String, + }, + description: { + kind: "parsed", + brief: "An optional description field which may be used to describe the types of IPs or zones on the map.", - }) - .option("enabled", { - type: "boolean", - description: + optional: true, + parse: String, + }, + enabled: { + kind: "boolean", + brief: "Whether the Address Map is enabled or not. Cloudflare's DNS will not respond with IP addresses on an Address Map until the map is enabled.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "edit ", - describe: "Update Address Map", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "address-map-id", + brief: "Identifier of an Address Map.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "addressing address-maps edit", classification: { safeFlags: ["enabled", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -143,6 +145,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/address-maps/get.ts b/packages/cli/src/commands/_generated/addressing/address-maps/get.ts index dda3be7873..e514002b76 100644 --- a/packages/cli/src/commands/_generated/addressing/address-maps/get.ts +++ b/packages/cli/src/commands/_generated/addressing/address-maps/get.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/addressing/address-maps/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,32 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing address-maps get \n\nShow a particular address map owned by the account." - ) - .positional("address-map-id", { - type: "string", - description: "Identifier of an Address Map.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Address Map Details", - builder, + usage: + "$0 addressing address-maps get \n\nShow a particular address map owned by the account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "address-map-id", + brief: "Identifier of an Address Map.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "addressing address-maps get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -76,6 +71,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/address-maps/index.ts b/packages/cli/src/commands/_generated/addressing/address-maps/index.ts index f0b9930c38..9a31195b38 100644 --- a/packages/cli/src/commands/_generated/addressing/address-maps/index.ts +++ b/packages/cli/src/commands/_generated/addressing/address-maps/index.ts @@ -6,31 +6,26 @@ import $get from "./get.js"; import $ips from "./ips/index.js"; import $list from "./list.js"; import $zones from "./zones/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * address-maps command group * @generated from apis/overlays/addressing.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "address-maps", describe: "Operations for address-maps", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($edit) - .command($get) - .command($list) - .command($accounts) - .command($ips) - .command($zones) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + edit: $edit, + get: $get, + list: $list, + accounts: $accounts, + ips: $ips, + zones: $zones, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/address-maps/ips/bulk-create.ts b/packages/cli/src/commands/_generated/addressing/address-maps/ips/bulk-create.ts index ddcaa10491..4c15d64b85 100644 --- a/packages/cli/src/commands/_generated/addressing/address-maps/ips/bulk-create.ts +++ b/packages/cli/src/commands/_generated/addressing/address-maps/ips/bulk-create.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/addressing/address-maps/ips/bulk-create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * bulk-create command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,45 +17,44 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing address-maps ips bulk-create\n\nAdd multiple IPs to a particular address map." - ) - .option("address-map-id", { - type: "string", - description: "Identifier of an Address Map.", - demandOption: true, - }) - .option("ips", { - type: "string", - array: true, - description: "The ips field", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "bulk-create", describe: "Add Multiple IPs to an Address Map", - builder, + usage: + "$0 addressing address-maps ips bulk-create\n\nAdd multiple IPs to a particular address map.", + flags: { + "address-map-id": { + kind: "parsed", + brief: "Identifier of an Address Map.", + parse: String, + }, + ips: { + kind: "parsed", + brief: "The ips field", + variadic: true, + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "addressing address-maps ips bulk-create", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -123,6 +121,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/address-maps/ips/bulk-delete.ts b/packages/cli/src/commands/_generated/addressing/address-maps/ips/bulk-delete.ts index 1020cfd49e..458effea63 100644 --- a/packages/cli/src/commands/_generated/addressing/address-maps/ips/bulk-delete.ts +++ b/packages/cli/src/commands/_generated/addressing/address-maps/ips/bulk-delete.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/addressing/address-maps/ips/bulk-delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * bulk-delete command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,44 +18,43 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing address-maps ips bulk-delete\n\nRemove multiple IPs from a particular address map." - ) - .option("address-map-id", { - type: "string", - description: "Identifier of an Address Map.", - demandOption: true, - }) - .option("ips", { - type: "string", - array: true, - description: "The ips field", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "bulk-delete", + describe: "Remove Multiple IPs from an Address Map", + usage: + "$0 addressing address-maps ips bulk-delete\n\nRemove multiple IPs from a particular address map.", + flags: { + "address-map-id": { + kind: "parsed", + brief: "Identifier of an Address Map.", + parse: String, + }, + ips: { + kind: "parsed", + brief: "The ips field", + variadic: true, + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "bulk-delete", - describe: "Remove Multiple IPs from an Address Map", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { @@ -64,7 +62,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -135,6 +133,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/address-maps/ips/create.ts b/packages/cli/src/commands/_generated/addressing/address-maps/ips/create.ts index cd6d110455..6c122f2b9f 100644 --- a/packages/cli/src/commands/_generated/addressing/address-maps/ips/create.ts +++ b/packages/cli/src/commands/_generated/addressing/address-maps/ips/create.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/addressing/address-maps/ips/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,41 +16,37 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing address-maps ips create \n\nAdd an IP from a prefix owned by the account to a particular address map." - ) - .positional("ip-address", { - type: "string", - description: "An IPv4 or IPv6 address.", - demandOption: true, - }) - .option("address-map-id", { - type: "string", - description: "Identifier of an Address Map.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create ", describe: "Add an IP to an Address Map", - builder, + usage: + "$0 addressing address-maps ips create \n\nAdd an IP from a prefix owned by the account to a particular address map.", + flags: { + "address-map-id": { + kind: "parsed", + brief: "Identifier of an Address Map.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "ip-address", + brief: "An IPv4 or IPv6 address.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "addressing address-maps ips create", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -83,6 +78,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/address-maps/ips/delete.ts b/packages/cli/src/commands/_generated/addressing/address-maps/ips/delete.ts index 7fea83c550..3431461206 100644 --- a/packages/cli/src/commands/_generated/addressing/address-maps/ips/delete.ts +++ b/packages/cli/src/commands/_generated/addressing/address-maps/ips/delete.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/addressing/address-maps/ips/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,40 +17,36 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing address-maps ips delete \n\nRemove an IP from a particular address map." - ) - .positional("ip-address", { - type: "string", - description: "An IPv4 or IPv6 address.", - demandOption: true, - }) - .option("address-map-id", { - type: "string", - description: "Identifier of an Address Map.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Remove an IP from an Address Map", + usage: + "$0 addressing address-maps ips delete \n\nRemove an IP from a particular address map.", + flags: { + "address-map-id": { + kind: "parsed", + brief: "Identifier of an Address Map.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Remove an IP from an Address Map", - builder, + }, + }, + operands: [ + { + placeholder: "ip-address", + brief: "An IPv4 or IPv6 address.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -59,7 +54,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -95,6 +90,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/address-maps/ips/index.ts b/packages/cli/src/commands/_generated/addressing/address-maps/ips/index.ts index e00d660272..0c0ec84a5f 100644 --- a/packages/cli/src/commands/_generated/addressing/address-maps/ips/index.ts +++ b/packages/cli/src/commands/_generated/addressing/address-maps/ips/index.ts @@ -2,27 +2,22 @@ import $bulkcreate from "./bulk-create.js"; import $bulkdelete from "./bulk-delete.js"; import $create from "./create.js"; import $delete from "./delete.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * ips command group * @generated from apis/overlays/addressing.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "ips", describe: "Operations for address-maps.ips", - builder: (yargs) => { - return yargs - .command($bulkcreate) - .command($bulkdelete) - .command($create) - .command($delete) - .demandCommand(1, "Please specify a subcommand"); + routes: { + "bulk-create": $bulkcreate, + "bulk-delete": $bulkdelete, + create: $create, + delete: $delete, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/address-maps/list.ts b/packages/cli/src/commands/_generated/addressing/address-maps/list.ts index ee9ea6010d..ea55bf9cdf 100644 --- a/packages/cli/src/commands/_generated/addressing/address-maps/list.ts +++ b/packages/cli/src/commands/_generated/addressing/address-maps/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/addressing/address-maps/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing address-maps list\n\nList all address maps owned by the account." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List Address Maps", - builder, + usage: + "$0 addressing address-maps list\n\nList all address maps owned by the account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "addressing address-maps list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/address-maps/zones/bulk-create.ts b/packages/cli/src/commands/_generated/addressing/address-maps/zones/bulk-create.ts index 23a40d4432..34859a7df4 100644 --- a/packages/cli/src/commands/_generated/addressing/address-maps/zones/bulk-create.ts +++ b/packages/cli/src/commands/_generated/addressing/address-maps/zones/bulk-create.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/addressing/address-maps/zones/bulk-create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * bulk-create command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,45 +17,44 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing address-maps zones bulk-create\n\nAdd multiple zones as members of a particular address map." - ) - .option("address-map-id", { - type: "string", - description: "Identifier of an Address Map.", - demandOption: true, - }) - .option("zones", { - type: "string", - array: true, - description: "The zones field", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "bulk-create", describe: "Add Multiple Zones to an Address Map", - builder, + usage: + "$0 addressing address-maps zones bulk-create\n\nAdd multiple zones as members of a particular address map.", + flags: { + "address-map-id": { + kind: "parsed", + brief: "Identifier of an Address Map.", + parse: String, + }, + zones: { + kind: "parsed", + brief: "The zones field", + variadic: true, + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "addressing address-maps zones bulk-create", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -123,6 +121,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/address-maps/zones/bulk-delete.ts b/packages/cli/src/commands/_generated/addressing/address-maps/zones/bulk-delete.ts index 8e1d8303f1..2edb45de73 100644 --- a/packages/cli/src/commands/_generated/addressing/address-maps/zones/bulk-delete.ts +++ b/packages/cli/src/commands/_generated/addressing/address-maps/zones/bulk-delete.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/addressing/address-maps/zones/bulk-delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * bulk-delete command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,44 +18,43 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing address-maps zones bulk-delete\n\nRemove multiple zones as members of a particular address map." - ) - .option("address-map-id", { - type: "string", - description: "Identifier of an Address Map.", - demandOption: true, - }) - .option("zones", { - type: "string", - array: true, - description: "The zones field", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "bulk-delete", + describe: "Remove Multiple Zones from an Address Map", + usage: + "$0 addressing address-maps zones bulk-delete\n\nRemove multiple zones as members of a particular address map.", + flags: { + "address-map-id": { + kind: "parsed", + brief: "Identifier of an Address Map.", + parse: String, + }, + zones: { + kind: "parsed", + brief: "The zones field", + variadic: true, + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "bulk-delete", - describe: "Remove Multiple Zones from an Address Map", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { @@ -64,7 +62,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -135,6 +133,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/address-maps/zones/create.ts b/packages/cli/src/commands/_generated/addressing/address-maps/zones/create.ts index 83150b733d..94690e44fa 100644 --- a/packages/cli/src/commands/_generated/addressing/address-maps/zones/create.ts +++ b/packages/cli/src/commands/_generated/addressing/address-maps/zones/create.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/addressing/address-maps/zones/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,41 +16,37 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing address-maps zones create \n\nAdd a zone as a member of a particular address map." - ) - .positional("member-zone-id", { - type: "string", - description: "Identifier of a zone.", - demandOption: true, - }) - .option("address-map-id", { - type: "string", - description: "Identifier of an Address Map.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create ", describe: "Add a zone membership to an Address Map", - builder, + usage: + "$0 addressing address-maps zones create \n\nAdd a zone as a member of a particular address map.", + flags: { + "address-map-id": { + kind: "parsed", + brief: "Identifier of an Address Map.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "member-zone-id", + brief: "Identifier of a zone.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "addressing address-maps zones create", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -83,6 +78,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/address-maps/zones/delete.ts b/packages/cli/src/commands/_generated/addressing/address-maps/zones/delete.ts index 13913aa65e..dce5d4d9e4 100644 --- a/packages/cli/src/commands/_generated/addressing/address-maps/zones/delete.ts +++ b/packages/cli/src/commands/_generated/addressing/address-maps/zones/delete.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/addressing/address-maps/zones/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,40 +17,36 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing address-maps zones delete \n\nRemove a zone as a member of a particular address map." - ) - .positional("member-zone-id", { - type: "string", - description: "Identifier of a zone.", - demandOption: true, - }) - .option("address-map-id", { - type: "string", - description: "Identifier of an Address Map.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Remove a zone membership from an Address Map", + usage: + "$0 addressing address-maps zones delete \n\nRemove a zone as a member of a particular address map.", + flags: { + "address-map-id": { + kind: "parsed", + brief: "Identifier of an Address Map.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Remove a zone membership from an Address Map", - builder, + }, + }, + operands: [ + { + placeholder: "member-zone-id", + brief: "Identifier of a zone.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -59,7 +54,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -95,6 +90,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/address-maps/zones/index.ts b/packages/cli/src/commands/_generated/addressing/address-maps/zones/index.ts index f2ce46612d..12d73e8e4b 100644 --- a/packages/cli/src/commands/_generated/addressing/address-maps/zones/index.ts +++ b/packages/cli/src/commands/_generated/addressing/address-maps/zones/index.ts @@ -2,27 +2,22 @@ import $bulkcreate from "./bulk-create.js"; import $bulkdelete from "./bulk-delete.js"; import $create from "./create.js"; import $delete from "./delete.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * zones command group * @generated from apis/overlays/addressing.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "zones", describe: "Operations for address-maps.zones", - builder: (yargs) => { - return yargs - .command($bulkcreate) - .command($bulkdelete) - .command($create) - .command($delete) - .demandCommand(1, "Please specify a subcommand"); + routes: { + "bulk-create": $bulkcreate, + "bulk-delete": $bulkdelete, + create: $create, + delete: $delete, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/index.ts b/packages/cli/src/commands/_generated/addressing/index.ts index 7a92b50dcc..99c664fc0a 100644 --- a/packages/cli/src/commands/_generated/addressing/index.ts +++ b/packages/cli/src/commands/_generated/addressing/index.ts @@ -4,29 +4,24 @@ import $loadocuments from "./loa-documents/index.js"; import $prefixes from "./prefixes/index.js"; import $regionalhostnames from "./regional-hostnames/index.js"; import $services from "./services/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * addressing command * @generated from apis/overlays/addressing.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "addressing", describe: "addressing", - builder: (yargs) => { - return yargs - .command($addressmaps) - .command($leases) - .command($loadocuments) - .command($prefixes) - .command($regionalhostnames) - .command($services) - .demandCommand(1, "Please specify a subcommand"); + routes: { + "address-maps": $addressmaps, + leases: $leases, + "loa-documents": $loadocuments, + prefixes: $prefixes, + "regional-hostnames": $regionalhostnames, + services: $services, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/leases/index.ts b/packages/cli/src/commands/_generated/addressing/leases/index.ts index 306f2cecdc..d7c55d7d66 100644 --- a/packages/cli/src/commands/_generated/addressing/leases/index.ts +++ b/packages/cli/src/commands/_generated/addressing/leases/index.ts @@ -1,20 +1,17 @@ import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * leases command group * @generated from apis/overlays/addressing.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "leases", describe: "Operations for leases", - builder: (yargs) => { - return yargs.command($list).demandCommand(1, "Please specify a subcommand"); + routes: { + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/leases/list.ts b/packages/cli/src/commands/_generated/addressing/leases/list.ts index 9312d5beee..b5fc84fd6f 100644 --- a/packages/cli/src/commands/_generated/addressing/leases/list.ts +++ b/packages/cli/src/commands/_generated/addressing/leases/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/addressing/leases/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,29 +16,25 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage("$0 addressing leases list\n\nList all leases owned by the account.") - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List Leases", - builder, + usage: "$0 addressing leases list\n\nList all leases owned by the account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "addressing leases list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -64,6 +59,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/loa-documents/create.ts b/packages/cli/src/commands/_generated/addressing/loa-documents/create.ts index f076f53864..44c46e215d 100644 --- a/packages/cli/src/commands/_generated/addressing/loa-documents/create.ts +++ b/packages/cli/src/commands/_generated/addressing/loa-documents/create.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,43 +17,44 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing loa-documents create\n\nSubmit LOA document (pdf format) under the account." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }) - .option("file", { - type: "string", - description: "Path to a file to upload as the request body", - }) - .option("loa-document", { - type: "string", - description: "LOA document to upload.", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create", describe: "Upload LOA Document", - builder, + usage: + "$0 addressing loa-documents create\n\nSubmit LOA document (pdf format) under the account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + file: { + kind: "parsed", + brief: "Path to a file to upload as the request body", + optional: true, + parse: String, + }, + "loa-document": { + kind: "parsed", + brief: "LOA document to upload.", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "addressing loa-documents create", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -146,6 +146,6 @@ const command: CommandModule = { } } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/loa-documents/get.ts b/packages/cli/src/commands/_generated/addressing/loa-documents/get.ts index 37844ecd6b..cc631f92a6 100644 --- a/packages/cli/src/commands/_generated/addressing/loa-documents/get.ts +++ b/packages/cli/src/commands/_generated/addressing/loa-documents/get.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,42 +16,38 @@ import { withProgress } from "#lib/progress.js"; import { fetchRawBytes, writeRawOutput } from "#lib/raw-fetch.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing loa-documents get \n\nDownload specified LOA document under the account." - ) - .positional("loa-document-id", { - type: "string", - description: "Identifier for the uploaded LOA document.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "get ", + describe: "Download LOA Document", + usage: + "$0 addressing loa-documents get \n\nDownload specified LOA document under the account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("text", { - type: "boolean", - description: + }, + text: { + kind: "boolean", + brief: "Decode the response body as UTF-8 text instead of writing raw bytes", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "get ", - describe: "Download LOA Document", - builder, + }, + }, + operands: [ + { + placeholder: "loa-document-id", + brief: "Identifier for the uploaded LOA document.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "addressing loa-documents get", classification: { safeFlags: ["dry-run", "text"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -89,6 +84,6 @@ const command: CommandModule = { return; } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/loa-documents/index.ts b/packages/cli/src/commands/_generated/addressing/loa-documents/index.ts index c55ae9052c..124eb60c88 100644 --- a/packages/cli/src/commands/_generated/addressing/loa-documents/index.ts +++ b/packages/cli/src/commands/_generated/addressing/loa-documents/index.ts @@ -1,26 +1,21 @@ import $create from "./create.js"; import $get from "./get.js"; import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * loa-documents command group * @generated from apis/overlays/addressing.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "loa-documents", describe: "Operations for loa-documents", - builder: (yargs) => { - return yargs - .command($create) - .command($get) - .command($list) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + get: $get, + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/loa-documents/list.ts b/packages/cli/src/commands/_generated/addressing/loa-documents/list.ts index 4aa7541da2..1fc3d84adc 100644 --- a/packages/cli/src/commands/_generated/addressing/loa-documents/list.ts +++ b/packages/cli/src/commands/_generated/addressing/loa-documents/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/addressing/loa-documents/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing loa-documents list\n\nList all LOA documents uploaded under the account." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List LOA Documents", - builder, + usage: + "$0 addressing loa-documents list\n\nList all LOA documents uploaded under the account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "addressing loa-documents list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/prefixes/advertisement-status/edit.ts b/packages/cli/src/commands/_generated/addressing/prefixes/advertisement-status/edit.ts index a5441283bf..e96bee0542 100644 --- a/packages/cli/src/commands/_generated/addressing/prefixes/advertisement-status/edit.ts +++ b/packages/cli/src/commands/_generated/addressing/prefixes/advertisement-status/edit.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/addressing/prefixes/advertisement-status/edit.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * edit command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,45 +17,44 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing prefixes advertisement-status edit \n\nAdvertise or withdraw the BGP route for a prefix. **Deprecated:** Prefer the BGP Prefixes endpoints, which additionally allow for advertising and withdrawing subnets of an IP prefix." - ) - .positional("prefix-id", { - type: "string", - description: "Identifier of an IP Prefix.", - demandOption: true, - }) - .option("advertised", { - type: "boolean", - description: - "Advertisement status of the prefix. If `true`, the BGP route for the prefix is advertised to the Internet. If \n`false`, the BGP route is withdrawn.\n", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "edit ", describe: "Update Prefix Dynamic Advertisement Status", - builder, + usage: + "$0 addressing prefixes advertisement-status edit \n\nAdvertise or withdraw the BGP route for a prefix. **Deprecated:** Prefer the BGP Prefixes endpoints, which additionally allow for advertising and withdrawing subnets of an IP prefix.", + flags: { + advertised: { + kind: "boolean", + brief: + "Advertisement status of the prefix. If `true`, the BGP route for the prefix is advertised to the Internet. If \n`false`, the BGP route is withdrawn.\n", + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "prefix-id", + brief: "Identifier of an IP Prefix.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "addressing prefixes advertisement-status edit", classification: { safeFlags: ["advertised", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -121,6 +119,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/prefixes/advertisement-status/get.ts b/packages/cli/src/commands/_generated/addressing/prefixes/advertisement-status/get.ts index e5d59aaed0..6e4e961249 100644 --- a/packages/cli/src/commands/_generated/addressing/prefixes/advertisement-status/get.ts +++ b/packages/cli/src/commands/_generated/addressing/prefixes/advertisement-status/get.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/addressing/prefixes/advertisement-status/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,32 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing prefixes advertisement-status get \n\nView the current advertisement state for a prefix. **Deprecated:** Prefer the BGP Prefixes endpoints, which additionally allow for advertising and withdrawing subnets of an IP prefix." - ) - .positional("prefix-id", { - type: "string", - description: "Identifier of an IP Prefix.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get Advertisement Status", - builder, + usage: + "$0 addressing prefixes advertisement-status get \n\nView the current advertisement state for a prefix. **Deprecated:** Prefer the BGP Prefixes endpoints, which additionally allow for advertising and withdrawing subnets of an IP prefix.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "prefix-id", + brief: "Identifier of an IP Prefix.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "addressing prefixes advertisement-status get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -74,6 +69,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/prefixes/advertisement-status/index.ts b/packages/cli/src/commands/_generated/addressing/prefixes/advertisement-status/index.ts index a8c3870d93..a139624251 100644 --- a/packages/cli/src/commands/_generated/addressing/prefixes/advertisement-status/index.ts +++ b/packages/cli/src/commands/_generated/addressing/prefixes/advertisement-status/index.ts @@ -1,24 +1,19 @@ import $edit from "./edit.js"; import $get from "./get.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * advertisement-status command group * @generated from apis/overlays/addressing.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "advertisement-status", describe: "Operations for prefixes.advertisement-status", - builder: (yargs) => { - return yargs - .command($edit) - .command($get) - .demandCommand(1, "Please specify a subcommand"); + routes: { + edit: $edit, + get: $get, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/prefixes/bgp-prefixes/create.ts b/packages/cli/src/commands/_generated/addressing/prefixes/bgp-prefixes/create.ts index 0f245bf2aa..f157aa78a5 100644 --- a/packages/cli/src/commands/_generated/addressing/prefixes/bgp-prefixes/create.ts +++ b/packages/cli/src/commands/_generated/addressing/prefixes/bgp-prefixes/create.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/addressing/prefixes/bgp-prefixes/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,44 +19,44 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing prefixes bgp-prefixes create \n\nCreate a BGP prefix, controlling the BGP advertisement status of a specific subnet. When created, BGP prefixes are initially withdrawn, and can be advertised with the Update BGP Prefix API." - ) - .positional("prefix-id", { - type: "string", - description: "Identifier of an IP Prefix.", - demandOption: true, - }) - .option("cidr", { - type: "string", - description: "IP Prefix in Classless Inter-Domain Routing format.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create ", describe: "Create BGP Prefix", - builder, + usage: + "$0 addressing prefixes bgp-prefixes create \n\nCreate a BGP prefix, controlling the BGP advertisement status of a specific subnet. When created, BGP prefixes are initially withdrawn, and can be advertised with the Update BGP Prefix API.", + flags: { + cidr: { + kind: "parsed", + brief: "IP Prefix in Classless Inter-Domain Routing format.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "prefix-id", + brief: "Identifier of an IP Prefix.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "addressing prefixes bgp-prefixes create", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -131,6 +130,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/prefixes/bgp-prefixes/delete.ts b/packages/cli/src/commands/_generated/addressing/prefixes/bgp-prefixes/delete.ts index 11cb19fbf2..41ab4bd9b2 100644 --- a/packages/cli/src/commands/_generated/addressing/prefixes/bgp-prefixes/delete.ts +++ b/packages/cli/src/commands/_generated/addressing/prefixes/bgp-prefixes/delete.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/addressing/prefixes/bgp-prefixes/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,40 +17,36 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing prefixes bgp-prefixes delete \n\nDelete a BGP Prefix associated with the specified IP Prefix. A BGP Prefix must be withdrawn before it can be deleted." - ) - .positional("bgp-prefix-id", { - type: "string", - description: "Identifier of BGP Prefix.", - demandOption: true, - }) - .option("prefix-id", { - type: "string", - description: "Identifier of an IP Prefix.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete BGP Prefix", + usage: + "$0 addressing prefixes bgp-prefixes delete \n\nDelete a BGP Prefix associated with the specified IP Prefix. A BGP Prefix must be withdrawn before it can be deleted.", + flags: { + "prefix-id": { + kind: "parsed", + brief: "Identifier of an IP Prefix.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete BGP Prefix", - builder, + }, + }, + operands: [ + { + placeholder: "bgp-prefix-id", + brief: "Identifier of BGP Prefix.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -59,7 +54,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -95,6 +90,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/prefixes/bgp-prefixes/edit.ts b/packages/cli/src/commands/_generated/addressing/prefixes/bgp-prefixes/edit.ts index a3d9182324..20c09aad43 100644 --- a/packages/cli/src/commands/_generated/addressing/prefixes/bgp-prefixes/edit.ts +++ b/packages/cli/src/commands/_generated/addressing/prefixes/bgp-prefixes/edit.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/addressing/prefixes/bgp-prefixes/edit.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * edit command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,52 +17,54 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing prefixes bgp-prefixes edit \n\nUpdate the properties of a BGP Prefix, such as the on demand advertisement status (advertised or withdrawn)." - ) - .positional("bgp-prefix-id", { - type: "string", - description: "Identifier of BGP Prefix.", - demandOption: true, - }) - .option("prefix-id", { - type: "string", - description: "Identifier of an IP Prefix.", - demandOption: true, - }) - .option("asn-prepend-count", { - type: "number", - description: +const command = apiCommand({ + command: "edit ", + describe: "Update BGP Prefix", + usage: + "$0 addressing prefixes bgp-prefixes edit \n\nUpdate the properties of a BGP Prefix, such as the on demand advertisement status (advertised or withdrawn).", + flags: { + "prefix-id": { + kind: "parsed", + brief: "Identifier of an IP Prefix.", + parse: String, + }, + "asn-prepend-count": { + kind: "parsed", + brief: "Number of times to prepend the Cloudflare ASN to the BGP AS-Path attribute", - }) - .option("auto-advertise-withdraw", { - type: "boolean", - description: + optional: true, + parse: Number, + }, + "auto-advertise-withdraw": { + kind: "boolean", + brief: "Determines if Cloudflare advertises a BYOIP BGP prefix even when there is no matching BGP prefix in the Magic routing table. When true, Cloudflare will automatically withdraw the BGP prefix when there are no matching BGP routes, and will resume advertising when there is at least one matching BGP route.", - }) - .option("on-demand-advertised", { - type: "boolean", - description: "The on_demand.advertised field", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + }, + "on-demand-advertised": { + kind: "boolean", + brief: "The on_demand.advertised field", + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "edit ", - describe: "Update BGP Prefix", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "bgp-prefix-id", + brief: "Identifier of BGP Prefix.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -74,7 +75,7 @@ const command: CommandModule = { "on-demand-advertised", "dry-run", ], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -141,6 +142,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/prefixes/bgp-prefixes/get.ts b/packages/cli/src/commands/_generated/addressing/prefixes/bgp-prefixes/get.ts index a6c0b6cf2a..d0d3a2c71b 100644 --- a/packages/cli/src/commands/_generated/addressing/prefixes/bgp-prefixes/get.ts +++ b/packages/cli/src/commands/_generated/addressing/prefixes/bgp-prefixes/get.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/addressing/prefixes/bgp-prefixes/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,41 +16,37 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing prefixes bgp-prefixes get \n\nRetrieve a single BGP Prefix according to its identifier" - ) - .positional("bgp-prefix-id", { - type: "string", - description: "Identifier of BGP Prefix.", - demandOption: true, - }) - .option("prefix-id", { - type: "string", - description: "Identifier of an IP Prefix.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Fetch BGP Prefix", - builder, + usage: + "$0 addressing prefixes bgp-prefixes get \n\nRetrieve a single BGP Prefix according to its identifier", + flags: { + "prefix-id": { + kind: "parsed", + brief: "Identifier of an IP Prefix.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "bgp-prefix-id", + brief: "Identifier of BGP Prefix.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "addressing prefixes bgp-prefixes get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -83,6 +78,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/prefixes/bgp-prefixes/index.ts b/packages/cli/src/commands/_generated/addressing/prefixes/bgp-prefixes/index.ts index fed42a814e..40034df705 100644 --- a/packages/cli/src/commands/_generated/addressing/prefixes/bgp-prefixes/index.ts +++ b/packages/cli/src/commands/_generated/addressing/prefixes/bgp-prefixes/index.ts @@ -3,28 +3,23 @@ import $delete from "./delete.js"; import $edit from "./edit.js"; import $get from "./get.js"; import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * bgp-prefixes command group * @generated from apis/overlays/addressing.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "bgp-prefixes", describe: "Operations for prefixes.bgp-prefixes", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($edit) - .command($get) - .command($list) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + edit: $edit, + get: $get, + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/prefixes/bgp-prefixes/list.ts b/packages/cli/src/commands/_generated/addressing/prefixes/bgp-prefixes/list.ts index dd4c211d2b..155c2c5160 100644 --- a/packages/cli/src/commands/_generated/addressing/prefixes/bgp-prefixes/list.ts +++ b/packages/cli/src/commands/_generated/addressing/prefixes/bgp-prefixes/list.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/addressing/prefixes/bgp-prefixes/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,31 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing prefixes bgp-prefixes list\n\nList all BGP Prefixes within the specified IP Prefix. BGP Prefixes are used to control which specific subnets are advertised to the Internet. It is possible to advertise subnets more specific than an IP Prefix by creating more specific BGP Prefixes." - ) - .option("prefix-id", { - type: "string", - description: "Identifier of an IP Prefix.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List BGP Prefixes", - builder, + usage: + "$0 addressing prefixes bgp-prefixes list\n\nList all BGP Prefixes within the specified IP Prefix. BGP Prefixes are used to control which specific subnets are advertised to the Internet. It is possible to advertise subnets more specific than an IP Prefix by creating more specific BGP Prefixes.", + flags: { + "prefix-id": { + kind: "parsed", + brief: "Identifier of an IP Prefix.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "addressing prefixes bgp-prefixes list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -74,6 +68,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/prefixes/create.ts b/packages/cli/src/commands/_generated/addressing/prefixes/create.ts index f5d19dc59a..cfe109d78e 100644 --- a/packages/cli/src/commands/_generated/addressing/prefixes/create.ts +++ b/packages/cli/src/commands/_generated/addressing/prefixes/create.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/addressing/prefixes/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,58 +19,62 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing prefixes create\n\nAdd a new prefix under the account." - ) - .option("asn", { - type: "number", - description: +const command = apiCommand({ + command: "create", + describe: "Add Prefix", + usage: "$0 addressing prefixes create\n\nAdd a new prefix under the account.", + flags: { + asn: { + kind: "parsed", + brief: "Autonomous System Number (ASN) the prefix will be advertised under. Use 13335 for Cloudflare's ASN, or your own ASN as an integer without the AS prefix. The IRR route and RPKI ROA must authorize this ASN.", - }) - .option("cidr", { - type: "string", - description: "IP Prefix in Classless Inter-Domain Routing format.", - }) - .option("delegate-loa-creation", { - type: "boolean", - description: + optional: true, + parse: Number, + }, + cidr: { + kind: "parsed", + brief: "IP Prefix in Classless Inter-Domain Routing format.", + optional: true, + parse: String, + }, + "delegate-loa-creation": { + kind: "boolean", + brief: "Whether Cloudflare is allowed to generate the LOA document on behalf of the prefix owner.", default: false, - }) - .option("description", { - type: "string", - description: "Description of the prefix.", - }) - .option("loa-document-id", { - type: "string", - description: "Identifier for the uploaded LOA document.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + }, + description: { + kind: "parsed", + brief: "Description of the prefix.", + optional: true, + parse: String, + }, + "loa-document-id": { + kind: "parsed", + brief: "Identifier for the uploaded LOA document.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "create", - describe: "Add Prefix", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "addressing prefixes create", classification: { safeFlags: ["delegate-loa-creation", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -166,6 +169,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/prefixes/delegations/create.ts b/packages/cli/src/commands/_generated/addressing/prefixes/delegations/create.ts index 0afe1c393d..4c14364dd9 100644 --- a/packages/cli/src/commands/_generated/addressing/prefixes/delegations/create.ts +++ b/packages/cli/src/commands/_generated/addressing/prefixes/delegations/create.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/addressing/prefixes/delegations/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,49 +19,51 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing prefixes delegations create \n\nCreate a new account delegation for a given IP prefix." - ) - .positional("prefix-id", { - type: "string", - description: "Identifier of an IP Prefix.", - demandOption: true, - }) - .option("cidr", { - type: "string", - description: "IP Prefix in Classless Inter-Domain Routing format.", - }) - .option("delegated-account-id", { - type: "string", - description: - "Account identifier for the account to which prefix is being delegated.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create ", describe: "Create Prefix Delegation", - builder, + usage: + "$0 addressing prefixes delegations create \n\nCreate a new account delegation for a given IP prefix.", + flags: { + cidr: { + kind: "parsed", + brief: "IP Prefix in Classless Inter-Domain Routing format.", + optional: true, + parse: String, + }, + "delegated-account-id": { + kind: "parsed", + brief: + "Account identifier for the account to which prefix is being delegated.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "prefix-id", + brief: "Identifier of an IP Prefix.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "addressing prefixes delegations create", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -152,6 +153,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/prefixes/delegations/delete.ts b/packages/cli/src/commands/_generated/addressing/prefixes/delegations/delete.ts index bc96bc81e4..4c20cdb179 100644 --- a/packages/cli/src/commands/_generated/addressing/prefixes/delegations/delete.ts +++ b/packages/cli/src/commands/_generated/addressing/prefixes/delegations/delete.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/addressing/prefixes/delegations/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,40 +17,36 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing prefixes delegations delete \n\nDelete an account delegation for a given IP prefix." - ) - .positional("delegation-id", { - type: "string", - description: "Identifier of a Delegation.", - demandOption: true, - }) - .option("prefix-id", { - type: "string", - description: "Identifier of an IP Prefix.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete Prefix Delegation", + usage: + "$0 addressing prefixes delegations delete \n\nDelete an account delegation for a given IP prefix.", + flags: { + "prefix-id": { + kind: "parsed", + brief: "Identifier of an IP Prefix.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete Prefix Delegation", - builder, + }, + }, + operands: [ + { + placeholder: "delegation-id", + brief: "Identifier of a Delegation.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -59,7 +54,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -95,6 +90,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/prefixes/delegations/index.ts b/packages/cli/src/commands/_generated/addressing/prefixes/delegations/index.ts index 45771a2495..edce1f8468 100644 --- a/packages/cli/src/commands/_generated/addressing/prefixes/delegations/index.ts +++ b/packages/cli/src/commands/_generated/addressing/prefixes/delegations/index.ts @@ -1,26 +1,21 @@ import $create from "./create.js"; import $delete from "./delete.js"; import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * delegations command group * @generated from apis/overlays/addressing.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "delegations", describe: "Operations for prefixes.delegations", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($list) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/prefixes/delegations/list.ts b/packages/cli/src/commands/_generated/addressing/prefixes/delegations/list.ts index e479d8af1b..65af556813 100644 --- a/packages/cli/src/commands/_generated/addressing/prefixes/delegations/list.ts +++ b/packages/cli/src/commands/_generated/addressing/prefixes/delegations/list.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/addressing/prefixes/delegations/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,31 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing prefixes delegations list\n\nList all delegations for a given account IP prefix." - ) - .option("prefix-id", { - type: "string", - description: "Identifier of an IP Prefix.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List Prefix Delegations", - builder, + usage: + "$0 addressing prefixes delegations list\n\nList all delegations for a given account IP prefix.", + flags: { + "prefix-id": { + kind: "parsed", + brief: "Identifier of an IP Prefix.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "addressing prefixes delegations list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -74,6 +68,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/prefixes/delete.ts b/packages/cli/src/commands/_generated/addressing/prefixes/delete.ts index 77b6000cf9..6c39c521bb 100644 --- a/packages/cli/src/commands/_generated/addressing/prefixes/delete.ts +++ b/packages/cli/src/commands/_generated/addressing/prefixes/delete.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/addressing/prefixes/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,35 +17,31 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing prefixes delete \n\nDelete an unapproved prefix owned by the account." - ) - .positional("prefix-id", { - type: "string", - description: "Identifier of an IP Prefix.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete Prefix", + usage: + "$0 addressing prefixes delete \n\nDelete an unapproved prefix owned by the account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete Prefix", - builder, + }, + }, + operands: [ + { + placeholder: "prefix-id", + brief: "Identifier of an IP Prefix.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -54,7 +49,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -86,6 +81,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/prefixes/edit.ts b/packages/cli/src/commands/_generated/addressing/prefixes/edit.ts index 5b6762c753..cfbf087be7 100644 --- a/packages/cli/src/commands/_generated/addressing/prefixes/edit.ts +++ b/packages/cli/src/commands/_generated/addressing/prefixes/edit.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/addressing/prefixes/edit.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * edit command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,44 +19,44 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing prefixes edit \n\nModify the description for a prefix owned by the account." - ) - .positional("prefix-id", { - type: "string", - description: "Identifier of an IP Prefix.", - demandOption: true, - }) - .option("description", { - type: "string", - description: "Description of the prefix.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "edit ", describe: "Update Prefix Description", - builder, + usage: + "$0 addressing prefixes edit \n\nModify the description for a prefix owned by the account.", + flags: { + description: { + kind: "parsed", + brief: "Description of the prefix.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "prefix-id", + brief: "Identifier of an IP Prefix.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "addressing prefixes edit", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -131,6 +130,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/prefixes/get.ts b/packages/cli/src/commands/_generated/addressing/prefixes/get.ts index 9da2d34076..f49f714abf 100644 --- a/packages/cli/src/commands/_generated/addressing/prefixes/get.ts +++ b/packages/cli/src/commands/_generated/addressing/prefixes/get.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/addressing/prefixes/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,32 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing prefixes get \n\nList a particular prefix owned by the account." - ) - .positional("prefix-id", { - type: "string", - description: "Identifier of an IP Prefix.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Prefix Details", - builder, + usage: + "$0 addressing prefixes get \n\nList a particular prefix owned by the account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "prefix-id", + brief: "Identifier of an IP Prefix.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "addressing prefixes get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -74,6 +69,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/prefixes/index.ts b/packages/cli/src/commands/_generated/addressing/prefixes/index.ts index 3a2faf947d..f27a94d3d0 100644 --- a/packages/cli/src/commands/_generated/addressing/prefixes/index.ts +++ b/packages/cli/src/commands/_generated/addressing/prefixes/index.ts @@ -8,33 +8,28 @@ import $get from "./get.js"; import $list from "./list.js"; import $servicebindings from "./service-bindings/index.js"; import $validate from "./validate/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * prefixes command group * @generated from apis/overlays/addressing.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "prefixes", describe: "Operations for prefixes", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($edit) - .command($get) - .command($list) - .command($advertisementstatus) - .command($bgpprefixes) - .command($delegations) - .command($servicebindings) - .command($validate) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + edit: $edit, + get: $get, + list: $list, + "advertisement-status": $advertisementstatus, + "bgp-prefixes": $bgpprefixes, + delegations: $delegations, + "service-bindings": $servicebindings, + validate: $validate, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/prefixes/list.ts b/packages/cli/src/commands/_generated/addressing/prefixes/list.ts index 2f80e5a572..53da3b8782 100644 --- a/packages/cli/src/commands/_generated/addressing/prefixes/list.ts +++ b/packages/cli/src/commands/_generated/addressing/prefixes/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/addressing/prefixes/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing prefixes list\n\nList all prefixes owned by the account." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List Prefixes", - builder, + usage: + "$0 addressing prefixes list\n\nList all prefixes owned by the account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "addressing prefixes list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/prefixes/service-bindings/create.ts b/packages/cli/src/commands/_generated/addressing/prefixes/service-bindings/create.ts index 016a5f2fa4..91f0d29060 100644 --- a/packages/cli/src/commands/_generated/addressing/prefixes/service-bindings/create.ts +++ b/packages/cli/src/commands/_generated/addressing/prefixes/service-bindings/create.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/addressing/prefixes/service-bindings/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,49 +19,51 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing prefixes service-bindings create \n\nCreates a new Service Binding, routing traffic to IPs within the given CIDR to a service running on Cloudflare's network. **NOTE:** The first Service Binding created for an IP Prefix must exactly match the IP Prefix's CIDR. Subsequent Service Bindings may be created with a more-specific CIDR. Refer to the [Service Bindings Documentation](https://developers.cloudflare.com/byoip/service-bindings/) for compatibility details." - ) - .positional("prefix-id", { - type: "string", - description: "Identifier of an IP Prefix.", - demandOption: true, - }) - .option("cidr", { - type: "string", - description: "IP Prefix in Classless Inter-Domain Routing format.", - }) - .option("service-id", { - type: "string", - description: - "Identifier of a Service on the Cloudflare network. Available services and their IDs may be found in the\n**List Services** endpoint.\n", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create ", describe: "Create Service Binding", - builder, + usage: + "$0 addressing prefixes service-bindings create \n\nCreates a new Service Binding, routing traffic to IPs within the given CIDR to a service running on Cloudflare's network. **NOTE:** The first Service Binding created for an IP Prefix must exactly match the IP Prefix's CIDR. Subsequent Service Bindings may be created with a more-specific CIDR. Refer to the [Service Bindings Documentation](https://developers.cloudflare.com/byoip/service-bindings/) for compatibility details.", + flags: { + cidr: { + kind: "parsed", + brief: "IP Prefix in Classless Inter-Domain Routing format.", + optional: true, + parse: String, + }, + "service-id": { + kind: "parsed", + brief: + "Identifier of a Service on the Cloudflare network. Available services and their IDs may be found in the\n**List Services** endpoint.\n", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "prefix-id", + brief: "Identifier of an IP Prefix.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "addressing prefixes service-bindings create", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -152,6 +153,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/prefixes/service-bindings/delete.ts b/packages/cli/src/commands/_generated/addressing/prefixes/service-bindings/delete.ts index bda77dfa80..77beb7bf96 100644 --- a/packages/cli/src/commands/_generated/addressing/prefixes/service-bindings/delete.ts +++ b/packages/cli/src/commands/_generated/addressing/prefixes/service-bindings/delete.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/addressing/prefixes/service-bindings/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,40 +17,36 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing prefixes service-bindings delete \n\nDelete a Service Binding" - ) - .positional("binding-id", { - type: "string", - description: "Identifier of a Service Binding.", - demandOption: true, - }) - .option("prefix-id", { - type: "string", - description: "Identifier of an IP Prefix.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete Service Binding", + usage: + "$0 addressing prefixes service-bindings delete \n\nDelete a Service Binding", + flags: { + "prefix-id": { + kind: "parsed", + brief: "Identifier of an IP Prefix.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete Service Binding", - builder, + }, + }, + operands: [ + { + placeholder: "binding-id", + brief: "Identifier of a Service Binding.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -59,7 +54,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -95,6 +90,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/prefixes/service-bindings/get.ts b/packages/cli/src/commands/_generated/addressing/prefixes/service-bindings/get.ts index 34b7ae169e..092bc88698 100644 --- a/packages/cli/src/commands/_generated/addressing/prefixes/service-bindings/get.ts +++ b/packages/cli/src/commands/_generated/addressing/prefixes/service-bindings/get.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/addressing/prefixes/service-bindings/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,41 +16,37 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing prefixes service-bindings get \n\nFetch a single Service Binding" - ) - .positional("binding-id", { - type: "string", - description: "Identifier of a Service Binding.", - demandOption: true, - }) - .option("prefix-id", { - type: "string", - description: "Identifier of an IP Prefix.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get Service Binding", - builder, + usage: + "$0 addressing prefixes service-bindings get \n\nFetch a single Service Binding", + flags: { + "prefix-id": { + kind: "parsed", + brief: "Identifier of an IP Prefix.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "binding-id", + brief: "Identifier of a Service Binding.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "addressing prefixes service-bindings get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -83,6 +78,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/prefixes/service-bindings/index.ts b/packages/cli/src/commands/_generated/addressing/prefixes/service-bindings/index.ts index 49a6e5a1bf..bd029dad03 100644 --- a/packages/cli/src/commands/_generated/addressing/prefixes/service-bindings/index.ts +++ b/packages/cli/src/commands/_generated/addressing/prefixes/service-bindings/index.ts @@ -2,27 +2,22 @@ import $create from "./create.js"; import $delete from "./delete.js"; import $get from "./get.js"; import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * service-bindings command group * @generated from apis/overlays/addressing.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "service-bindings", describe: "Operations for prefixes.service-bindings", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($get) - .command($list) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + get: $get, + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/prefixes/service-bindings/list.ts b/packages/cli/src/commands/_generated/addressing/prefixes/service-bindings/list.ts index 483fddae06..44c624b1e4 100644 --- a/packages/cli/src/commands/_generated/addressing/prefixes/service-bindings/list.ts +++ b/packages/cli/src/commands/_generated/addressing/prefixes/service-bindings/list.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/addressing/prefixes/service-bindings/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,31 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing prefixes service-bindings list\n\nList the Cloudflare services this prefix is currently bound to. Traffic sent to an address within an IP prefix will be routed to the Cloudflare service of the most-specific Service Binding matching the address. **Example:** binding `192.0.2.0/24` to Cloudflare Magic Transit and `192.0.2.1/32` to the Cloudflare CDN would route traffic for `192.0.2.1` to the CDN, and traffic for all other IPs in the prefix to Cloudflare Magic Transit." - ) - .option("prefix-id", { - type: "string", - description: "Identifier of an IP Prefix.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List Service Bindings", - builder, + usage: + "$0 addressing prefixes service-bindings list\n\nList the Cloudflare services this prefix is currently bound to. Traffic sent to an address within an IP prefix will be routed to the Cloudflare service of the most-specific Service Binding matching the address. **Example:** binding `192.0.2.0/24` to Cloudflare Magic Transit and `192.0.2.1/32` to the Cloudflare CDN would route traffic for `192.0.2.1` to the CDN, and traffic for all other IPs in the prefix to Cloudflare Magic Transit.", + flags: { + "prefix-id": { + kind: "parsed", + brief: "Identifier of an IP Prefix.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "addressing prefixes service-bindings list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -74,6 +68,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/prefixes/validate/create.ts b/packages/cli/src/commands/_generated/addressing/prefixes/validate/create.ts index 397860e262..c954adf43a 100644 --- a/packages/cli/src/commands/_generated/addressing/prefixes/validate/create.ts +++ b/packages/cli/src/commands/_generated/addressing/prefixes/validate/create.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/addressing/prefixes/validate/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,32 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing prefixes validate create \n\nTriggers a new prefix validation. The checks run asynchronously and include IRR, RPKI, prefix ownership, and, when applicable, ASN ownership and Autonomous System Provider Authorization (ASPA). Use Prefix Details to monitor the results. Approval does not advertise the prefix or activate traffic." - ) - .positional("prefix-id", { - type: "string", - description: "Identifier of an IP Prefix.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create ", describe: "Validate Prefix", - builder, + usage: + "$0 addressing prefixes validate create \n\nTriggers a new prefix validation. The checks run asynchronously and include IRR, RPKI, prefix ownership, and, when applicable, ASN ownership and Autonomous System Provider Authorization (ASPA). Use Prefix Details to monitor the results. Approval does not advertise the prefix or activate traffic.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "prefix-id", + brief: "Identifier of an IP Prefix.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "addressing prefixes validate create", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -74,6 +69,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/prefixes/validate/index.ts b/packages/cli/src/commands/_generated/addressing/prefixes/validate/index.ts index be501cbd79..784742f068 100644 --- a/packages/cli/src/commands/_generated/addressing/prefixes/validate/index.ts +++ b/packages/cli/src/commands/_generated/addressing/prefixes/validate/index.ts @@ -1,22 +1,17 @@ import $create from "./create.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * validate command group * @generated from apis/overlays/addressing.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "validate", describe: "Operations for prefixes.validate", - builder: (yargs) => { - return yargs - .command($create) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/regional-hostnames/create.ts b/packages/cli/src/commands/_generated/addressing/regional-hostnames/create.ts index 75caa581a5..f11aeaebee 100644 --- a/packages/cli/src/commands/_generated/addressing/regional-hostnames/create.ts +++ b/packages/cli/src/commands/_generated/addressing/regional-hostnames/create.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/addressing/regional-hostnames/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { compactBody, parseBody } from "#lib/body-parser.js"; import { formatDryRun } from "#lib/dry-run.js"; @@ -15,50 +14,51 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing regional-hostnames create\n\nCreate a new Regional Hostname entry. Cloudflare will only use data centers that are physically located within the chosen region to decrypt and service HTTPS traffic. Learn more about [Regional Services](https://developers.cloudflare.com/data-localization/regional-services/get-started/)." - ) - .option("hostname", { - type: "string", - description: +const command = apiCommand({ + command: "create", + describe: "Create Regional Hostname", + usage: + "$0 addressing regional-hostnames create\n\nCreate a new Regional Hostname entry. Cloudflare will only use data centers that are physically located within the chosen region to decrypt and service HTTPS traffic. Learn more about [Regional Services](https://developers.cloudflare.com/data-localization/regional-services/get-started/).", + flags: { + hostname: { + kind: "parsed", + brief: "DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g `*.example.com`", - }) - .option("region-key", { - type: "string", - description: "Identifying key for the region", - }) - .option("routing", { - type: "string", - description: - "Configure which routing method to use for the regional hostname", + optional: true, + parse: String, + }, + "region-key": { + kind: "parsed", + brief: "Identifying key for the region", + optional: true, + parse: String, + }, + routing: { + kind: "parsed", + brief: "Configure which routing method to use for the regional hostname", default: "dns", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "create", - describe: "Create Regional Hostname", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "addressing regional-hostnames create", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -153,6 +153,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/regional-hostnames/delete.ts b/packages/cli/src/commands/_generated/addressing/regional-hostnames/delete.ts index 1eaa5175de..0754bb8ac6 100644 --- a/packages/cli/src/commands/_generated/addressing/regional-hostnames/delete.ts +++ b/packages/cli/src/commands/_generated/addressing/regional-hostnames/delete.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/addressing/regional-hostnames/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; @@ -13,36 +12,32 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing regional-hostnames delete \n\nDelete the region configuration for a specific Regional Hostname." - ) - .positional("hostname", { - type: "string", - description: - "DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g \`*.example.com\`", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete Regional Hostname", + usage: + "$0 addressing regional-hostnames delete \n\nDelete the region configuration for a specific Regional Hostname.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete Regional Hostname", - builder, + }, + }, + operands: [ + { + placeholder: "hostname", + brief: + "DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g \`*.example.com\`", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -50,7 +45,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -86,6 +81,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/regional-hostnames/edit.ts b/packages/cli/src/commands/_generated/addressing/regional-hostnames/edit.ts index 737c1c55fa..76f0f98bdf 100644 --- a/packages/cli/src/commands/_generated/addressing/regional-hostnames/edit.ts +++ b/packages/cli/src/commands/_generated/addressing/regional-hostnames/edit.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/addressing/regional-hostnames/edit.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * edit command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { compactBody, parseBody } from "#lib/body-parser.js"; import { formatDryRun } from "#lib/dry-run.js"; @@ -15,45 +14,45 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing regional-hostnames edit \n\nUpdate the configuration for a specific Regional Hostname. Only the region_key of a hostname is mutable." - ) - .positional("hostname", { - type: "string", - description: - "DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g \`*.example.com\`", - demandOption: true, - }) - .option("region-key", { - type: "string", - description: "Identifying key for the region", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "edit ", describe: "Update Regional Hostname", - builder, + usage: + "$0 addressing regional-hostnames edit \n\nUpdate the configuration for a specific Regional Hostname. Only the region_key of a hostname is mutable.", + flags: { + "region-key": { + kind: "parsed", + brief: "Identifying key for the region", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "hostname", + brief: + "DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g \`*.example.com\`", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "addressing regional-hostnames edit", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -131,6 +130,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/regional-hostnames/get.ts b/packages/cli/src/commands/_generated/addressing/regional-hostnames/get.ts index 1b71125547..0b250c981a 100644 --- a/packages/cli/src/commands/_generated/addressing/regional-hostnames/get.ts +++ b/packages/cli/src/commands/_generated/addressing/regional-hostnames/get.ts @@ -1,48 +1,43 @@ import operation from "../../_operations/addressing/regional-hostnames/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing regional-hostnames get \n\nFetch the configuration for a specific Regional Hostname, within a zone." - ) - .positional("hostname", { - type: "string", - description: - "DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g \`*.example.com\`", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Fetch Regional Hostname", - builder, + usage: + "$0 addressing regional-hostnames get \n\nFetch the configuration for a specific Regional Hostname, within a zone.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "hostname", + brief: + "DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are supported for one level, e.g \`*.example.com\`", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "addressing regional-hostnames get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -74,6 +69,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/regional-hostnames/index.ts b/packages/cli/src/commands/_generated/addressing/regional-hostnames/index.ts index 2574e769c3..a86eb0a96e 100644 --- a/packages/cli/src/commands/_generated/addressing/regional-hostnames/index.ts +++ b/packages/cli/src/commands/_generated/addressing/regional-hostnames/index.ts @@ -4,29 +4,24 @@ import $edit from "./edit.js"; import $get from "./get.js"; import $list from "./list.js"; import $regions from "./regions/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * regional-hostnames command group * @generated from apis/overlays/addressing.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "regional-hostnames", describe: "Operations for regional-hostnames", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($edit) - .command($get) - .command($list) - .command($regions) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + edit: $edit, + get: $get, + list: $list, + regions: $regions, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/regional-hostnames/list.ts b/packages/cli/src/commands/_generated/addressing/regional-hostnames/list.ts index 066ca72c3a..e3509a63d6 100644 --- a/packages/cli/src/commands/_generated/addressing/regional-hostnames/list.ts +++ b/packages/cli/src/commands/_generated/addressing/regional-hostnames/list.ts @@ -1,42 +1,36 @@ import operation from "../../_operations/addressing/regional-hostnames/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing regional-hostnames list\n\nList all Regional Hostnames within a zone." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List Regional Hostnames", - builder, + usage: + "$0 addressing regional-hostnames list\n\nList all Regional Hostnames within a zone.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "addressing regional-hostnames list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -64,6 +58,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/regional-hostnames/regions/index.ts b/packages/cli/src/commands/_generated/addressing/regional-hostnames/regions/index.ts index b4968f1944..23905475cf 100644 --- a/packages/cli/src/commands/_generated/addressing/regional-hostnames/regions/index.ts +++ b/packages/cli/src/commands/_generated/addressing/regional-hostnames/regions/index.ts @@ -1,20 +1,17 @@ import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * regions command group * @generated from apis/overlays/addressing.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "regions", describe: "Operations for regional-hostnames.regions", - builder: (yargs) => { - return yargs.command($list).demandCommand(1, "Please specify a subcommand"); + routes: { + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/regional-hostnames/regions/list.ts b/packages/cli/src/commands/_generated/addressing/regional-hostnames/regions/list.ts index 12eb02f812..677d9fcaa5 100644 --- a/packages/cli/src/commands/_generated/addressing/regional-hostnames/regions/list.ts +++ b/packages/cli/src/commands/_generated/addressing/regional-hostnames/regions/list.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/addressing/regional-hostnames/regions/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing regional-hostnames regions list\n\nList all Regional Services regions available for use by this account." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List Regions", - builder, + usage: + "$0 addressing regional-hostnames regions list\n\nList all Regional Services regions available for use by this account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "addressing regional-hostnames regions list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/services/index.ts b/packages/cli/src/commands/_generated/addressing/services/index.ts index a34df479c2..031849f62e 100644 --- a/packages/cli/src/commands/_generated/addressing/services/index.ts +++ b/packages/cli/src/commands/_generated/addressing/services/index.ts @@ -1,20 +1,17 @@ import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * services command group * @generated from apis/overlays/addressing.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "services", describe: "Operations for services", - builder: (yargs) => { - return yargs.command($list).demandCommand(1, "Please specify a subcommand"); + routes: { + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/addressing/services/list.ts b/packages/cli/src/commands/_generated/addressing/services/list.ts index 805251173c..554949e790 100644 --- a/packages/cli/src/commands/_generated/addressing/services/list.ts +++ b/packages/cli/src/commands/_generated/addressing/services/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/addressing/services/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/addressing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 addressing services list\n\nBring-Your-Own IP (BYOIP) prefixes onboarded to Cloudflare must be bound to a service running on the Cloudflare network to enable a Cloudflare product on the IP addresses. This endpoint can be used as a reference of available services on the Cloudflare network, and their service IDs." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List Services", - builder, + usage: + "$0 addressing services list\n\nBring-Your-Own IP (BYOIP) prefixes onboarded to Cloudflare must be bound to a service running on the Cloudflare network to enable a Cloudflare product on the IP addresses. This endpoint can be used as a reference of available services on the Cloudflare network, and their service IDs.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "addressing services list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/agent-memory/create-namespace.ts b/packages/cli/src/commands/_generated/agent-memory/create-namespace.ts index c5ea3ae258..177112b50c 100644 --- a/packages/cli/src/commands/_generated/agent-memory/create-namespace.ts +++ b/packages/cli/src/commands/_generated/agent-memory/create-namespace.ts @@ -1,11 +1,10 @@ import operation from "../_operations/agent-memory/create-namespace.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create-namespace command * @generated from apis/overlays/agent-memory.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,36 +19,38 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 agent-memory create-namespace\n\nCreates a new memory namespace owned by the account." - ) - .option("name", { type: "string", description: "Namespace name." }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create-namespace", describe: "Create a namespace", - builder, + usage: + "$0 agent-memory create-namespace\n\nCreates a new memory namespace owned by the account.", + flags: { + name: { + kind: "parsed", + brief: "Namespace name.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "agent-memory create-namespace", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -115,6 +116,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/agent-memory/delete-memory.ts b/packages/cli/src/commands/_generated/agent-memory/delete-memory.ts index 55b55d1c43..b40083af45 100644 --- a/packages/cli/src/commands/_generated/agent-memory/delete-memory.ts +++ b/packages/cli/src/commands/_generated/agent-memory/delete-memory.ts @@ -1,11 +1,10 @@ import operation from "../_operations/agent-memory/delete-memory.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete-memory command * @generated from apis/overlays/agent-memory.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,45 +17,33 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 agent-memory delete-memory \n\nDeletes a memory by ID. Removes the memory and any source messages linked to it. Returns the deleted memory." - ) - .positional("memory-id", { - type: "string", - description: "Memory Identifier.", - demandOption: true, - }) - .option("namespace-name", { - type: "string", - description: "Namespace name.", - demandOption: true, - }) - .option("profile-name", { - type: "string", - description: "Profile name.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete-memory ", + describe: "Delete a memory", + usage: + "$0 agent-memory delete-memory \n\nDeletes a memory by ID. Removes the memory and any source messages linked to it. Returns the deleted memory.", + flags: { + "namespace-name": { + kind: "parsed", + brief: "Namespace name.", + parse: String, + }, + "profile-name": { kind: "parsed", brief: "Profile name.", parse: String }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete-memory ", - describe: "Delete a memory", - builder, + }, + }, + operands: [ + { placeholder: "memory-id", brief: "Memory Identifier.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -64,7 +51,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -107,6 +94,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/agent-memory/delete-namespace.ts b/packages/cli/src/commands/_generated/agent-memory/delete-namespace.ts index 414cf9906e..4dc7081db8 100644 --- a/packages/cli/src/commands/_generated/agent-memory/delete-namespace.ts +++ b/packages/cli/src/commands/_generated/agent-memory/delete-namespace.ts @@ -1,11 +1,10 @@ import operation from "../_operations/agent-memory/delete-namespace.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete-namespace command * @generated from apis/overlays/agent-memory.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,35 +17,27 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 agent-memory delete-namespace \n\nDeletes a namespace." - ) - .positional("namespace-name", { - type: "string", - description: "Namespace name.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete-namespace ", + describe: "Delete a namespace", + usage: + "$0 agent-memory delete-namespace \n\nDeletes a namespace.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete-namespace ", - describe: "Delete a namespace", - builder, + }, + }, + operands: [ + { placeholder: "namespace-name", brief: "Namespace name.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -54,7 +45,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -93,6 +84,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/agent-memory/delete-profile.ts b/packages/cli/src/commands/_generated/agent-memory/delete-profile.ts index e6fc58644f..cddc26c929 100644 --- a/packages/cli/src/commands/_generated/agent-memory/delete-profile.ts +++ b/packages/cli/src/commands/_generated/agent-memory/delete-profile.ts @@ -1,11 +1,10 @@ import operation from "../_operations/agent-memory/delete-profile.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete-profile command * @generated from apis/overlays/agent-memory.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,40 +17,32 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 agent-memory delete-profile \n\nMarks a profile for deletion." - ) - .positional("profile-name", { - type: "string", - description: "Profile name.", - demandOption: true, - }) - .option("namespace-name", { - type: "string", - description: "Namespace name.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete-profile ", + describe: "Delete a profile", + usage: + "$0 agent-memory delete-profile \n\nMarks a profile for deletion.", + flags: { + "namespace-name": { + kind: "parsed", + brief: "Namespace name.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete-profile ", - describe: "Delete a profile", - builder, + }, + }, + operands: [ + { placeholder: "profile-name", brief: "Profile name.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -59,7 +50,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -100,6 +91,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/agent-memory/delete-session.ts b/packages/cli/src/commands/_generated/agent-memory/delete-session.ts index 08e7538995..13430eb14a 100644 --- a/packages/cli/src/commands/_generated/agent-memory/delete-session.ts +++ b/packages/cli/src/commands/_generated/agent-memory/delete-session.ts @@ -1,11 +1,10 @@ import operation from "../_operations/agent-memory/delete-session.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete-session command * @generated from apis/overlays/agent-memory.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,45 +17,33 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 agent-memory delete-session \n\nMarks all memories and messages in a profile that are tagged with the given session ID for deletion." - ) - .positional("session-id", { - type: "string", - description: "Session identifier.", - demandOption: true, - }) - .option("namespace-name", { - type: "string", - description: "Namespace name.", - demandOption: true, - }) - .option("profile-name", { - type: "string", - description: "Profile name.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete-session ", + describe: "Delete a session", + usage: + "$0 agent-memory delete-session \n\nMarks all memories and messages in a profile that are tagged with the given session ID for deletion.", + flags: { + "namespace-name": { + kind: "parsed", + brief: "Namespace name.", + parse: String, + }, + "profile-name": { kind: "parsed", brief: "Profile name.", parse: String }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete-session ", - describe: "Delete a session", - builder, + }, + }, + operands: [ + { placeholder: "session-id", brief: "Session identifier.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -64,7 +51,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -107,6 +94,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/agent-memory/get-memory.ts b/packages/cli/src/commands/_generated/agent-memory/get-memory.ts index cfdb475b9f..e02b84cd74 100644 --- a/packages/cli/src/commands/_generated/agent-memory/get-memory.ts +++ b/packages/cli/src/commands/_generated/agent-memory/get-memory.ts @@ -1,11 +1,10 @@ import operation from "../_operations/agent-memory/get-memory.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get-memory command * @generated from apis/overlays/agent-memory.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,46 +16,33 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 agent-memory get-memory \n\nRetrieves a memory by ID." - ) - .positional("memory-id", { - type: "string", - description: "Memory Identifier.", - demandOption: true, - }) - .option("namespace-name", { - type: "string", - description: "Namespace name.", - demandOption: true, - }) - .option("profile-name", { - type: "string", - description: "Profile name.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get-memory ", describe: "Get a memory", - builder, + usage: "$0 agent-memory get-memory \n\nRetrieves a memory by ID.", + flags: { + "namespace-name": { + kind: "parsed", + brief: "Namespace name.", + parse: String, + }, + "profile-name": { kind: "parsed", brief: "Profile name.", parse: String }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { placeholder: "memory-id", brief: "Memory Identifier.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "agent-memory get-memory", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -90,6 +76,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/agent-memory/get-namespace.ts b/packages/cli/src/commands/_generated/agent-memory/get-namespace.ts index 96d62880ea..628295217e 100644 --- a/packages/cli/src/commands/_generated/agent-memory/get-namespace.ts +++ b/packages/cli/src/commands/_generated/agent-memory/get-namespace.ts @@ -1,11 +1,10 @@ import operation from "../_operations/agent-memory/get-namespace.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get-namespace command * @generated from apis/overlays/agent-memory.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,28 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 agent-memory get-namespace \n\nGets a namespace by name." - ) - .positional("namespace-name", { - type: "string", - description: "Namespace name.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get-namespace ", describe: "Get a namespace", - builder, + usage: + "$0 agent-memory get-namespace \n\nGets a namespace by name.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { placeholder: "namespace-name", brief: "Namespace name.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "agent-memory get-namespace", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -76,6 +67,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/agent-memory/index.ts b/packages/cli/src/commands/_generated/agent-memory/index.ts index 3e11e5948d..3c3e02bba2 100644 --- a/packages/cli/src/commands/_generated/agent-memory/index.ts +++ b/packages/cli/src/commands/_generated/agent-memory/index.ts @@ -12,37 +12,32 @@ import $listprofiles from "./list-profiles.js"; import $recall from "./recall.js"; import $remember from "./remember.js"; import $summary from "./summary.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * agent-memory command * @generated from apis/overlays/agent-memory.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "agent-memory", describe: "agent-memory", - builder: (yargs) => { - return yargs - .command($createnamespace) - .command($deletememory) - .command($deletenamespace) - .command($deleteprofile) - .command($deletesession) - .command($getmemory) - .command($getnamespace) - .command($ingest) - .command($listmemories) - .command($listnamespaces) - .command($listprofiles) - .command($recall) - .command($remember) - .command($summary) - .demandCommand(1, "Please specify a subcommand"); + routes: { + "create-namespace": $createnamespace, + "delete-memory": $deletememory, + "delete-namespace": $deletenamespace, + "delete-profile": $deleteprofile, + "delete-session": $deletesession, + "get-memory": $getmemory, + "get-namespace": $getnamespace, + ingest: $ingest, + "list-memories": $listmemories, + "list-namespaces": $listnamespaces, + "list-profiles": $listprofiles, + recall: $recall, + remember: $remember, + summary: $summary, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/agent-memory/ingest.ts b/packages/cli/src/commands/_generated/agent-memory/ingest.ts index 833887eac9..588bf2581a 100644 --- a/packages/cli/src/commands/_generated/agent-memory/ingest.ts +++ b/packages/cli/src/commands/_generated/agent-memory/ingest.ts @@ -1,11 +1,10 @@ import operation from "../_operations/agent-memory/ingest.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * ingest command * @generated from apis/overlays/agent-memory.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,54 +18,52 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 agent-memory ingest \n\nProcesses a conversation and extracts structured memories from it. Agent Memory identifies facts, events, instructions, and tasks automatically." - ) - .positional("profile-name", { - type: "string", - description: "Profile name.", - demandOption: true, - }) - .option("namespace-name", { - type: "string", - description: "Namespace name.", - demandOption: true, - }) - .option("messages", { - type: "string", - description: - 'Conversation messages to extract memories from. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"content": string, "role": "system" | "user" | "assistant", "timestamp"?: string}]. ? marks optional keys.', - }) - .option("session-id", { - type: "string", - description: "Session identifier.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "ingest ", describe: "Ingest messages", - builder, + usage: + "$0 agent-memory ingest \n\nProcesses a conversation and extracts structured memories from it. Agent Memory identifies facts, events, instructions, and tasks automatically.", + flags: { + "namespace-name": { + kind: "parsed", + brief: "Namespace name.", + parse: String, + }, + messages: { + kind: "parsed", + brief: + 'Conversation messages to extract memories from. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"content": string, "role": "system" | "user" | "assistant", "timestamp"?: string}]. ? marks optional keys.', + optional: true, + parse: String, + }, + "session-id": { + kind: "parsed", + brief: "Session identifier.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { placeholder: "profile-name", brief: "Profile name.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "agent-memory ingest", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -146,6 +143,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/agent-memory/list-memories.ts b/packages/cli/src/commands/_generated/agent-memory/list-memories.ts index f35e0fa896..db1d9db3f9 100644 --- a/packages/cli/src/commands/_generated/agent-memory/list-memories.ts +++ b/packages/cli/src/commands/_generated/agent-memory/list-memories.ts @@ -1,11 +1,10 @@ import operation from "../_operations/agent-memory/list-memories.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list-memories command * @generated from apis/overlays/agent-memory.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,58 +16,57 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 agent-memory list-memories \n\nList memories stored in a profile." - ) - .positional("profile-name", { - type: "string", - description: "Profile name.", - demandOption: true, - }) - .option("namespace-name", { - type: "string", - description: "Namespace name.", - demandOption: true, - }) - .option("per-page", { - type: "number", - description: "Number of results per page.", - }) - .option("cursor", { - type: "string", - description: "Continuation cursor for paginated results.", - }) - .option("session-id", { - type: "string", - description: "Session identifier for filtering.", - }) - .option("type", { - type: "string", - description: "Memory type for filtering.", - choices: ["fact", "event", "instruction", "task"], - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list-memories ", describe: "List memories", - builder, + usage: + "$0 agent-memory list-memories \n\nList memories stored in a profile.", + flags: { + "namespace-name": { + kind: "parsed", + brief: "Namespace name.", + parse: String, + }, + "per-page": { + kind: "parsed", + brief: "Number of results per page.", + optional: true, + parse: Number, + }, + cursor: { + kind: "parsed", + brief: "Continuation cursor for paginated results.", + optional: true, + parse: String, + }, + "session-id": { + kind: "parsed", + brief: "Session identifier for filtering.", + optional: true, + parse: String, + }, + type: { + kind: "enum", + brief: "Memory type for filtering.", + values: ["fact", "event", "instruction", "task"], + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { placeholder: "profile-name", brief: "Profile name.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "agent-memory list-memories", classification: { safeFlags: ["type", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -108,6 +106,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/agent-memory/list-namespaces.ts b/packages/cli/src/commands/_generated/agent-memory/list-namespaces.ts index 0e0382ec51..c476174ee1 100644 --- a/packages/cli/src/commands/_generated/agent-memory/list-namespaces.ts +++ b/packages/cli/src/commands/_generated/agent-memory/list-namespaces.ts @@ -1,11 +1,10 @@ import operation from "../_operations/agent-memory/list-namespaces.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list-namespaces command * @generated from apis/overlays/agent-memory.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,49 +16,50 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 agent-memory list-namespaces\n\nLists all namespaces for the given account. Results are paginated." - ) - .option("per-page", { - type: "number", - description: "Number of results per page.", - }) - .option("order", { - type: "string", - description: "Field to order the results by.", - choices: ["id", "name"], - }) - .option("direction", { - type: "string", - description: "Direction to sort the results in.", - choices: ["asc", "desc"], - }) - .option("cursor", { - type: "string", - description: "Pagination cursor returned by a previous list response.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list-namespaces", describe: "List namespaces", - builder, + usage: + "$0 agent-memory list-namespaces\n\nLists all namespaces for the given account. Results are paginated.", + flags: { + "per-page": { + kind: "parsed", + brief: "Number of results per page.", + optional: true, + parse: Number, + }, + order: { + kind: "enum", + brief: "Field to order the results by.", + values: ["id", "name"], + optional: true, + }, + direction: { + kind: "enum", + brief: "Direction to sort the results in.", + values: ["asc", "desc"], + optional: true, + }, + cursor: { + kind: "parsed", + brief: "Pagination cursor returned by a previous list response.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "agent-memory list-namespaces", classification: { safeFlags: ["order", "direction", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -91,6 +91,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/agent-memory/list-profiles.ts b/packages/cli/src/commands/_generated/agent-memory/list-profiles.ts index f3e7b406bb..4f6867d5c3 100644 --- a/packages/cli/src/commands/_generated/agent-memory/list-profiles.ts +++ b/packages/cli/src/commands/_generated/agent-memory/list-profiles.ts @@ -1,11 +1,10 @@ import operation from "../_operations/agent-memory/list-profiles.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list-profiles command * @generated from apis/overlays/agent-memory.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,45 +16,40 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 agent-memory list-profiles \n\nLists the profiles of a namespace, ordered by name. A profile appears once it has been used." - ) - .positional("namespace-name", { - type: "string", - description: "Namespace name.", - demandOption: true, - }) - .option("per-page", { - type: "number", - description: "Number of results per page.", - }) - .option("cursor", { - type: "string", - description: - "Opaque continuation cursor returned by a previous list response.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list-profiles ", describe: "List profiles", - builder, + usage: + "$0 agent-memory list-profiles \n\nLists the profiles of a namespace, ordered by name. A profile appears once it has been used.", + flags: { + "per-page": { + kind: "parsed", + brief: "Number of results per page.", + optional: true, + parse: Number, + }, + cursor: { + kind: "parsed", + brief: "Opaque continuation cursor returned by a previous list response.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { placeholder: "namespace-name", brief: "Namespace name.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "agent-memory list-profiles", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -91,6 +85,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/agent-memory/recall.ts b/packages/cli/src/commands/_generated/agent-memory/recall.ts index 37e58a8d38..29ddbbbc4f 100644 --- a/packages/cli/src/commands/_generated/agent-memory/recall.ts +++ b/packages/cli/src/commands/_generated/agent-memory/recall.ts @@ -1,11 +1,10 @@ import operation from "../_operations/agent-memory/recall.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * recall command * @generated from apis/overlays/agent-memory.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,69 +19,69 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 agent-memory recall \n\nRetrieves memories relevant to the query and returns a synthesized answer." - ) - .positional("profile-name", { - type: "string", - description: "Profile name.", - demandOption: true, - }) - .option("namespace-name", { - type: "string", - description: "Namespace name.", - demandOption: true, - }) - .option("query", { - type: "string", - description: "Natural-language query to match against stored memories.", - }) - .option("reference-date", { - type: "string", - description: "Temporal anchor for relative date references in the query.", - }) - .option("response-length", { - type: "string", - description: "Verbosity of the synthesized answer. Defaults to 'medium'.", +const command = apiCommand({ + command: "recall ", + describe: "Recall memories", + usage: + "$0 agent-memory recall \n\nRetrieves memories relevant to the query and returns a synthesized answer.", + flags: { + "namespace-name": { + kind: "parsed", + brief: "Namespace name.", + parse: String, + }, + query: { + kind: "parsed", + brief: "Natural-language query to match against stored memories.", + optional: true, + parse: String, + }, + "reference-date": { + kind: "parsed", + brief: "Temporal anchor for relative date references in the query.", + optional: true, + parse: String, + }, + "response-length": { + kind: "parsed", + brief: "Verbosity of the synthesized answer. Defaults to 'medium'.", + optional: true, choices: ["short", "medium", "long"], - }) - .coerce("response-length", (value) => - resolveFileToken(value, "response-length", "text") - ) - .option("thinking-level", { - type: "string", - description: "Recall intensity / search depth. Defaults to 'low'.", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "response-length", "text"), + }, + "thinking-level": { + kind: "parsed", + brief: "Recall intensity / search depth. Defaults to 'low'.", + optional: true, choices: ["low", "medium", "high"], - }) - .coerce("thinking-level", (value) => - resolveFileToken(value, "thinking-level", "text") - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "thinking-level", "text"), + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "recall ", - describe: "Recall memories", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { placeholder: "profile-name", brief: "Profile name.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "agent-memory recall", classification: { safeFlags: ["response-length", "thinking-level", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -175,6 +174,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/agent-memory/remember.ts b/packages/cli/src/commands/_generated/agent-memory/remember.ts index 2aef57992c..917e0931c5 100644 --- a/packages/cli/src/commands/_generated/agent-memory/remember.ts +++ b/packages/cli/src/commands/_generated/agent-memory/remember.ts @@ -1,11 +1,10 @@ import operation from "../_operations/agent-memory/remember.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * remember command * @generated from apis/overlays/agent-memory.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,53 +19,51 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 agent-memory remember \n\nStores a single memory explicitly." - ) - .positional("profile-name", { - type: "string", - description: "Profile name.", - demandOption: true, - }) - .option("namespace-name", { - type: "string", - description: "Namespace name.", - demandOption: true, - }) - .option("content", { - type: "string", - description: "Raw memory content to store.", - }) - .option("session-id", { - type: "string", - description: "Session identifier.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "remember ", describe: "Remember a memory", - builder, + usage: + "$0 agent-memory remember \n\nStores a single memory explicitly.", + flags: { + "namespace-name": { + kind: "parsed", + brief: "Namespace name.", + parse: String, + }, + content: { + kind: "parsed", + brief: "Raw memory content to store.", + optional: true, + parse: String, + }, + "session-id": { + kind: "parsed", + brief: "Session identifier.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { placeholder: "profile-name", brief: "Profile name.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "agent-memory remember", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -155,6 +152,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/agent-memory/summary.ts b/packages/cli/src/commands/_generated/agent-memory/summary.ts index dfc768f37f..ab82faf0a2 100644 --- a/packages/cli/src/commands/_generated/agent-memory/summary.ts +++ b/packages/cli/src/commands/_generated/agent-memory/summary.ts @@ -1,11 +1,10 @@ import operation from "../_operations/agent-memory/summary.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * summary command * @generated from apis/overlays/agent-memory.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,49 +18,45 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 agent-memory summary \n\nGenerates a paste-ready prompt block summarizing everything stored in a memory profile." - ) - .positional("profile-name", { - type: "string", - description: "Profile name.", - demandOption: true, - }) - .option("namespace-name", { - type: "string", - description: "Namespace name.", - demandOption: true, - }) - .option("session-id", { - type: "string", - description: "Session identifier.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "summary ", describe: "Get a profile summary", - builder, + usage: + "$0 agent-memory summary \n\nGenerates a paste-ready prompt block summarizing everything stored in a memory profile.", + flags: { + "namespace-name": { + kind: "parsed", + brief: "Namespace name.", + parse: String, + }, + "session-id": { + kind: "parsed", + brief: "Session identifier.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { placeholder: "profile-name", brief: "Profile name.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "agent-memory summary", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -128,6 +123,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-audit/index.ts b/packages/cli/src/commands/_generated/ai-audit/index.ts index 1eb221eb32..dbf977b318 100644 --- a/packages/cli/src/commands/_generated/ai-audit/index.ts +++ b/packages/cli/src/commands/_generated/ai-audit/index.ts @@ -1,22 +1,17 @@ import $robots from "./robots/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * ai-audit command * @generated from apis/overlays/ai-audit.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "ai-audit", describe: "ai-audit", - builder: (yargs) => { - return yargs - .command($robots) - .demandCommand(1, "Please specify a subcommand"); + routes: { + robots: $robots, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-audit/robots/bulk-get.ts b/packages/cli/src/commands/_generated/ai-audit/robots/bulk-get.ts index 80c6079827..923a24349b 100644 --- a/packages/cli/src/commands/_generated/ai-audit/robots/bulk-get.ts +++ b/packages/cli/src/commands/_generated/ai-audit/robots/bulk-get.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-audit/robots/bulk-get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * bulk-get command * @generated from apis/overlays/ai-audit.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { parseBody } from "#lib/body-parser.js"; import { formatDryRun } from "#lib/dry-run.js"; @@ -13,36 +12,33 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-audit robots bulk-get\n\nFetches and parses robots.txt files for multiple domains within a zone in a single request. Each domain must belong to the specified zone. Results are keyed by hostname." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: - "Array of domain hostnames to fetch robots.txt for. Each domain must end with the zone name. Maximum 25 domains per request.", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "bulk-get", describe: "Bulk get robots.txt rules", - builder, + usage: + "$0 ai-audit robots bulk-get\n\nFetches and parses robots.txt files for multiple domains within a zone in a single request. Each domain must belong to the specified zone. Results are keyed by hostname.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: + "Array of domain hostnames to fetch robots.txt for. Each domain must end with the zone name. Maximum 25 domains per request.", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "ai-audit robots bulk-get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -85,6 +81,6 @@ const command: CommandModule = { } } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-audit/robots/get.ts b/packages/cli/src/commands/_generated/ai-audit/robots/get.ts index e305b0f6b3..13674aa590 100644 --- a/packages/cli/src/commands/_generated/ai-audit/robots/get.ts +++ b/packages/cli/src/commands/_generated/ai-audit/robots/get.ts @@ -1,47 +1,43 @@ import operation from "../../_operations/ai-audit/robots/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/ai-audit.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-audit robots get\n\nFetches and parses the robots.txt file for a zone or a specific subdomain within the zone. Returns parsed user-agent rules, content signals, and sitemaps." - ) - .option("subdomain", { - type: "string", - description: - "Optional subdomain to fetch robots.txt for. If omitted, fetches robots.txt for the zone apex domain.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get", describe: "Get robots.txt rules", - builder, + usage: + "$0 ai-audit robots get\n\nFetches and parses the robots.txt file for a zone or a specific subdomain within the zone. Returns parsed user-agent rules, content signals, and sitemaps.", + flags: { + subdomain: { + kind: "parsed", + brief: + "Optional subdomain to fetch robots.txt for. If omitted, fetches robots.txt for the zone apex domain.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "ai-audit robots get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -73,6 +69,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-audit/robots/index.ts b/packages/cli/src/commands/_generated/ai-audit/robots/index.ts index a3169b3eda..e60226fe98 100644 --- a/packages/cli/src/commands/_generated/ai-audit/robots/index.ts +++ b/packages/cli/src/commands/_generated/ai-audit/robots/index.ts @@ -1,24 +1,19 @@ import $bulkget from "./bulk-get.js"; import $get from "./get.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * robots command group * @generated from apis/overlays/ai-audit.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "robots", describe: "Operations for robots", - builder: (yargs) => { - return yargs - .command($bulkget) - .command($get) - .demandCommand(1, "Please specify a subcommand"); + routes: { + "bulk-get": $bulkget, + get: $get, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/custom-domains/create.ts b/packages/cli/src/commands/_generated/ai-gateway/custom-domains/create.ts index 5fc32fd7e4..e515b851a9 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/custom-domains/create.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/custom-domains/create.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-gateway/custom-domains/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,55 +19,58 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway custom-domains create \n\nProvisions a Cloudflare-for-SaaS custom hostname and returns the CNAME target to point DNS at." - ) - .positional("gateway-id", { - type: "string", - description: "Unique identifier of the AI Gateway within the account.", - demandOption: true, - }) - .option("domain", { - type: "string", - description: "Custom hostname that you own, such as `ai.example.com`.", - }) - .option("min-tls", { - type: "string", - description: "The minTLS field", - choices: ["1.0", "1.1", "1.2", "1.3"], - }) - .coerce("min-tls", (value) => resolveFileToken(value, "min-tls", "text")) - .option("zone-id", { - type: "string", - description: - "ID of the Cloudflare zone that contains the custom hostname.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create ", describe: "Create a custom domain for a gateway", - builder, + usage: + "$0 ai-gateway custom-domains create \n\nProvisions a Cloudflare-for-SaaS custom hostname and returns the CNAME target to point DNS at.", + flags: { + domain: { + kind: "parsed", + brief: "Custom hostname that you own, such as `ai.example.com`.", + optional: true, + parse: String, + }, + "min-tls": { + kind: "parsed", + brief: "The minTLS field", + optional: true, + choices: ["1.0", "1.1", "1.2", "1.3"], + parse: String, + coerce: (value: string) => resolveFileToken(value, "min-tls", "text"), + }, + "zone-id": { + kind: "parsed", + brief: "ID of the Cloudflare zone that contains the custom hostname.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "gateway-id", + brief: "Unique identifier of the AI Gateway within the account.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway custom-domains create", classification: { safeFlags: ["min-tls", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -160,6 +162,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/custom-domains/delete.ts b/packages/cli/src/commands/_generated/ai-gateway/custom-domains/delete.ts index 9a672306f1..711039552c 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/custom-domains/delete.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/custom-domains/delete.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-gateway/custom-domains/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,40 +17,36 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway custom-domains delete \n\nDeletes a custom domain from an AI Gateway and removes its Cloudflare for SaaS custom hostname." - ) - .positional("hostname", { - type: "string", - description: "Custom hostname that you own, such as \`ai.example.com\`.", - demandOption: true, - }) - .option("gateway-id", { - type: "string", - description: "Unique identifier of the AI Gateway within the account.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete a custom domain", + usage: + "$0 ai-gateway custom-domains delete \n\nDeletes a custom domain from an AI Gateway and removes its Cloudflare for SaaS custom hostname.", + flags: { + "gateway-id": { + kind: "parsed", + brief: "Unique identifier of the AI Gateway within the account.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete a custom domain", - builder, + }, + }, + operands: [ + { + placeholder: "hostname", + brief: "Custom hostname that you own, such as \`ai.example.com\`.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -59,7 +54,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -100,6 +95,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/custom-domains/get.ts b/packages/cli/src/commands/_generated/ai-gateway/custom-domains/get.ts index 847cf40ca8..075258e7dd 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/custom-domains/get.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/custom-domains/get.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-gateway/custom-domains/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,41 +16,37 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway custom-domains get \n\nRetrieves a custom domain attached to an AI Gateway, including its status and CNAME target." - ) - .positional("hostname", { - type: "string", - description: "Custom hostname that you own, such as \`ai.example.com\`.", - demandOption: true, - }) - .option("gateway-id", { - type: "string", - description: "Unique identifier of the AI Gateway within the account.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get a custom domain", - builder, + usage: + "$0 ai-gateway custom-domains get \n\nRetrieves a custom domain attached to an AI Gateway, including its status and CNAME target.", + flags: { + "gateway-id": { + kind: "parsed", + brief: "Unique identifier of the AI Gateway within the account.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "hostname", + brief: "Custom hostname that you own, such as \`ai.example.com\`.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway custom-domains get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -83,6 +78,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/custom-domains/index.ts b/packages/cli/src/commands/_generated/ai-gateway/custom-domains/index.ts index 4dc3cb4e60..13afe8d0a0 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/custom-domains/index.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/custom-domains/index.ts @@ -2,27 +2,22 @@ import $create from "./create.js"; import $delete from "./delete.js"; import $get from "./get.js"; import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * custom-domains command group * @generated from apis/overlays/ai-gateway.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "custom-domains", describe: "Manage custom hostnames that route requests through an AI Gateway", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($get) - .command($list) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + get: $get, + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/custom-domains/list.ts b/packages/cli/src/commands/_generated/ai-gateway/custom-domains/list.ts index acf026a3fa..d1809d32ac 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/custom-domains/list.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/custom-domains/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-gateway/custom-domains/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,44 +16,50 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway custom-domains list\n\nLists the custom domains attached to an AI Gateway, including the certificate and validation status of each domain." - ) - .option("gateway-id", { - type: "string", - description: "Unique identifier of the AI Gateway within the account.", - demandOption: true, - }) - .option("page", { type: "number", description: "Page" }) - .option("per-page", { type: "number", description: "Per page" }) - .option("status", { - type: "string", - description: "Status", - choices: ["initializing", "pending_dcv", "active", "blocked", "error"], - }) - .option("search", { type: "string", description: "Search by hostname" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List custom domains", - builder, + usage: + "$0 ai-gateway custom-domains list\n\nLists the custom domains attached to an AI Gateway, including the certificate and validation status of each domain.", + flags: { + "gateway-id": { + kind: "parsed", + brief: "Unique identifier of the AI Gateway within the account.", + parse: String, + }, + page: { kind: "parsed", brief: "Page", optional: true, parse: Number }, + "per-page": { + kind: "parsed", + brief: "Per page", + optional: true, + parse: Number, + }, + status: { + kind: "enum", + brief: "Status", + values: ["initializing", "pending_dcv", "active", "blocked", "error"], + optional: true, + }, + search: { + kind: "parsed", + brief: "Search by hostname", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway custom-domains list", classification: { safeFlags: ["status", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -90,6 +95,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/custom-providers/create.ts b/packages/cli/src/commands/_generated/ai-gateway/custom-providers/create.ts index 290998409a..198c05f799 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/custom-providers/create.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/custom-providers/create.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-gateway/custom-providers/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,59 +19,89 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway custom-providers create\n\nCreates an account-level custom provider that forwards AI Gateway requests to the HTTPS base URL you supply. Requests reference the provider as `custom-{slug}`, so the slug must be unique within the account." - ) - .option("base-url", { type: "string", description: "The base_url field" }) - .option("beta", { type: "boolean", description: "The beta field" }) - .option("curl-example", { - type: "string", - description: "The curl_example field", - }) - .option("description", { - type: "string", - description: "The description field", - }) - .option("enable", { type: "boolean", description: "The enable field" }) - .option("headers", { - type: "string", - description: - "JSON object of extra HTTP headers that AI Gateway sends to the provider. Values can contain credentials.", - }) - .option("js-example", { - type: "string", - description: "The js_example field", - }) - .option("link", { type: "string", description: "The link field" }) - .option("name", { type: "string", description: "The name field" }) - .option("position", { type: "number", description: "The position field" }) - .option("slug", { type: "string", description: "The slug field" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create", describe: "Create a custom provider", - builder, + usage: + "$0 ai-gateway custom-providers create\n\nCreates an account-level custom provider that forwards AI Gateway requests to the HTTPS base URL you supply. Requests reference the provider as `custom-{slug}`, so the slug must be unique within the account.", + flags: { + "base-url": { + kind: "parsed", + brief: "The base_url field", + optional: true, + parse: String, + }, + beta: { kind: "boolean", brief: "The beta field", optional: true }, + "curl-example": { + kind: "parsed", + brief: "The curl_example field", + optional: true, + parse: String, + }, + description: { + kind: "parsed", + brief: "The description field", + optional: true, + parse: String, + }, + enable: { kind: "boolean", brief: "The enable field", optional: true }, + headers: { + kind: "parsed", + brief: + "JSON object of extra HTTP headers that AI Gateway sends to the provider. Values can contain credentials.", + optional: true, + parse: String, + }, + "js-example": { + kind: "parsed", + brief: "The js_example field", + optional: true, + parse: String, + }, + link: { + kind: "parsed", + brief: "The link field", + optional: true, + parse: String, + }, + name: { + kind: "parsed", + brief: "The name field", + optional: true, + parse: String, + }, + position: { + kind: "parsed", + brief: "The position field", + optional: true, + parse: Number, + }, + slug: { + kind: "parsed", + brief: "The slug field", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway custom-providers create", classification: { safeFlags: ["beta", "enable", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -227,6 +256,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/custom-providers/delete.ts b/packages/cli/src/commands/_generated/ai-gateway/custom-providers/delete.ts index 92b3bb76a6..1278abdcbe 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/custom-providers/delete.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/custom-providers/delete.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-gateway/custom-providers/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,35 +17,25 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway custom-providers delete \n\nDeletes a custom provider and every pricing rule that belongs to it." - ) - .positional("id", { - type: "string", - description: "ID", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete a custom provider", + usage: + "$0 ai-gateway custom-providers delete \n\nDeletes a custom provider and every pricing rule that belongs to it.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete a custom provider", - builder, + }, + }, + operands: [{ placeholder: "id", brief: "ID", parse: String }], handler: async (argv): Promise => runWithTelemetry( { @@ -54,7 +43,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -88,6 +77,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/custom-providers/get.ts b/packages/cli/src/commands/_generated/ai-gateway/custom-providers/get.ts index 50b257accc..37ba00561d 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/custom-providers/get.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/custom-providers/get.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-gateway/custom-providers/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway custom-providers get \n\nRetrieves a custom provider, including its slug, base URL, and custom headers." - ) - .positional("id", { - type: "string", - description: "ID", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get a custom provider", - builder, + usage: + "$0 ai-gateway custom-providers get \n\nRetrieves a custom provider, including its slug, base URL, and custom headers.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [{ placeholder: "id", brief: "ID", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway custom-providers get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -71,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/custom-providers/index.ts b/packages/cli/src/commands/_generated/ai-gateway/custom-providers/index.ts index 1e6320b19c..b63a377eb2 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/custom-providers/index.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/custom-providers/index.ts @@ -3,29 +3,24 @@ import $delete from "./delete.js"; import $get from "./get.js"; import $list from "./list.js"; import $update from "./update.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * custom-providers command group * @generated from apis/overlays/ai-gateway.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "custom-providers", describe: "Manage account-level custom AI providers and their endpoint settings", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($get) - .command($list) - .command($update) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + get: $get, + list: $list, + update: $update, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/custom-providers/list.ts b/packages/cli/src/commands/_generated/ai-gateway/custom-providers/list.ts index e692a5da9b..74d9a6df37 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/custom-providers/list.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/custom-providers/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-gateway/custom-providers/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,39 +16,41 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway custom-providers list\n\nLists the custom providers configured for the account, ordered by position and then name." - ) - .option("page", { type: "number", description: "Page" }) - .option("per-page", { type: "number", description: "Per page" }) - .option("beta", { type: "boolean", description: "Beta" }) - .option("enable", { type: "boolean", description: "Enable" }) - .option("search", { - type: "string", - description: "Search by id, name, slug", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List custom providers", - builder, + usage: + "$0 ai-gateway custom-providers list\n\nLists the custom providers configured for the account, ordered by position and then name.", + flags: { + page: { kind: "parsed", brief: "Page", optional: true, parse: Number }, + "per-page": { + kind: "parsed", + brief: "Per page", + optional: true, + parse: Number, + }, + beta: { kind: "boolean", brief: "Beta", optional: true }, + enable: { kind: "boolean", brief: "Enable", optional: true }, + search: { + kind: "parsed", + brief: "Search by id, name, slug", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway custom-providers list", classification: { safeFlags: ["beta", "enable", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -82,6 +83,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/custom-providers/update.ts b/packages/cli/src/commands/_generated/ai-gateway/custom-providers/update.ts index 67b6c3343e..1114d59788 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/custom-providers/update.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/custom-providers/update.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-gateway/custom-providers/update.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,65 +18,95 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway custom-providers update \n\nUpdates the specified fields of a custom provider. Changes clear cached entries for the provider." - ) - .positional("id", { - type: "string", - description: "ID", - demandOption: true, - }) - .option("base-url", { type: "string", description: "The base_url field" }) - .option("beta", { type: "boolean", description: "The beta field" }) - .option("curl-example", { - type: "string", - description: "The curl_example field", - }) - .option("description", { - type: "string", - description: "The description field", - }) - .option("enable", { type: "boolean", description: "The enable field" }) - .option("headers", { - type: "string", - description: - "JSON object of extra HTTP headers that AI Gateway sends to the provider. Values can contain credentials.", - }) - .option("js-example", { - type: "string", - description: "The js_example field", - }) - .option("link", { type: "string", description: "The link field" }) - .option("logo", { type: "string", description: "The logo field" }) - .option("name", { type: "string", description: "The name field" }) - .option("position", { type: "number", description: "The position field" }) - .option("slug", { type: "string", description: "The slug field" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "update ", describe: "Update a custom provider", - builder, + usage: + "$0 ai-gateway custom-providers update \n\nUpdates the specified fields of a custom provider. Changes clear cached entries for the provider.", + flags: { + "base-url": { + kind: "parsed", + brief: "The base_url field", + optional: true, + parse: String, + }, + beta: { kind: "boolean", brief: "The beta field", optional: true }, + "curl-example": { + kind: "parsed", + brief: "The curl_example field", + optional: true, + parse: String, + }, + description: { + kind: "parsed", + brief: "The description field", + optional: true, + parse: String, + }, + enable: { kind: "boolean", brief: "The enable field", optional: true }, + headers: { + kind: "parsed", + brief: + "JSON object of extra HTTP headers that AI Gateway sends to the provider. Values can contain credentials.", + optional: true, + parse: String, + }, + "js-example": { + kind: "parsed", + brief: "The js_example field", + optional: true, + parse: String, + }, + link: { + kind: "parsed", + brief: "The link field", + optional: true, + parse: String, + }, + logo: { + kind: "parsed", + brief: "The logo field", + optional: true, + parse: String, + }, + name: { + kind: "parsed", + brief: "The name field", + optional: true, + parse: String, + }, + position: { + kind: "parsed", + brief: "The position field", + optional: true, + parse: Number, + }, + slug: { + kind: "parsed", + brief: "The slug field", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [{ placeholder: "id", brief: "ID", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway custom-providers update", classification: { safeFlags: ["beta", "enable", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -226,6 +255,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/create.ts b/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/create.ts index c67e8b667b..ad7da8ec6e 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/create.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/create.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-gateway/dynamic-routing/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,46 +19,45 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway dynamic-routing create \n\nCreates a dynamic route on an AI Gateway from the specified routing elements. Clients call the route by using `dynamic/{name}` as the model name." - ) - .positional("gateway-id", { - type: "string", - description: "Gateway ID", - demandOption: true, - }) - .option("elements", { - type: "string", - description: - 'The elements field. Provide as a JSON array of objects or @path/to/file.json. Shape: [({"id": string, "outputs": {...}, "type": "start"} | {"id": string, "outputs": {...}, "properties": {...}, "type": "conditional"} | {"id": string, "outputs": {...}, "type": "percentage"} | ...more)].', - }) - .option("name", { type: "string", description: "The name field" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create ", describe: "Create a dynamic route", - builder, + usage: + "$0 ai-gateway dynamic-routing create \n\nCreates a dynamic route on an AI Gateway from the specified routing elements. Clients call the route by using `dynamic/{name}` as the model name.", + flags: { + elements: { + kind: "parsed", + brief: + 'The elements field. Provide as a JSON array of objects or @path/to/file.json. Shape: [({"id": string, "outputs": {...}, "type": "start"} | {"id": string, "outputs": {...}, "properties": {...}, "type": "conditional"} | {"id": string, "outputs": {...}, "type": "percentage"} | ...more)].', + optional: true, + parse: String, + }, + name: { + kind: "parsed", + brief: "The name field", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [{ placeholder: "gateway-id", brief: "Gateway ID", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway dynamic-routing create", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -140,6 +138,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/delete.ts b/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/delete.ts index eacae83eeb..f96c81550b 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/delete.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/delete.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-gateway/dynamic-routing/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,40 +17,26 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway dynamic-routing delete \n\nDeletes a dynamic route from an AI Gateway." - ) - .positional("id", { - type: "string", - description: "ID", - demandOption: true, - }) - .option("gateway-id", { - type: "string", - description: "Gateway ID", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete a dynamic route", + usage: + "$0 ai-gateway dynamic-routing delete \n\nDeletes a dynamic route from an AI Gateway.", + flags: { + "gateway-id": { kind: "parsed", brief: "Gateway ID", parse: String }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete a dynamic route", - builder, + }, + }, + operands: [{ placeholder: "id", brief: "ID", parse: String }], handler: async (argv): Promise => runWithTelemetry( { @@ -59,7 +44,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -95,6 +80,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/deployments/create.ts b/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/deployments/create.ts index d8201b1d71..d89fad8006 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/deployments/create.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/deployments/create.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/ai-gateway/dynamic-routing/deployments/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,49 +19,39 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway dynamic-routing deployments create \n\nDeploys the specified version of a dynamic route so that it serves traffic. Deploy an earlier version to roll back." - ) - .positional("id", { - type: "string", - description: "ID", - demandOption: true, - }) - .option("gateway-id", { - type: "string", - description: "Gateway ID", - demandOption: true, - }) - .option("version-id", { - type: "string", - description: "The version_id field", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create ", describe: "Deploy a dynamic route version", - builder, + usage: + "$0 ai-gateway dynamic-routing deployments create \n\nDeploys the specified version of a dynamic route so that it serves traffic. Deploy an earlier version to roll back.", + flags: { + "gateway-id": { kind: "parsed", brief: "Gateway ID", parse: String }, + "version-id": { + kind: "parsed", + brief: "The version_id field", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [{ placeholder: "id", brief: "ID", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway dynamic-routing deployments create", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -141,6 +130,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/deployments/index.ts b/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/deployments/index.ts index 2eb8b23ff4..4cd9ac95b9 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/deployments/index.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/deployments/index.ts @@ -1,24 +1,19 @@ import $create from "./create.js"; import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * deployments command group * @generated from apis/overlays/ai-gateway.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "deployments", describe: "Deploy dynamic route versions and view deployment history", - builder: (yargs) => { - return yargs - .command($create) - .command($list) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/deployments/list.ts b/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/deployments/list.ts index 6153ac6b26..beae2f5a4e 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/deployments/list.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/deployments/list.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/ai-gateway/dynamic-routing/deployments/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,42 +16,40 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway dynamic-routing deployments list\n\nLists the deployment history of a dynamic route." - ) - .option("gateway-id", { - type: "string", - description: "Gateway ID", - demandOption: true, - }) - .option("id", { type: "string", description: "ID", demandOption: true }) - .option("page", { type: "number", description: "Page number" }) - .option("per-page", { - type: "number", - description: "Number of deployments per page", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List dynamic route deployments", - builder, + usage: + "$0 ai-gateway dynamic-routing deployments list\n\nLists the deployment history of a dynamic route.", + flags: { + "gateway-id": { kind: "parsed", brief: "Gateway ID", parse: String }, + id: { kind: "parsed", brief: "ID", parse: String }, + page: { + kind: "parsed", + brief: "Page number", + optional: true, + parse: Number, + }, + "per-page": { + kind: "parsed", + brief: "Number of deployments per page", + optional: true, + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway dynamic-routing deployments list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -90,6 +87,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/get.ts b/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/get.ts index a3584ad8a2..0f56015bc6 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/get.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/get.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-gateway/dynamic-routing/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,41 +16,27 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway dynamic-routing get \n\nRetrieves a dynamic route with its routing elements, active version, and current deployment." - ) - .positional("id", { - type: "string", - description: "ID", - demandOption: true, - }) - .option("gateway-id", { - type: "string", - description: "Gateway ID", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get a dynamic route", - builder, + usage: + "$0 ai-gateway dynamic-routing get \n\nRetrieves a dynamic route with its routing elements, active version, and current deployment.", + flags: { + "gateway-id": { kind: "parsed", brief: "Gateway ID", parse: String }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [{ placeholder: "id", brief: "ID", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway dynamic-routing get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -83,6 +68,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/index.ts b/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/index.ts index 323da423da..d3649525ad 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/index.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/index.ts @@ -5,31 +5,26 @@ import $get from "./get.js"; import $list from "./list.js"; import $update from "./update.js"; import $versions from "./versions/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * dynamic-routing command group * @generated from apis/overlays/ai-gateway.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "dynamic-routing", describe: "Route requests across multiple AI providers with fallback, load-balancing, and versioned deployments", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($get) - .command($list) - .command($update) - .command($deployments) - .command($versions) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + get: $get, + list: $list, + update: $update, + deployments: $deployments, + versions: $versions, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/list.ts b/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/list.ts index bc209bfc51..84fa43810c 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/list.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-gateway/dynamic-routing/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,41 +16,39 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway dynamic-routing list\n\nLists the dynamic routes configured on an AI Gateway." - ) - .option("gateway-id", { - type: "string", - description: "Gateway ID", - demandOption: true, - }) - .option("page", { type: "number", description: "Page number" }) - .option("per-page", { - type: "number", - description: "Number of routes per page", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List dynamic routes", - builder, + usage: + "$0 ai-gateway dynamic-routing list\n\nLists the dynamic routes configured on an AI Gateway.", + flags: { + "gateway-id": { kind: "parsed", brief: "Gateway ID", parse: String }, + page: { + kind: "parsed", + brief: "Page number", + optional: true, + parse: Number, + }, + "per-page": { + kind: "parsed", + brief: "Number of routes per page", + optional: true, + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway dynamic-routing list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -85,6 +82,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/update.ts b/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/update.ts index a16b592f3d..5bfb93e335 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/update.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/update.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-gateway/dynamic-routing/update.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,46 +19,39 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway dynamic-routing update \n\nUpdates the name of a dynamic route. To change routing behaviour, create and deploy a new version." - ) - .positional("id", { - type: "string", - description: "ID", - demandOption: true, - }) - .option("gateway-id", { - type: "string", - description: "Gateway ID", - demandOption: true, - }) - .option("name", { type: "string", description: "The name field" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "update ", describe: "Rename a dynamic route", - builder, + usage: + "$0 ai-gateway dynamic-routing update \n\nUpdates the name of a dynamic route. To change routing behaviour, create and deploy a new version.", + flags: { + "gateway-id": { kind: "parsed", brief: "Gateway ID", parse: String }, + name: { + kind: "parsed", + brief: "The name field", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [{ placeholder: "id", brief: "ID", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway dynamic-routing update", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -138,6 +130,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/versions/create.ts b/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/versions/create.ts index c05db32fe1..85a453838b 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/versions/create.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/versions/create.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/ai-gateway/dynamic-routing/versions/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,50 +17,40 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway dynamic-routing versions create \n\nCreates a new version of a dynamic route from the specified routing elements. The version does not serve traffic until you deploy it." - ) - .positional("id", { - type: "string", - description: "ID", - demandOption: true, - }) - .option("gateway-id", { - type: "string", - description: "Gateway ID", - demandOption: true, - }) - .option("elements", { - type: "string", - description: - 'The elements field. Provide as a JSON array of objects or @path/to/file.json. Shape: [({"id": string, "outputs": {...}, "type": "start"} | {"id": string, "outputs": {...}, "properties": {...}, "type": "conditional"} | {"id": string, "outputs": {...}, "type": "percentage"} | ...more)].', - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create ", describe: "Create a dynamic route version", - builder, + usage: + "$0 ai-gateway dynamic-routing versions create \n\nCreates a new version of a dynamic route from the specified routing elements. The version does not serve traffic until you deploy it.", + flags: { + "gateway-id": { kind: "parsed", brief: "Gateway ID", parse: String }, + elements: { + kind: "parsed", + brief: + 'The elements field. Provide as a JSON array of objects or @path/to/file.json. Shape: [({"id": string, "outputs": {...}, "type": "start"} | {"id": string, "outputs": {...}, "properties": {...}, "type": "conditional"} | {"id": string, "outputs": {...}, "type": "percentage"} | ...more)].', + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [{ placeholder: "id", brief: "ID", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway dynamic-routing versions create", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -131,6 +120,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/versions/get.ts b/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/versions/get.ts index c93ee407c6..d584f93107 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/versions/get.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/versions/get.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/ai-gateway/dynamic-routing/versions/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,42 +16,28 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway dynamic-routing versions get \n\nRetrieves a saved version of a dynamic route, including its routing elements." - ) - .positional("version-id", { - type: "string", - description: "Version ID", - demandOption: true, - }) - .option("gateway-id", { - type: "string", - description: "Gateway ID", - demandOption: true, - }) - .option("id", { type: "string", description: "ID", demandOption: true }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get a dynamic route version", - builder, + usage: + "$0 ai-gateway dynamic-routing versions get \n\nRetrieves a saved version of a dynamic route, including its routing elements.", + flags: { + "gateway-id": { kind: "parsed", brief: "Gateway ID", parse: String }, + id: { kind: "parsed", brief: "ID", parse: String }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [{ placeholder: "version-id", brief: "Version ID", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway dynamic-routing versions get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -86,6 +71,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/versions/index.ts b/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/versions/index.ts index 9d657751b9..c86f9ae704 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/versions/index.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/versions/index.ts @@ -1,26 +1,21 @@ import $create from "./create.js"; import $get from "./get.js"; import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * versions command group * @generated from apis/overlays/ai-gateway.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "versions", describe: "Create and inspect saved versions of a dynamic route", - builder: (yargs) => { - return yargs - .command($create) - .command($get) - .command($list) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + get: $get, + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/versions/list.ts b/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/versions/list.ts index 382591cce2..ae9b915d2d 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/versions/list.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/dynamic-routing/versions/list.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/ai-gateway/dynamic-routing/versions/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,42 +16,40 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway dynamic-routing versions list\n\nLists the saved versions of a dynamic route." - ) - .option("gateway-id", { - type: "string", - description: "Gateway ID", - demandOption: true, - }) - .option("id", { type: "string", description: "ID", demandOption: true }) - .option("page", { type: "number", description: "Page number" }) - .option("per-page", { - type: "number", - description: "Number of versions per page", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List dynamic route versions", - builder, + usage: + "$0 ai-gateway dynamic-routing versions list\n\nLists the saved versions of a dynamic route.", + flags: { + "gateway-id": { kind: "parsed", brief: "Gateway ID", parse: String }, + id: { kind: "parsed", brief: "ID", parse: String }, + page: { + kind: "parsed", + brief: "Page number", + optional: true, + parse: Number, + }, + "per-page": { + kind: "parsed", + brief: "Number of versions per page", + optional: true, + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway dynamic-routing versions list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -90,6 +87,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/gateways/create.ts b/packages/cli/src/commands/_generated/ai-gateway/gateways/create.ts index 184faa8533..82a9db7cc1 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/gateways/create.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/gateways/create.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-gateway/gateways/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,381 +19,456 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway gateways create\n\nCreates an AI Gateway in the account with the specified caching, rate limiting, logging, and authentication settings. The gateway ID appears in request URLs and must be unique within the account." - ) - .option("authentication", { - type: "boolean", - description: +const command = apiCommand({ + command: "create", + describe: "Create a gateway", + usage: + "$0 ai-gateway gateways create\n\nCreates an AI Gateway in the account with the specified caching, rate limiting, logging, and authentication settings. The gateway ID appears in request URLs and must be unique within the account.", + flags: { + authentication: { + kind: "boolean", + brief: "Require authentication for gateway access. New gateways must have authentication enabled. Once enabled, authentication cannot be disabled.", - }) - .option("byok-only", { - type: "boolean", - description: + optional: true, + }, + "byok-only": { + kind: "boolean", + brief: "Requires customer-provided provider credentials and prevents fallback to Unified Billing.", - }) - .option("cache-invalidate-on-update", { - type: "boolean", - description: "The cache_invalidate_on_update field", - }) - .option("cache-ttl", { type: "number", description: "The cache_ttl field" }) - .option("collect-logs", { - type: "boolean", - description: "The collect_logs field", - }) - .option("guardrails-prompt-p1", { - type: "string", - description: "The guardrails.prompt.P1 field", + optional: true, + }, + "cache-invalidate-on-update": { + kind: "boolean", + brief: "The cache_invalidate_on_update field", + optional: true, + }, + "cache-ttl": { + kind: "parsed", + brief: "The cache_ttl field", + optional: true, + parse: Number, + }, + "collect-logs": { + kind: "boolean", + brief: "The collect_logs field", + optional: true, + }, + "guardrails-prompt-p1": { + kind: "parsed", + brief: "The guardrails.prompt.P1 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-prompt-p1", (value) => - resolveFileToken(value, "guardrails-prompt-p1", "text") - ) - .option("guardrails-prompt-s1", { - type: "string", - description: "The guardrails.prompt.S1 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-prompt-p1", "text"), + }, + "guardrails-prompt-s1": { + kind: "parsed", + brief: "The guardrails.prompt.S1 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-prompt-s1", (value) => - resolveFileToken(value, "guardrails-prompt-s1", "text") - ) - .option("guardrails-prompt-s10", { - type: "string", - description: "The guardrails.prompt.S10 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-prompt-s1", "text"), + }, + "guardrails-prompt-s10": { + kind: "parsed", + brief: "The guardrails.prompt.S10 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-prompt-s10", (value) => - resolveFileToken(value, "guardrails-prompt-s10", "text") - ) - .option("guardrails-prompt-s11", { - type: "string", - description: "The guardrails.prompt.S11 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-prompt-s10", "text"), + }, + "guardrails-prompt-s11": { + kind: "parsed", + brief: "The guardrails.prompt.S11 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-prompt-s11", (value) => - resolveFileToken(value, "guardrails-prompt-s11", "text") - ) - .option("guardrails-prompt-s12", { - type: "string", - description: "The guardrails.prompt.S12 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-prompt-s11", "text"), + }, + "guardrails-prompt-s12": { + kind: "parsed", + brief: "The guardrails.prompt.S12 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-prompt-s12", (value) => - resolveFileToken(value, "guardrails-prompt-s12", "text") - ) - .option("guardrails-prompt-s13", { - type: "string", - description: "The guardrails.prompt.S13 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-prompt-s12", "text"), + }, + "guardrails-prompt-s13": { + kind: "parsed", + brief: "The guardrails.prompt.S13 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-prompt-s13", (value) => - resolveFileToken(value, "guardrails-prompt-s13", "text") - ) - .option("guardrails-prompt-s14", { - type: "string", - description: "The guardrails.prompt.S14 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-prompt-s13", "text"), + }, + "guardrails-prompt-s14": { + kind: "parsed", + brief: "The guardrails.prompt.S14 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-prompt-s14", (value) => - resolveFileToken(value, "guardrails-prompt-s14", "text") - ) - .option("guardrails-prompt-s2", { - type: "string", - description: "The guardrails.prompt.S2 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-prompt-s14", "text"), + }, + "guardrails-prompt-s2": { + kind: "parsed", + brief: "The guardrails.prompt.S2 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-prompt-s2", (value) => - resolveFileToken(value, "guardrails-prompt-s2", "text") - ) - .option("guardrails-prompt-s3", { - type: "string", - description: "The guardrails.prompt.S3 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-prompt-s2", "text"), + }, + "guardrails-prompt-s3": { + kind: "parsed", + brief: "The guardrails.prompt.S3 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-prompt-s3", (value) => - resolveFileToken(value, "guardrails-prompt-s3", "text") - ) - .option("guardrails-prompt-s4", { - type: "string", - description: "The guardrails.prompt.S4 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-prompt-s3", "text"), + }, + "guardrails-prompt-s4": { + kind: "parsed", + brief: "The guardrails.prompt.S4 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-prompt-s4", (value) => - resolveFileToken(value, "guardrails-prompt-s4", "text") - ) - .option("guardrails-prompt-s5", { - type: "string", - description: "The guardrails.prompt.S5 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-prompt-s4", "text"), + }, + "guardrails-prompt-s5": { + kind: "parsed", + brief: "The guardrails.prompt.S5 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-prompt-s5", (value) => - resolveFileToken(value, "guardrails-prompt-s5", "text") - ) - .option("guardrails-prompt-s6", { - type: "string", - description: "The guardrails.prompt.S6 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-prompt-s5", "text"), + }, + "guardrails-prompt-s6": { + kind: "parsed", + brief: "The guardrails.prompt.S6 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-prompt-s6", (value) => - resolveFileToken(value, "guardrails-prompt-s6", "text") - ) - .option("guardrails-prompt-s7", { - type: "string", - description: "The guardrails.prompt.S7 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-prompt-s6", "text"), + }, + "guardrails-prompt-s7": { + kind: "parsed", + brief: "The guardrails.prompt.S7 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-prompt-s7", (value) => - resolveFileToken(value, "guardrails-prompt-s7", "text") - ) - .option("guardrails-prompt-s8", { - type: "string", - description: "The guardrails.prompt.S8 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-prompt-s7", "text"), + }, + "guardrails-prompt-s8": { + kind: "parsed", + brief: "The guardrails.prompt.S8 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-prompt-s8", (value) => - resolveFileToken(value, "guardrails-prompt-s8", "text") - ) - .option("guardrails-prompt-s9", { - type: "string", - description: "The guardrails.prompt.S9 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-prompt-s8", "text"), + }, + "guardrails-prompt-s9": { + kind: "parsed", + brief: "The guardrails.prompt.S9 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-prompt-s9", (value) => - resolveFileToken(value, "guardrails-prompt-s9", "text") - ) - .option("guardrails-response-p1", { - type: "string", - description: "The guardrails.response.P1 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-prompt-s9", "text"), + }, + "guardrails-response-p1": { + kind: "parsed", + brief: "The guardrails.response.P1 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-response-p1", (value) => - resolveFileToken(value, "guardrails-response-p1", "text") - ) - .option("guardrails-response-s1", { - type: "string", - description: "The guardrails.response.S1 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-response-p1", "text"), + }, + "guardrails-response-s1": { + kind: "parsed", + brief: "The guardrails.response.S1 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-response-s1", (value) => - resolveFileToken(value, "guardrails-response-s1", "text") - ) - .option("guardrails-response-s10", { - type: "string", - description: "The guardrails.response.S10 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-response-s1", "text"), + }, + "guardrails-response-s10": { + kind: "parsed", + brief: "The guardrails.response.S10 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-response-s10", (value) => - resolveFileToken(value, "guardrails-response-s10", "text") - ) - .option("guardrails-response-s11", { - type: "string", - description: "The guardrails.response.S11 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-response-s10", "text"), + }, + "guardrails-response-s11": { + kind: "parsed", + brief: "The guardrails.response.S11 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-response-s11", (value) => - resolveFileToken(value, "guardrails-response-s11", "text") - ) - .option("guardrails-response-s12", { - type: "string", - description: "The guardrails.response.S12 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-response-s11", "text"), + }, + "guardrails-response-s12": { + kind: "parsed", + brief: "The guardrails.response.S12 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-response-s12", (value) => - resolveFileToken(value, "guardrails-response-s12", "text") - ) - .option("guardrails-response-s13", { - type: "string", - description: "The guardrails.response.S13 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-response-s12", "text"), + }, + "guardrails-response-s13": { + kind: "parsed", + brief: "The guardrails.response.S13 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-response-s13", (value) => - resolveFileToken(value, "guardrails-response-s13", "text") - ) - .option("guardrails-response-s14", { - type: "string", - description: "The guardrails.response.S14 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-response-s13", "text"), + }, + "guardrails-response-s14": { + kind: "parsed", + brief: "The guardrails.response.S14 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-response-s14", (value) => - resolveFileToken(value, "guardrails-response-s14", "text") - ) - .option("guardrails-response-s2", { - type: "string", - description: "The guardrails.response.S2 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-response-s14", "text"), + }, + "guardrails-response-s2": { + kind: "parsed", + brief: "The guardrails.response.S2 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-response-s2", (value) => - resolveFileToken(value, "guardrails-response-s2", "text") - ) - .option("guardrails-response-s3", { - type: "string", - description: "The guardrails.response.S3 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-response-s2", "text"), + }, + "guardrails-response-s3": { + kind: "parsed", + brief: "The guardrails.response.S3 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-response-s3", (value) => - resolveFileToken(value, "guardrails-response-s3", "text") - ) - .option("guardrails-response-s4", { - type: "string", - description: "The guardrails.response.S4 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-response-s3", "text"), + }, + "guardrails-response-s4": { + kind: "parsed", + brief: "The guardrails.response.S4 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-response-s4", (value) => - resolveFileToken(value, "guardrails-response-s4", "text") - ) - .option("guardrails-response-s5", { - type: "string", - description: "The guardrails.response.S5 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-response-s4", "text"), + }, + "guardrails-response-s5": { + kind: "parsed", + brief: "The guardrails.response.S5 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-response-s5", (value) => - resolveFileToken(value, "guardrails-response-s5", "text") - ) - .option("guardrails-response-s6", { - type: "string", - description: "The guardrails.response.S6 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-response-s5", "text"), + }, + "guardrails-response-s6": { + kind: "parsed", + brief: "The guardrails.response.S6 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-response-s6", (value) => - resolveFileToken(value, "guardrails-response-s6", "text") - ) - .option("guardrails-response-s7", { - type: "string", - description: "The guardrails.response.S7 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-response-s6", "text"), + }, + "guardrails-response-s7": { + kind: "parsed", + brief: "The guardrails.response.S7 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-response-s7", (value) => - resolveFileToken(value, "guardrails-response-s7", "text") - ) - .option("guardrails-response-s8", { - type: "string", - description: "The guardrails.response.S8 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-response-s7", "text"), + }, + "guardrails-response-s8": { + kind: "parsed", + brief: "The guardrails.response.S8 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-response-s8", (value) => - resolveFileToken(value, "guardrails-response-s8", "text") - ) - .option("guardrails-response-s9", { - type: "string", - description: "The guardrails.response.S9 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-response-s8", "text"), + }, + "guardrails-response-s9": { + kind: "parsed", + brief: "The guardrails.response.S9 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-response-s9", (value) => - resolveFileToken(value, "guardrails-response-s9", "text") - ) - .option("id", { - type: "string", - description: "Unique identifier of the AI Gateway within the account.", - }) - .option("log-classification", { - type: "boolean", - description: "The log_classification field", - }) - .option("log-management", { - type: "number", - description: "The log_management field", - }) - .option("log-management-strategy", { - type: "string", - description: "The log_management_strategy field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-response-s9", "text"), + }, + id: { + kind: "parsed", + brief: "Unique identifier of the AI Gateway within the account.", + optional: true, + parse: String, + }, + "log-classification": { + kind: "boolean", + brief: "The log_classification field", + optional: true, + }, + "log-management": { + kind: "parsed", + brief: "The log_management field", + optional: true, + parse: Number, + }, + "log-management-strategy": { + kind: "parsed", + brief: "The log_management_strategy field", + optional: true, choices: ["STOP_INSERTING", "DELETE_OLDEST"], - }) - .coerce("log-management-strategy", (value) => - resolveFileToken(value, "log-management-strategy", "text") - ) - .option("logpush", { type: "boolean", description: "The logpush field" }) - .option("logpush-public-key", { - type: "string", - description: "The logpush_public_key field", - }) - .option("multiprovider-enabled", { - type: "boolean", - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "log-management-strategy", "text"), + }, + logpush: { kind: "boolean", brief: "The logpush field", optional: true }, + "logpush-public-key": { + kind: "parsed", + brief: "The logpush_public_key field", + optional: true, + parse: String, + }, + "multiprovider-enabled": { + kind: "boolean", + brief: "Lets requests to a model use every provider that serves it. When off, a model uses only the providers it launched with, so a provider added later receives none of its traffic. A request that names providers (the cf-aig-allowed-providers header or routing.allowedProviders) can still use any of them. Model aliases (custom/) are not restricted.", - }) - .option("otel", { - type: "string", - description: + optional: true, + }, + otel: { + kind: "parsed", + brief: 'The otel field. Provide as a JSON array of objects, null, or @path/to/file.json. Shape: [{"headers": {...}, "url": string, "authorization"?: string, "content_type"?: "json" | "protobuf"}]. ? marks optional keys.', - }) - .option("rate-limiting-interval", { - type: "number", - description: "The rate_limiting_interval field", - }) - .option("rate-limiting-limit", { - type: "number", - description: "The rate_limiting_limit field", - }) - .option("rate-limiting-technique", { - type: "string", - description: "The rate_limiting_technique field", + optional: true, + parse: String, + }, + "rate-limiting-interval": { + kind: "parsed", + brief: "The rate_limiting_interval field", + optional: true, + parse: Number, + }, + "rate-limiting-limit": { + kind: "parsed", + brief: "The rate_limiting_limit field", + optional: true, + parse: Number, + }, + "rate-limiting-technique": { + kind: "parsed", + brief: "The rate_limiting_technique field", + optional: true, choices: ["fixed", "sliding"], - }) - .coerce("rate-limiting-technique", (value) => - resolveFileToken(value, "rate-limiting-technique", "text") - ) - .option("retry-backoff", { - type: "string", - description: "Backoff strategy for retry delays", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "rate-limiting-technique", "text"), + }, + "retry-backoff": { + kind: "parsed", + brief: "Backoff strategy for retry delays", + optional: true, choices: ["constant", "linear", "exponential"], - }) - .coerce("retry-backoff", (value) => - resolveFileToken(value, "retry-backoff", "text") - ) - .option("retry-delay", { - type: "number", - description: "Delay between retry attempts in milliseconds (0-60000)", - }) - .option("retry-max-attempts", { - type: "number", - description: "Maximum number of retry attempts for failed requests (1-5)", - }) - .option("spend-limits-enabled", { - type: "boolean", - description: "The spend_limits.enabled field", - }) - .option("spend-limits-rules", { - type: "string", - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "retry-backoff", "text"), + }, + "retry-delay": { + kind: "parsed", + brief: "Delay between retry attempts in milliseconds (0-60000)", + optional: true, + parse: Number, + }, + "retry-max-attempts": { + kind: "parsed", + brief: "Maximum number of retry attempts for failed requests (1-5)", + optional: true, + parse: Number, + }, + "spend-limits-enabled": { + kind: "boolean", + brief: "The spend_limits.enabled field", + optional: true, + }, + "spend-limits-rules": { + kind: "parsed", + brief: 'The spend_limits.rules field. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"limit": number, "limitType": "cost", "window": number, "enabled"?: boolean, "id"?: string, ...more}]. ? marks optional keys.', - }) - .option("store-id", { - type: "string", - description: + optional: true, + parse: String, + }, + "store-id": { + kind: "parsed", + brief: "Secrets Store used by this gateway. Omit on update to keep the current store. Cannot be cleared while stored keys or secret references depend on it.", - }) - .option("stripe-authorization", { - type: "string", - description: "The stripe.authorization field", - }) - .option("stripe-usage-events", { - type: "string", - description: + optional: true, + parse: String, + }, + "stripe-authorization": { + kind: "parsed", + brief: "The stripe.authorization field", + optional: true, + parse: String, + }, + "stripe-usage-events": { + kind: "parsed", + brief: 'The stripe.usage_events field. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"payload": string}].', - }) - .option("workers-ai-billing-mode", { - type: "string", - description: + optional: true, + parse: String, + }, + "workers-ai-billing-mode": { + kind: "parsed", + brief: "Controls how Workers AI inference calls routed through this gateway are billed. 'postpaid' bills the account directly through Workers AI; 'unified' deducts credits via AI Gateway using neuron-based pricing and delegates billing to AI Gateway.", - choices: ["postpaid", "unified"], default: "postpaid", - }) - .coerce("workers-ai-billing-mode", (value) => - resolveFileToken(value, "workers-ai-billing-mode", "text") - ) - .option("zdr", { type: "boolean", description: "The zdr field" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + choices: ["postpaid", "unified"], + parse: String, + coerce: (value: string) => + resolveFileToken(value, "workers-ai-billing-mode", "text"), + }, + zdr: { kind: "boolean", brief: "The zdr field", optional: true }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }) - .check((argv) => { + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], + rules(rules) { + rules.check((argv) => { const groupSet = ["stripe-authorization", "stripe-usage-events"].some( (k) => argv[k] !== undefined ); @@ -410,14 +484,7 @@ function builder(yargs: Argv) { } return true; }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "create", - describe: "Create a gateway", - builder, + }, handler: async (argv): Promise => runWithTelemetry( { @@ -469,7 +536,7 @@ const command: CommandModule = { "zdr", "dry-run", ], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -723,6 +790,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/gateways/delete.ts b/packages/cli/src/commands/_generated/ai-gateway/gateways/delete.ts index dce68fae09..f2a92df928 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/gateways/delete.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/gateways/delete.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,35 +17,31 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway gateways delete \n\nPermanently deletes an AI Gateway, its configuration, and its stored logs." - ) - .positional("gateway-id", { - type: "string", - description: "Unique identifier of the AI Gateway within the account.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete a gateway", + usage: + "$0 ai-gateway gateways delete \n\nPermanently deletes an AI Gateway, its configuration, and its stored logs.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete a gateway", - builder, + }, + }, + operands: [ + { + placeholder: "gateway-id", + brief: "Unique identifier of the AI Gateway within the account.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -54,7 +49,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -92,6 +87,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/gateways/get-url.ts b/packages/cli/src/commands/_generated/ai-gateway/gateways/get-url.ts index f9b173bcbf..879c2b3cd2 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/gateways/get-url.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/gateways/get-url.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get-url command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,41 +16,33 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway gateways get-url \n\nRetrieves the endpoint URL for an AI Gateway." - ) - .positional("ai-gateway-provider", { - type: "string", - description: "Provider", - demandOption: true, - }) - .option("gateway-id", { - type: "string", - description: "Unique identifier of the AI Gateway within the account.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get-url ", describe: "Get Gateway URL", - builder, + usage: + "$0 ai-gateway gateways get-url \n\nRetrieves the endpoint URL for an AI Gateway.", + flags: { + "gateway-id": { + kind: "parsed", + brief: "Unique identifier of the AI Gateway within the account.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { placeholder: "ai-gateway-provider", brief: "Provider", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway gateways get-url", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -83,6 +74,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/gateways/get.ts b/packages/cli/src/commands/_generated/ai-gateway/gateways/get.ts index 8c8bcfcc1c..89c47bdfef 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/gateways/get.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/gateways/get.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,32 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway gateways get \n\nRetrieves the configuration of an AI Gateway." - ) - .positional("gateway-id", { - type: "string", - description: "Unique identifier of the AI Gateway within the account.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get a gateway", - builder, + usage: + "$0 ai-gateway gateways get \n\nRetrieves the configuration of an AI Gateway.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "gateway-id", + brief: "Unique identifier of the AI Gateway within the account.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway gateways get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -75,6 +70,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/gateways/index.ts b/packages/cli/src/commands/_generated/ai-gateway/gateways/index.ts index cdb4c0e799..97a994dd58 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/gateways/index.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/gateways/index.ts @@ -5,30 +5,25 @@ import $get from "./get.js"; import $list from "./list.js"; import $providers from "./providers/index.js"; import $update from "./update.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * gateways command group * @generated from apis/overlays/ai-gateway.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "gateways", describe: "Create and configure AI Gateways for an account", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($get) - .command($geturl) - .command($list) - .command($update) - .command($providers) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + get: $get, + "get-url": $geturl, + list: $list, + update: $update, + providers: $providers, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/gateways/list.ts b/packages/cli/src/commands/_generated/ai-gateway/gateways/list.ts index 2f6f976308..8863194bd6 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/gateways/list.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/gateways/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-gateway/gateways/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,34 +16,39 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway gateways list\n\nLists the AI Gateways in the account. Use `search` to filter by gateway ID." - ) - .option("page", { type: "number", description: "Page" }) - .option("per-page", { type: "number", description: "Per page" }) - .option("search", { type: "string", description: "Search by id" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List gateways", - builder, + usage: + "$0 ai-gateway gateways list\n\nLists the AI Gateways in the account. Use `search` to filter by gateway ID.", + flags: { + page: { kind: "parsed", brief: "Page", optional: true, parse: Number }, + "per-page": { + kind: "parsed", + brief: "Per page", + optional: true, + parse: Number, + }, + search: { + kind: "parsed", + brief: "Search by id", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway gateways list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -75,6 +79,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/gateways/providers/create.ts b/packages/cli/src/commands/_generated/ai-gateway/gateways/providers/create.ts index efb85e3ae4..c202e15253 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/gateways/providers/create.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/gateways/providers/create.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/ai-gateway/gateways/providers/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,64 +19,80 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway gateways providers create \n\nStores an upstream AI provider API key for an AI Gateway in the Secrets Store configured on the gateway, with an optional rate limit. Pass `secret` to store a new key, or omit it to use an existing Secrets Store secret." - ) - .positional("gateway-id", { - type: "string", - description: "Unique identifier of the AI Gateway within the account.", - demandOption: true, - }) - .option("alias", { type: "string", description: "The alias field" }) - .option("default-config", { - type: "boolean", - description: "The default_config field", - }) - .option("provider-slug", { - type: "string", - description: "The provider_slug field", - }) - .option("rate-limit", { - type: "number", - description: "The rate_limit field", - }) - .option("rate-limit-period", { - type: "number", - description: "The rate_limit_period field", - default: 60, - }) - .option("secret", { - type: "string", - description: - "Provider API key to store in the Secrets Store configured on the gateway.", - }) - .option("secret-id", { type: "string", description: "The secret_id field" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create ", describe: "Store a provider key", - builder, + usage: + "$0 ai-gateway gateways providers create \n\nStores an upstream AI provider API key for an AI Gateway in the Secrets Store configured on the gateway, with an optional rate limit. Pass `secret` to store a new key, or omit it to use an existing Secrets Store secret.", + flags: { + alias: { + kind: "parsed", + brief: "The alias field", + optional: true, + parse: String, + }, + "default-config": { + kind: "boolean", + brief: "The default_config field", + optional: true, + }, + "provider-slug": { + kind: "parsed", + brief: "The provider_slug field", + optional: true, + parse: String, + }, + "rate-limit": { + kind: "parsed", + brief: "The rate_limit field", + optional: true, + parse: Number, + }, + "rate-limit-period": { + kind: "parsed", + brief: "The rate_limit_period field", + default: "60", + parse: Number, + }, + secret: { + kind: "parsed", + brief: + "Provider API key to store in the Secrets Store configured on the gateway.", + optional: true, + parse: String, + }, + "secret-id": { + kind: "parsed", + brief: "The secret_id field", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "gateway-id", + brief: "Unique identifier of the AI Gateway within the account.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway gateways providers create", classification: { safeFlags: ["default-config", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -199,6 +214,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/gateways/providers/delete.ts b/packages/cli/src/commands/_generated/ai-gateway/gateways/providers/delete.ts index 6cb871ec7a..7be395c2fb 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/gateways/providers/delete.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/gateways/providers/delete.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/ai-gateway/gateways/providers/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,40 +17,30 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway gateways providers delete \n\nDeletes a provider key configuration from an AI Gateway and deletes its secret from the Secrets Store." - ) - .positional("id", { - type: "string", - description: "ID", - demandOption: true, - }) - .option("gateway-id", { - type: "string", - description: "Unique identifier of the AI Gateway within the account.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete a provider key", + usage: + "$0 ai-gateway gateways providers delete \n\nDeletes a provider key configuration from an AI Gateway and deletes its secret from the Secrets Store.", + flags: { + "gateway-id": { + kind: "parsed", + brief: "Unique identifier of the AI Gateway within the account.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete a provider key", - builder, + }, + }, + operands: [{ placeholder: "id", brief: "ID", parse: String }], handler: async (argv): Promise => runWithTelemetry( { @@ -59,7 +48,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -100,6 +89,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/gateways/providers/get.ts b/packages/cli/src/commands/_generated/ai-gateway/gateways/providers/get.ts index 83102ad921..58b8f66a6e 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/gateways/providers/get.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/gateways/providers/get.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/ai-gateway/gateways/providers/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,41 +16,31 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway gateways providers get \n\nRetrieves a provider key configuration for an AI Gateway. The response shows a masked preview of the key, never the key itself." - ) - .positional("id", { - type: "string", - description: "ID", - demandOption: true, - }) - .option("gateway-id", { - type: "string", - description: "Unique identifier of the AI Gateway within the account.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get a provider key", - builder, + usage: + "$0 ai-gateway gateways providers get \n\nRetrieves a provider key configuration for an AI Gateway. The response shows a masked preview of the key, never the key itself.", + flags: { + "gateway-id": { + kind: "parsed", + brief: "Unique identifier of the AI Gateway within the account.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [{ placeholder: "id", brief: "ID", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway gateways providers get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -83,6 +72,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/gateways/providers/index.ts b/packages/cli/src/commands/_generated/ai-gateway/gateways/providers/index.ts index 2c936470db..e0826d82dc 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/gateways/providers/index.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/gateways/providers/index.ts @@ -4,29 +4,24 @@ import $get from "./get.js"; import $list from "./list.js"; import $test from "./test.js"; import $update from "./update.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * providers command group * @generated from apis/overlays/ai-gateway.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "providers", describe: "Store and rotate upstream AI provider keys for a gateway", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($get) - .command($list) - .command($test) - .command($update) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + get: $get, + list: $list, + test: $test, + update: $update, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/gateways/providers/list.ts b/packages/cli/src/commands/_generated/ai-gateway/gateways/providers/list.ts index 3a3dce14fe..1a152c15fd 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/gateways/providers/list.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/gateways/providers/list.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/ai-gateway/gateways/providers/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,38 +16,38 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway gateways providers list\n\nLists the provider keys stored for an AI Gateway. Responses show a masked preview of each key, never the key itself." - ) - .option("gateway-id", { - type: "string", - description: "Unique identifier of the AI Gateway within the account.", - demandOption: true, - }) - .option("page", { type: "number", description: "Page" }) - .option("per-page", { type: "number", description: "Per page" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List provider keys", - builder, + usage: + "$0 ai-gateway gateways providers list\n\nLists the provider keys stored for an AI Gateway. Responses show a masked preview of each key, never the key itself.", + flags: { + "gateway-id": { + kind: "parsed", + brief: "Unique identifier of the AI Gateway within the account.", + parse: String, + }, + page: { kind: "parsed", brief: "Page", optional: true, parse: Number }, + "per-page": { + kind: "parsed", + brief: "Per page", + optional: true, + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway gateways providers list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -82,6 +81,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/gateways/providers/test.ts b/packages/cli/src/commands/_generated/ai-gateway/gateways/providers/test.ts index 8988081a10..cc517d1880 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/gateways/providers/test.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/gateways/providers/test.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/ai-gateway/gateways/providers/test.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * test command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,45 +18,37 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway gateways providers test \n\nChecks whether stored credentials can list models through the provider implementation in AI Gateway. Requires AI Gateway content update permission. Does not run inference, check credits or inference permissions, or return provider response bodies. HTTP 401 from the model-list request is classified as invalid, as is AWS Bedrock HTTP 403 with an UnrecognizedClientException error type. Other failures are inconclusive, including other HTTP 400 or 403 responses; a 403 alone does not distinguish rejected credentials from insufficient permissions. Unsupported providers or credential formats also return an inconclusive result." - ) - .positional("id", { - type: "string", - description: "ID", - demandOption: true, - }) - .option("gateway-id", { - type: "string", - description: "Unique identifier of the AI Gateway within the account.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "test ", describe: "Check stored provider credentials", - builder, + usage: + "$0 ai-gateway gateways providers test \n\nChecks whether stored credentials can list models through the provider implementation in AI Gateway. Requires AI Gateway content update permission. Does not run inference, check credits or inference permissions, or return provider response bodies. HTTP 401 from the model-list request is classified as invalid, as is AWS Bedrock HTTP 403 with an UnrecognizedClientException error type. Other failures are inconclusive, including other HTTP 400 or 403 responses; a 403 alone does not distinguish rejected credentials from insufficient permissions. Unsupported providers or credential formats also return an inconclusive result.", + flags: { + "gateway-id": { + kind: "parsed", + brief: "Unique identifier of the AI Gateway within the account.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [{ placeholder: "id", brief: "ID", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway gateways providers test", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -106,6 +97,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/gateways/providers/update.ts b/packages/cli/src/commands/_generated/ai-gateway/gateways/providers/update.ts index b8d4db0a38..04d6d8d493 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/gateways/providers/update.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/gateways/providers/update.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/ai-gateway/gateways/providers/update.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,50 +19,44 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway gateways providers update \n\nReplaces the stored API key of a provider key configuration. Only the key can change." - ) - .positional("id", { - type: "string", - description: "ID", - demandOption: true, - }) - .option("gateway-id", { - type: "string", - description: "Unique identifier of the AI Gateway within the account.", - demandOption: true, - }) - .option("secret", { - type: "string", - description: - "Provider API key to store in the Secrets Store configured on the gateway.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "update ", describe: "Rotate a provider key", - builder, + usage: + "$0 ai-gateway gateways providers update \n\nReplaces the stored API key of a provider key configuration. Only the key can change.", + flags: { + "gateway-id": { + kind: "parsed", + brief: "Unique identifier of the AI Gateway within the account.", + parse: String, + }, + secret: { + kind: "parsed", + brief: + "Provider API key to store in the Secrets Store configured on the gateway.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [{ placeholder: "id", brief: "ID", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway gateways providers update", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -144,6 +137,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/gateways/update.ts b/packages/cli/src/commands/_generated/ai-gateway/gateways/update.ts index adbeddb462..5a8f335ac6 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/gateways/update.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/gateways/update.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -24,381 +23,456 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway gateways update \n\nUpdates the configuration of an AI Gateway, such as its caching, rate limiting, spend limits, logging, and authentication settings." - ) - .positional("gateway-id", { - type: "string", - description: "Unique identifier of the AI Gateway within the account.", - demandOption: true, - }) - .option("authentication", { - type: "boolean", - description: +const command = apiCommand({ + command: "update ", + describe: "Update a gateway", + usage: + "$0 ai-gateway gateways update \n\nUpdates the configuration of an AI Gateway, such as its caching, rate limiting, spend limits, logging, and authentication settings.", + flags: { + authentication: { + kind: "boolean", + brief: "Require authentication for gateway access. New gateways must have authentication enabled. Once enabled, authentication cannot be disabled.", - }) - .option("byok-only", { - type: "boolean", - description: + optional: true, + }, + "byok-only": { + kind: "boolean", + brief: "Requires customer-provided provider credentials and prevents fallback to Unified Billing.", - }) - .option("cache-invalidate-on-update", { - type: "boolean", - description: "The cache_invalidate_on_update field", - }) - .option("cache-ttl", { type: "number", description: "The cache_ttl field" }) - .option("collect-logs", { - type: "boolean", - description: "The collect_logs field", - }) - .option("guardrails-prompt-p1", { - type: "string", - description: "The guardrails.prompt.P1 field", + optional: true, + }, + "cache-invalidate-on-update": { + kind: "boolean", + brief: "The cache_invalidate_on_update field", + optional: true, + }, + "cache-ttl": { + kind: "parsed", + brief: "The cache_ttl field", + optional: true, + parse: Number, + }, + "collect-logs": { + kind: "boolean", + brief: "The collect_logs field", + optional: true, + }, + "guardrails-prompt-p1": { + kind: "parsed", + brief: "The guardrails.prompt.P1 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-prompt-p1", (value) => - resolveFileToken(value, "guardrails-prompt-p1", "text") - ) - .option("guardrails-prompt-s1", { - type: "string", - description: "The guardrails.prompt.S1 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-prompt-p1", "text"), + }, + "guardrails-prompt-s1": { + kind: "parsed", + brief: "The guardrails.prompt.S1 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-prompt-s1", (value) => - resolveFileToken(value, "guardrails-prompt-s1", "text") - ) - .option("guardrails-prompt-s10", { - type: "string", - description: "The guardrails.prompt.S10 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-prompt-s1", "text"), + }, + "guardrails-prompt-s10": { + kind: "parsed", + brief: "The guardrails.prompt.S10 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-prompt-s10", (value) => - resolveFileToken(value, "guardrails-prompt-s10", "text") - ) - .option("guardrails-prompt-s11", { - type: "string", - description: "The guardrails.prompt.S11 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-prompt-s10", "text"), + }, + "guardrails-prompt-s11": { + kind: "parsed", + brief: "The guardrails.prompt.S11 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-prompt-s11", (value) => - resolveFileToken(value, "guardrails-prompt-s11", "text") - ) - .option("guardrails-prompt-s12", { - type: "string", - description: "The guardrails.prompt.S12 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-prompt-s11", "text"), + }, + "guardrails-prompt-s12": { + kind: "parsed", + brief: "The guardrails.prompt.S12 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-prompt-s12", (value) => - resolveFileToken(value, "guardrails-prompt-s12", "text") - ) - .option("guardrails-prompt-s13", { - type: "string", - description: "The guardrails.prompt.S13 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-prompt-s12", "text"), + }, + "guardrails-prompt-s13": { + kind: "parsed", + brief: "The guardrails.prompt.S13 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-prompt-s13", (value) => - resolveFileToken(value, "guardrails-prompt-s13", "text") - ) - .option("guardrails-prompt-s14", { - type: "string", - description: "The guardrails.prompt.S14 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-prompt-s13", "text"), + }, + "guardrails-prompt-s14": { + kind: "parsed", + brief: "The guardrails.prompt.S14 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-prompt-s14", (value) => - resolveFileToken(value, "guardrails-prompt-s14", "text") - ) - .option("guardrails-prompt-s2", { - type: "string", - description: "The guardrails.prompt.S2 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-prompt-s14", "text"), + }, + "guardrails-prompt-s2": { + kind: "parsed", + brief: "The guardrails.prompt.S2 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-prompt-s2", (value) => - resolveFileToken(value, "guardrails-prompt-s2", "text") - ) - .option("guardrails-prompt-s3", { - type: "string", - description: "The guardrails.prompt.S3 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-prompt-s2", "text"), + }, + "guardrails-prompt-s3": { + kind: "parsed", + brief: "The guardrails.prompt.S3 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-prompt-s3", (value) => - resolveFileToken(value, "guardrails-prompt-s3", "text") - ) - .option("guardrails-prompt-s4", { - type: "string", - description: "The guardrails.prompt.S4 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-prompt-s3", "text"), + }, + "guardrails-prompt-s4": { + kind: "parsed", + brief: "The guardrails.prompt.S4 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-prompt-s4", (value) => - resolveFileToken(value, "guardrails-prompt-s4", "text") - ) - .option("guardrails-prompt-s5", { - type: "string", - description: "The guardrails.prompt.S5 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-prompt-s4", "text"), + }, + "guardrails-prompt-s5": { + kind: "parsed", + brief: "The guardrails.prompt.S5 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-prompt-s5", (value) => - resolveFileToken(value, "guardrails-prompt-s5", "text") - ) - .option("guardrails-prompt-s6", { - type: "string", - description: "The guardrails.prompt.S6 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-prompt-s5", "text"), + }, + "guardrails-prompt-s6": { + kind: "parsed", + brief: "The guardrails.prompt.S6 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-prompt-s6", (value) => - resolveFileToken(value, "guardrails-prompt-s6", "text") - ) - .option("guardrails-prompt-s7", { - type: "string", - description: "The guardrails.prompt.S7 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-prompt-s6", "text"), + }, + "guardrails-prompt-s7": { + kind: "parsed", + brief: "The guardrails.prompt.S7 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-prompt-s7", (value) => - resolveFileToken(value, "guardrails-prompt-s7", "text") - ) - .option("guardrails-prompt-s8", { - type: "string", - description: "The guardrails.prompt.S8 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-prompt-s7", "text"), + }, + "guardrails-prompt-s8": { + kind: "parsed", + brief: "The guardrails.prompt.S8 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-prompt-s8", (value) => - resolveFileToken(value, "guardrails-prompt-s8", "text") - ) - .option("guardrails-prompt-s9", { - type: "string", - description: "The guardrails.prompt.S9 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-prompt-s8", "text"), + }, + "guardrails-prompt-s9": { + kind: "parsed", + brief: "The guardrails.prompt.S9 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-prompt-s9", (value) => - resolveFileToken(value, "guardrails-prompt-s9", "text") - ) - .option("guardrails-response-p1", { - type: "string", - description: "The guardrails.response.P1 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-prompt-s9", "text"), + }, + "guardrails-response-p1": { + kind: "parsed", + brief: "The guardrails.response.P1 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-response-p1", (value) => - resolveFileToken(value, "guardrails-response-p1", "text") - ) - .option("guardrails-response-s1", { - type: "string", - description: "The guardrails.response.S1 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-response-p1", "text"), + }, + "guardrails-response-s1": { + kind: "parsed", + brief: "The guardrails.response.S1 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-response-s1", (value) => - resolveFileToken(value, "guardrails-response-s1", "text") - ) - .option("guardrails-response-s10", { - type: "string", - description: "The guardrails.response.S10 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-response-s1", "text"), + }, + "guardrails-response-s10": { + kind: "parsed", + brief: "The guardrails.response.S10 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-response-s10", (value) => - resolveFileToken(value, "guardrails-response-s10", "text") - ) - .option("guardrails-response-s11", { - type: "string", - description: "The guardrails.response.S11 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-response-s10", "text"), + }, + "guardrails-response-s11": { + kind: "parsed", + brief: "The guardrails.response.S11 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-response-s11", (value) => - resolveFileToken(value, "guardrails-response-s11", "text") - ) - .option("guardrails-response-s12", { - type: "string", - description: "The guardrails.response.S12 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-response-s11", "text"), + }, + "guardrails-response-s12": { + kind: "parsed", + brief: "The guardrails.response.S12 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-response-s12", (value) => - resolveFileToken(value, "guardrails-response-s12", "text") - ) - .option("guardrails-response-s13", { - type: "string", - description: "The guardrails.response.S13 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-response-s12", "text"), + }, + "guardrails-response-s13": { + kind: "parsed", + brief: "The guardrails.response.S13 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-response-s13", (value) => - resolveFileToken(value, "guardrails-response-s13", "text") - ) - .option("guardrails-response-s14", { - type: "string", - description: "The guardrails.response.S14 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-response-s13", "text"), + }, + "guardrails-response-s14": { + kind: "parsed", + brief: "The guardrails.response.S14 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-response-s14", (value) => - resolveFileToken(value, "guardrails-response-s14", "text") - ) - .option("guardrails-response-s2", { - type: "string", - description: "The guardrails.response.S2 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-response-s14", "text"), + }, + "guardrails-response-s2": { + kind: "parsed", + brief: "The guardrails.response.S2 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-response-s2", (value) => - resolveFileToken(value, "guardrails-response-s2", "text") - ) - .option("guardrails-response-s3", { - type: "string", - description: "The guardrails.response.S3 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-response-s2", "text"), + }, + "guardrails-response-s3": { + kind: "parsed", + brief: "The guardrails.response.S3 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-response-s3", (value) => - resolveFileToken(value, "guardrails-response-s3", "text") - ) - .option("guardrails-response-s4", { - type: "string", - description: "The guardrails.response.S4 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-response-s3", "text"), + }, + "guardrails-response-s4": { + kind: "parsed", + brief: "The guardrails.response.S4 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-response-s4", (value) => - resolveFileToken(value, "guardrails-response-s4", "text") - ) - .option("guardrails-response-s5", { - type: "string", - description: "The guardrails.response.S5 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-response-s4", "text"), + }, + "guardrails-response-s5": { + kind: "parsed", + brief: "The guardrails.response.S5 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-response-s5", (value) => - resolveFileToken(value, "guardrails-response-s5", "text") - ) - .option("guardrails-response-s6", { - type: "string", - description: "The guardrails.response.S6 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-response-s5", "text"), + }, + "guardrails-response-s6": { + kind: "parsed", + brief: "The guardrails.response.S6 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-response-s6", (value) => - resolveFileToken(value, "guardrails-response-s6", "text") - ) - .option("guardrails-response-s7", { - type: "string", - description: "The guardrails.response.S7 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-response-s6", "text"), + }, + "guardrails-response-s7": { + kind: "parsed", + brief: "The guardrails.response.S7 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-response-s7", (value) => - resolveFileToken(value, "guardrails-response-s7", "text") - ) - .option("guardrails-response-s8", { - type: "string", - description: "The guardrails.response.S8 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-response-s7", "text"), + }, + "guardrails-response-s8": { + kind: "parsed", + brief: "The guardrails.response.S8 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-response-s8", (value) => - resolveFileToken(value, "guardrails-response-s8", "text") - ) - .option("guardrails-response-s9", { - type: "string", - description: "The guardrails.response.S9 field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-response-s8", "text"), + }, + "guardrails-response-s9": { + kind: "parsed", + brief: "The guardrails.response.S9 field", + optional: true, choices: ["FLAG", "BLOCK"], - }) - .coerce("guardrails-response-s9", (value) => - resolveFileToken(value, "guardrails-response-s9", "text") - ) - .option("log-classification", { - type: "boolean", - description: "The log_classification field", - }) - .option("log-management", { - type: "number", - description: "The log_management field", - }) - .option("log-management-strategy", { - type: "string", - description: "The log_management_strategy field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-response-s9", "text"), + }, + "log-classification": { + kind: "boolean", + brief: "The log_classification field", + optional: true, + }, + "log-management": { + kind: "parsed", + brief: "The log_management field", + optional: true, + parse: Number, + }, + "log-management-strategy": { + kind: "parsed", + brief: "The log_management_strategy field", + optional: true, choices: ["STOP_INSERTING", "DELETE_OLDEST"], - }) - .coerce("log-management-strategy", (value) => - resolveFileToken(value, "log-management-strategy", "text") - ) - .option("logpush", { type: "boolean", description: "The logpush field" }) - .option("logpush-public-key", { - type: "string", - description: "The logpush_public_key field", - }) - .option("multiprovider-enabled", { - type: "boolean", - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "log-management-strategy", "text"), + }, + logpush: { kind: "boolean", brief: "The logpush field", optional: true }, + "logpush-public-key": { + kind: "parsed", + brief: "The logpush_public_key field", + optional: true, + parse: String, + }, + "multiprovider-enabled": { + kind: "boolean", + brief: "Lets requests to a model use every provider that serves it. When off, a model uses only the providers it launched with, so a provider added later receives none of its traffic. A request that names providers (the cf-aig-allowed-providers header or routing.allowedProviders) can still use any of them. Model aliases (custom/) are not restricted.", - }) - .option("otel", { - type: "string", - description: + optional: true, + }, + otel: { + kind: "parsed", + brief: 'The otel field. Provide as a JSON array of objects, null, or @path/to/file.json. Shape: [{"headers": {...}, "url": string, "authorization"?: string, "content_type"?: "json" | "protobuf"}]. ? marks optional keys.', - }) - .option("rate-limiting-interval", { - type: "number", - description: "The rate_limiting_interval field", - }) - .option("rate-limiting-limit", { - type: "number", - description: "The rate_limiting_limit field", - }) - .option("rate-limiting-technique", { - type: "string", - description: "The rate_limiting_technique field", + optional: true, + parse: String, + }, + "rate-limiting-interval": { + kind: "parsed", + brief: "The rate_limiting_interval field", + optional: true, + parse: Number, + }, + "rate-limiting-limit": { + kind: "parsed", + brief: "The rate_limiting_limit field", + optional: true, + parse: Number, + }, + "rate-limiting-technique": { + kind: "parsed", + brief: "The rate_limiting_technique field", + optional: true, choices: ["fixed", "sliding"], - }) - .coerce("rate-limiting-technique", (value) => - resolveFileToken(value, "rate-limiting-technique", "text") - ) - .option("retry-backoff", { - type: "string", - description: "Backoff strategy for retry delays", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "rate-limiting-technique", "text"), + }, + "retry-backoff": { + kind: "parsed", + brief: "Backoff strategy for retry delays", + optional: true, choices: ["constant", "linear", "exponential"], - }) - .coerce("retry-backoff", (value) => - resolveFileToken(value, "retry-backoff", "text") - ) - .option("retry-delay", { - type: "number", - description: "Delay between retry attempts in milliseconds (0-60000)", - }) - .option("retry-max-attempts", { - type: "number", - description: "Maximum number of retry attempts for failed requests (1-5)", - }) - .option("spend-limits-enabled", { - type: "boolean", - description: "The spend_limits.enabled field", - }) - .option("spend-limits-rules", { - type: "string", - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "retry-backoff", "text"), + }, + "retry-delay": { + kind: "parsed", + brief: "Delay between retry attempts in milliseconds (0-60000)", + optional: true, + parse: Number, + }, + "retry-max-attempts": { + kind: "parsed", + brief: "Maximum number of retry attempts for failed requests (1-5)", + optional: true, + parse: Number, + }, + "spend-limits-enabled": { + kind: "boolean", + brief: "The spend_limits.enabled field", + optional: true, + }, + "spend-limits-rules": { + kind: "parsed", + brief: 'The spend_limits.rules field. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"limit": number, "limitType": "cost", "window": number, "enabled"?: boolean, "id"?: string, ...more}]. ? marks optional keys.', - }) - .option("store-id", { - type: "string", - description: + optional: true, + parse: String, + }, + "store-id": { + kind: "parsed", + brief: "Secrets Store used by this gateway. Omit on update to keep the current store. Cannot be cleared while stored keys or secret references depend on it.", - }) - .option("stripe-authorization", { - type: "string", - description: "The stripe.authorization field", - }) - .option("stripe-usage-events", { - type: "string", - description: + optional: true, + parse: String, + }, + "stripe-authorization": { + kind: "parsed", + brief: "The stripe.authorization field", + optional: true, + parse: String, + }, + "stripe-usage-events": { + kind: "parsed", + brief: 'The stripe.usage_events field. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"payload": string}].', - }) - .option("workers-ai-billing-mode", { - type: "string", - description: + optional: true, + parse: String, + }, + "workers-ai-billing-mode": { + kind: "parsed", + brief: "Controls how Workers AI inference calls routed through this gateway are billed. 'postpaid' bills the account directly through Workers AI; 'unified' deducts credits via AI Gateway using neuron-based pricing and delegates billing to AI Gateway.", + optional: true, choices: ["postpaid", "unified"], - }) - .coerce("workers-ai-billing-mode", (value) => - resolveFileToken(value, "workers-ai-billing-mode", "text") - ) - .option("zdr", { type: "boolean", description: "The zdr field" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "workers-ai-billing-mode", "text"), + }, + zdr: { kind: "boolean", brief: "The zdr field", optional: true }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }) - .check((argv) => { + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "gateway-id", + brief: "Unique identifier of the AI Gateway within the account.", + parse: String, + }, + ], + rules(rules) { + rules.check((argv) => { const groupSet = ["stripe-authorization", "stripe-usage-events"].some( (k) => argv[k] !== undefined ); @@ -414,14 +488,7 @@ function builder(yargs: Argv) { } return true; }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "update ", - describe: "Update a gateway", - builder, + }, handler: async (argv): Promise => runWithTelemetry( { @@ -473,7 +540,7 @@ const command: CommandModule = { "zdr", "dry-run", ], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -947,6 +1014,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/index.ts b/packages/cli/src/commands/_generated/ai-gateway/index.ts index 2613e67834..b48f87e382 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/index.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/index.ts @@ -4,30 +4,25 @@ import $dynamicrouting from "./dynamic-routing/index.js"; import $gateways from "./gateways/index.js"; import $logs from "./logs/index.js"; import $modelaliases from "./model-aliases/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * ai-gateway command * @generated from apis/overlays/ai-gateway.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "ai-gateway", describe: "Proxy, cache, rate-limit, and observe requests to AI providers — OpenAI, Anthropic, Workers AI, and more", - builder: (yargs) => { - return yargs - .command($customdomains) - .command($customproviders) - .command($dynamicrouting) - .command($gateways) - .command($logs) - .command($modelaliases) - .demandCommand(1, "Please specify a subcommand"); + routes: { + "custom-domains": $customdomains, + "custom-providers": $customproviders, + "dynamic-routing": $dynamicrouting, + gateways: $gateways, + logs: $logs, + "model-aliases": $modelaliases, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/logs/delete.ts b/packages/cli/src/commands/_generated/ai-gateway/logs/delete.ts index 9756a240e3..4a00120d64 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/logs/delete.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/logs/delete.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-gateway/logs/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,20 +17,16 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway logs delete \n\nDeletes gateway log entries matching the specified criteria." - ) - .positional("gateway-id", { - type: "string", - description: "Unique identifier of the AI Gateway within the account.", - demandOption: true, - }) - .option("order-by", { - type: "string", - description: "Order by", - choices: [ +const command = apiCommand({ + command: "delete ", + describe: "Delete Gateway Logs", + usage: + "$0 ai-gateway logs delete \n\nDeletes gateway log entries matching the specified criteria.", + flags: { + "order-by": { + kind: "enum", + brief: "Order by", + values: [ "created_at", "provider", "model", @@ -44,33 +39,41 @@ function builder(yargs: Argv) { "duration", "feedback", ], - }) - .option("order-by-direction", { - type: "string", - description: "Order by direction", - choices: ["asc", "desc"], - }) - .option("filters", { type: "string", array: true, description: "Filters" }) - .option("limit", { type: "number", description: "Limit" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + }, + "order-by-direction": { + kind: "enum", + brief: "Order by direction", + values: ["asc", "desc"], + optional: true, + }, + filters: { + kind: "parsed", + brief: "Filters", + variadic: true, + optional: true, + parse: String, + }, + limit: { kind: "parsed", brief: "Limit", optional: true, parse: Number }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete Gateway Logs", - builder, + }, + }, + operands: [ + { + placeholder: "gateway-id", + brief: "Unique identifier of the AI Gateway within the account.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -78,7 +81,7 @@ const command: CommandModule = { classification: { safeFlags: ["order-by", "order-by-direction", "dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -123,6 +126,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/logs/get-request.ts b/packages/cli/src/commands/_generated/ai-gateway/logs/get-request.ts index 5f55287367..855359a46a 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/logs/get-request.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/logs/get-request.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-gateway/logs/get-request.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get-request command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,41 +16,31 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway logs get-request \n\nRetrieves the original request payload for an AI Gateway log entry." - ) - .positional("id", { - type: "string", - description: "ID", - demandOption: true, - }) - .option("gateway-id", { - type: "string", - description: "Unique identifier of the AI Gateway within the account.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get-request ", describe: "Get Gateway Log Request", - builder, + usage: + "$0 ai-gateway logs get-request \n\nRetrieves the original request payload for an AI Gateway log entry.", + flags: { + "gateway-id": { + kind: "parsed", + brief: "Unique identifier of the AI Gateway within the account.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [{ placeholder: "id", brief: "ID", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway logs get-request", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -83,6 +72,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/logs/get-response.ts b/packages/cli/src/commands/_generated/ai-gateway/logs/get-response.ts index 57a92997b9..83d9108012 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/logs/get-response.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/logs/get-response.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-gateway/logs/get-response.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get-response command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,41 +16,31 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway logs get-response \n\nRetrieves the response payload for an AI Gateway log entry." - ) - .positional("id", { - type: "string", - description: "ID", - demandOption: true, - }) - .option("gateway-id", { - type: "string", - description: "Unique identifier of the AI Gateway within the account.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get-response ", describe: "Get Gateway Log Response", - builder, + usage: + "$0 ai-gateway logs get-response \n\nRetrieves the response payload for an AI Gateway log entry.", + flags: { + "gateway-id": { + kind: "parsed", + brief: "Unique identifier of the AI Gateway within the account.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [{ placeholder: "id", brief: "ID", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway logs get-response", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -83,6 +72,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/logs/get.ts b/packages/cli/src/commands/_generated/ai-gateway/logs/get.ts index 5d13205173..c7958960a0 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/logs/get.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/logs/get.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-gateway/logs/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,41 +16,31 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway logs get \n\nRetrieves detailed information for a specific AI Gateway log entry." - ) - .positional("id", { - type: "string", - description: "ID", - demandOption: true, - }) - .option("gateway-id", { - type: "string", - description: "Unique identifier of the AI Gateway within the account.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get Gateway Log Detail", - builder, + usage: + "$0 ai-gateway logs get \n\nRetrieves detailed information for a specific AI Gateway log entry.", + flags: { + "gateway-id": { + kind: "parsed", + brief: "Unique identifier of the AI Gateway within the account.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [{ placeholder: "id", brief: "ID", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway logs get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -83,6 +72,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/logs/index.ts b/packages/cli/src/commands/_generated/ai-gateway/logs/index.ts index 622fcbd279..b98ac917b0 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/logs/index.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/logs/index.ts @@ -4,30 +4,25 @@ import $getresponse from "./get-response.js"; import $get from "./get.js"; import $list from "./list.js"; import $update from "./update.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * logs command group * @generated from apis/overlays/ai-gateway.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "logs", describe: "Inspect, annotate, and delete gateway request logs stored by Legacy Logs", - builder: (yargs) => { - return yargs - .command($delete) - .command($get) - .command($getrequest) - .command($getresponse) - .command($list) - .command($update) - .demandCommand(1, "Please specify a subcommand"); + routes: { + delete: $delete, + get: $get, + "get-request": $getrequest, + "get-response": $getresponse, + list: $list, + update: $update, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/logs/list.ts b/packages/cli/src/commands/_generated/ai-gateway/logs/list.ts index 3ec26e19e9..452782e0db 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/logs/list.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/logs/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-gateway/logs/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,30 +16,40 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway logs list\n\nLists request/response log entries for the AI gateway with filtering and pagination." - ) - .option("gateway-id", { - type: "string", - description: "Unique identifier of the AI Gateway within the account.", - demandOption: true, - }) - .option("search", { - type: "string", - description: "Free-text search over log metadata.", - }) - .option("page", { - type: "number", - description: +const command = apiCommand({ + command: "list", + describe: "List Gateway Logs", + usage: + "$0 ai-gateway logs list\n\nLists request/response log entries for the AI gateway with filtering and pagination.", + flags: { + "gateway-id": { + kind: "parsed", + brief: "Unique identifier of the AI Gateway within the account.", + parse: String, + }, + search: { + kind: "parsed", + brief: "Free-text search over log metadata.", + optional: true, + parse: String, + }, + page: { + kind: "parsed", + brief: "Page number, from 1. A high page reads every page before it again. To read further back in a listing sorted by created_at, ask for page 1 again with a created_at lt filter set to the created_at of the last log returned. Logs in the same millisecond as that log can be left out: to include them, set the filter 1 ms later and drop the logs already returned.", - }) - .option("per-page", { type: "number", description: "Per page" }) - .option("order-by", { - type: "string", - description: "Order by", - choices: [ + optional: true, + parse: Number, + }, + "per-page": { + kind: "parsed", + brief: "Per page", + optional: true, + parse: Number, + }, + "order-by": { + kind: "enum", + brief: "Order by", + values: [ "created_at", "provider", "model", @@ -48,68 +57,145 @@ function builder(yargs: Argv) { "success", "cached", ], - }) - .option("order-by-direction", { - type: "string", - description: "Order by direction", - choices: ["asc", "desc"], - }) - .option("filters", { type: "string", array: true, description: "Filters" }) - .option("meta-info", { type: "boolean", description: "Meta info" }) - .option("direction", { - type: "string", - description: "Direction", - choices: ["asc", "desc"], - }) - .option("start-date", { type: "string", description: "Start date" }) - .option("end-date", { type: "string", description: "End date" }) - .option("min-cost", { type: "number", description: "Min cost" }) - .option("max-cost", { type: "number", description: "Max cost" }) - .option("min-tokens-in", { type: "number", description: "Min tokens in" }) - .option("max-tokens-in", { type: "number", description: "Max tokens in" }) - .option("min-tokens-out", { type: "number", description: "Min tokens out" }) - .option("max-tokens-out", { type: "number", description: "Max tokens out" }) - .option("min-total-tokens", { - type: "number", - description: "Min total tokens", - }) - .option("max-total-tokens", { - type: "number", - description: "Max total tokens", - }) - .option("min-duration", { type: "number", description: "Min duration" }) - .option("max-duration", { type: "number", description: "Max duration" }) - .option("feedback", { - type: "string", - description: "Feedback", - choices: ["-1", "0", "1"], - }) - .option("success", { type: "boolean", description: "Success" }) - .option("cached", { type: "boolean", description: "Cached" }) - .option("model", { type: "string", description: "Model filter." }) - .option("model-type", { type: "string", description: "Model type" }) - .option("ai-gateway-provider", { type: "string", description: "Provider" }) - .option("request-content-type", { - type: "string", - description: "Request content type", - }) - .option("response-content-type", { - type: "string", - description: "Response content type", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + }, + "order-by-direction": { + kind: "enum", + brief: "Order by direction", + values: ["asc", "desc"], + optional: true, + }, + filters: { + kind: "parsed", + brief: "Filters", + variadic: true, + optional: true, + parse: String, + }, + "meta-info": { kind: "boolean", brief: "Meta info", optional: true }, + direction: { + kind: "enum", + brief: "Direction", + values: ["asc", "desc"], + optional: true, + }, + "start-date": { + kind: "parsed", + brief: "Start date", + optional: true, + parse: String, + }, + "end-date": { + kind: "parsed", + brief: "End date", + optional: true, + parse: String, + }, + "min-cost": { + kind: "parsed", + brief: "Min cost", + optional: true, + parse: Number, + }, + "max-cost": { + kind: "parsed", + brief: "Max cost", + optional: true, + parse: Number, + }, + "min-tokens-in": { + kind: "parsed", + brief: "Min tokens in", + optional: true, + parse: Number, + }, + "max-tokens-in": { + kind: "parsed", + brief: "Max tokens in", + optional: true, + parse: Number, + }, + "min-tokens-out": { + kind: "parsed", + brief: "Min tokens out", + optional: true, + parse: Number, + }, + "max-tokens-out": { + kind: "parsed", + brief: "Max tokens out", + optional: true, + parse: Number, + }, + "min-total-tokens": { + kind: "parsed", + brief: "Min total tokens", + optional: true, + parse: Number, + }, + "max-total-tokens": { + kind: "parsed", + brief: "Max total tokens", + optional: true, + parse: Number, + }, + "min-duration": { + kind: "parsed", + brief: "Min duration", + optional: true, + parse: Number, + }, + "max-duration": { + kind: "parsed", + brief: "Max duration", + optional: true, + parse: Number, + }, + feedback: { + kind: "enum", + brief: "Feedback", + values: ["-1", "0", "1"], + optional: true, + }, + success: { kind: "boolean", brief: "Success", optional: true }, + cached: { kind: "boolean", brief: "Cached", optional: true }, + model: { + kind: "parsed", + brief: "Model filter.", + optional: true, + parse: String, + }, + "model-type": { + kind: "parsed", + brief: "Model type", + optional: true, + parse: String, + }, + "ai-gateway-provider": { + kind: "parsed", + brief: "Provider", + optional: true, + parse: String, + }, + "request-content-type": { + kind: "parsed", + brief: "Request content type", + optional: true, + parse: String, + }, + "response-content-type": { + kind: "parsed", + brief: "Response content type", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "list", - describe: "List Gateway Logs", - builder, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { @@ -125,7 +211,7 @@ const command: CommandModule = { "cached", "dry-run", ], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -185,6 +271,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/logs/update.ts b/packages/cli/src/commands/_generated/ai-gateway/logs/update.ts index ca387a41f9..7816c24d59 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/logs/update.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/logs/update.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-gateway/logs/update.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,52 +17,56 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway logs update \n\nUpdates metadata for an AI Gateway log entry." - ) - .positional("id", { - type: "string", - description: "ID", - demandOption: true, - }) - .option("gateway-id", { - type: "string", - description: "Unique identifier of the AI Gateway within the account.", - demandOption: true, - }) - .option("feedback", { type: "number", description: "The feedback field" }) - .option("metadata", { - type: "string", - description: - 'The metadata field. Provide as a JSON object or @path/to/file.json. Shape: {"": (string | number | boolean)}.', - }) - .option("score", { type: "number", description: "The score field" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "update ", describe: "Patch Gateway Log", - builder, + usage: + "$0 ai-gateway logs update \n\nUpdates metadata for an AI Gateway log entry.", + flags: { + "gateway-id": { + kind: "parsed", + brief: "Unique identifier of the AI Gateway within the account.", + parse: String, + }, + feedback: { + kind: "parsed", + brief: "The feedback field", + optional: true, + parse: Number, + }, + metadata: { + kind: "parsed", + brief: + 'The metadata field. Provide as a JSON object or @path/to/file.json. Shape: {"": (string | number | boolean)}.', + optional: true, + parse: String, + }, + score: { + kind: "parsed", + brief: "The score field", + optional: true, + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [{ placeholder: "id", brief: "ID", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway logs update", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -132,6 +135,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/model-aliases/create.ts b/packages/cli/src/commands/_generated/ai-gateway/model-aliases/create.ts index 457c6307fd..3692a6a2bf 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/model-aliases/create.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/model-aliases/create.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-gateway/model-aliases/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,62 +19,63 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway model-aliases create \n\nCreates a model alias on a gateway: a named, ordered list of catalog models, each optionally restricted to providers. Requests address it as `custom/`." - ) - .positional("gateway-id", { - type: "string", - description: "Gateway ID", - demandOption: true, - }) - .option("models", { - type: "string", - description: +const command = apiCommand({ + command: "create ", + describe: "Create a model alias", + usage: + "$0 ai-gateway model-aliases create \n\nCreates a model alias on a gateway: a named, ordered list of catalog models, each optionally restricted to providers. Requests address it as `custom/`.", + flags: { + models: { + kind: "parsed", + brief: 'The models field. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"model": string, "providers"?: [string]}]. ? marks optional keys.', - }) - .option("name", { type: "string", description: "The name field" }) - .option("routing-algorithm", { - type: "string", - description: "The routing.algorithm field", + optional: true, + parse: String, + }, + name: { + kind: "parsed", + brief: "The name field", + optional: true, + parse: String, + }, + "routing-algorithm": { + kind: "parsed", + brief: "The routing.algorithm field", + optional: true, choices: ["preferred", "smart"], - }) - .coerce("routing-algorithm", (value) => - resolveFileToken(value, "routing-algorithm", "text") - ) - .option("routing-mode", { - type: "string", - description: "The routing.mode field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "routing-algorithm", "text"), + }, + "routing-mode": { + kind: "parsed", + brief: "The routing.mode field", + optional: true, choices: ["cost", "best"], - }) - .coerce("routing-mode", (value) => - resolveFileToken(value, "routing-mode", "text") - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "routing-mode", "text"), + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "create ", - describe: "Create a model alias", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [{ placeholder: "gateway-id", brief: "Gateway ID", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway model-aliases create", classification: { safeFlags: ["routing-algorithm", "routing-mode", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -164,6 +164,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/model-aliases/delete.ts b/packages/cli/src/commands/_generated/ai-gateway/model-aliases/delete.ts index 79703c9ea1..21bead3c91 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/model-aliases/delete.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/model-aliases/delete.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-gateway/model-aliases/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,40 +17,26 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway model-aliases delete \n\nDeletes a model alias from a gateway." - ) - .positional("id", { - type: "string", - description: "ID", - demandOption: true, - }) - .option("gateway-id", { - type: "string", - description: "Gateway ID", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete a model alias", + usage: + "$0 ai-gateway model-aliases delete \n\nDeletes a model alias from a gateway.", + flags: { + "gateway-id": { kind: "parsed", brief: "Gateway ID", parse: String }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete a model alias", - builder, + }, + }, + operands: [{ placeholder: "id", brief: "ID", parse: String }], handler: async (argv): Promise => runWithTelemetry( { @@ -59,7 +44,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -95,6 +80,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/model-aliases/get.ts b/packages/cli/src/commands/_generated/ai-gateway/model-aliases/get.ts index 2bf1f3f33a..0b48eb5169 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/model-aliases/get.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/model-aliases/get.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-gateway/model-aliases/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,41 +16,27 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway model-aliases get \n\nRetrieves a model alias configured on a gateway." - ) - .positional("id", { - type: "string", - description: "ID", - demandOption: true, - }) - .option("gateway-id", { - type: "string", - description: "Gateway ID", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get a model alias", - builder, + usage: + "$0 ai-gateway model-aliases get \n\nRetrieves a model alias configured on a gateway.", + flags: { + "gateway-id": { kind: "parsed", brief: "Gateway ID", parse: String }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [{ placeholder: "id", brief: "ID", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway model-aliases get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -83,6 +68,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/model-aliases/index.ts b/packages/cli/src/commands/_generated/ai-gateway/model-aliases/index.ts index 2bf9151443..61ff9261d2 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/model-aliases/index.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/model-aliases/index.ts @@ -3,29 +3,24 @@ import $delete from "./delete.js"; import $get from "./get.js"; import $list from "./list.js"; import $update from "./update.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * model-aliases command group * @generated from apis/overlays/ai-gateway.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "model-aliases", describe: "Map a custom model name to one or more provider models on a gateway", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($get) - .command($list) - .command($update) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + get: $get, + list: $list, + update: $update, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/model-aliases/list.ts b/packages/cli/src/commands/_generated/ai-gateway/model-aliases/list.ts index db721f6725..ec9770888b 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/model-aliases/list.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/model-aliases/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-gateway/model-aliases/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,38 +16,34 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway model-aliases list\n\nLists the model aliases configured on a gateway, sorted by name." - ) - .option("gateway-id", { - type: "string", - description: "Gateway ID", - demandOption: true, - }) - .option("page", { type: "number", description: "Page" }) - .option("per-page", { type: "number", description: "Per page" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List model aliases", - builder, + usage: + "$0 ai-gateway model-aliases list\n\nLists the model aliases configured on a gateway, sorted by name.", + flags: { + "gateway-id": { kind: "parsed", brief: "Gateway ID", parse: String }, + page: { kind: "parsed", brief: "Page", optional: true, parse: Number }, + "per-page": { + kind: "parsed", + brief: "Per page", + optional: true, + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway model-aliases list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -82,6 +77,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-gateway/model-aliases/update.ts b/packages/cli/src/commands/_generated/ai-gateway/model-aliases/update.ts index 0d0021543e..39aced019f 100644 --- a/packages/cli/src/commands/_generated/ai-gateway/model-aliases/update.ts +++ b/packages/cli/src/commands/_generated/ai-gateway/model-aliases/update.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-gateway/model-aliases/update.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/ai-gateway.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,67 +19,64 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-gateway model-aliases update \n\nReplaces a model alias. Omitting `routing` clears any previously stored routing options." - ) - .positional("id", { - type: "string", - description: "ID", - demandOption: true, - }) - .option("gateway-id", { - type: "string", - description: "Gateway ID", - demandOption: true, - }) - .option("models", { - type: "string", - description: +const command = apiCommand({ + command: "update ", + describe: "Update a model alias", + usage: + "$0 ai-gateway model-aliases update \n\nReplaces a model alias. Omitting `routing` clears any previously stored routing options.", + flags: { + "gateway-id": { kind: "parsed", brief: "Gateway ID", parse: String }, + models: { + kind: "parsed", + brief: 'The models field. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"model": string, "providers"?: [string]}]. ? marks optional keys.', - }) - .option("name", { type: "string", description: "The name field" }) - .option("routing-algorithm", { - type: "string", - description: "The routing.algorithm field", + optional: true, + parse: String, + }, + name: { + kind: "parsed", + brief: "The name field", + optional: true, + parse: String, + }, + "routing-algorithm": { + kind: "parsed", + brief: "The routing.algorithm field", + optional: true, choices: ["preferred", "smart"], - }) - .coerce("routing-algorithm", (value) => - resolveFileToken(value, "routing-algorithm", "text") - ) - .option("routing-mode", { - type: "string", - description: "The routing.mode field", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "routing-algorithm", "text"), + }, + "routing-mode": { + kind: "parsed", + brief: "The routing.mode field", + optional: true, choices: ["cost", "best"], - }) - .coerce("routing-mode", (value) => - resolveFileToken(value, "routing-mode", "text") - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "routing-mode", "text"), + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "update ", - describe: "Update a model alias", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [{ placeholder: "id", brief: "ID", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "ai-gateway model-aliases update", classification: { safeFlags: ["routing-algorithm", "routing-mode", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -174,6 +170,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/chat-completions.ts b/packages/cli/src/commands/_generated/ai-search/chat-completions.ts index 10c3255b26..40391986e0 100644 --- a/packages/cli/src/commands/_generated/ai-search/chat-completions.ts +++ b/packages/cli/src/commands/_generated/ai-search/chat-completions.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * chat-completions command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -25,162 +24,197 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search chat-completions \n\nPerforms a chat completion request against an AI Search instance, using indexed content as context for generating responses." - ) - .positional("instance-id", { - type: "string", - description: "AI Search instance ID.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Namespace to use for this operation.", +const command = apiCommand({ + command: "chat-completions ", + describe: "Chat Completions", + usage: + "$0 ai-search chat-completions \n\nPerforms a chat completion request against an AI Search instance, using indexed content as context for generating responses.", + flags: { + namespace: { + kind: "parsed", + brief: "Namespace to use for this operation.", default: "default", - }) - .option("ai-search-options-cache-cache-threshold", { - type: "string", - description: "The ai_search_options.cache.cache_threshold field", + parse: String, + }, + "ai-search-options-cache-cache-threshold": { + kind: "parsed", + brief: "The ai_search_options.cache.cache_threshold field", + optional: true, choices: [ "super_strict_match", "close_enough", "flexible_friend", "anything_goes", ], - }) - .coerce("ai-search-options-cache-cache-threshold", (value) => - resolveFileToken(value, "ai-search-options-cache-cache-threshold", "text") - ) - .option("ai-search-options-cache-enabled", { - type: "boolean", - description: "The ai_search_options.cache.enabled field", - }) - .option("ai-search-options-custom-metadata", { - type: "string", - description: + parse: String, + coerce: (value: string) => + resolveFileToken( + value, + "ai-search-options-cache-cache-threshold", + "text" + ), + }, + "ai-search-options-cache-enabled": { + kind: "boolean", + brief: "The ai_search_options.cache.enabled field", + optional: true, + }, + "ai-search-options-custom-metadata": { + kind: "parsed", + brief: "Metadata added to AI Gateway logs for requests this operation triggers. Accepts up to 2 string, number, or boolean entries. Reserved keys: 'ai-search', 'task', 'origin', and any key beginning with 'cf.'. Provide as a JSON object or @path/to/file.json. Shape: {\"\": (string | number | boolean)}.", - }) - .option("ai-search-options-query-rewrite-enabled", { - type: "boolean", - description: "The ai_search_options.query_rewrite.enabled field", - }) - .option("ai-search-options-query-rewrite-model", { - type: "string", - description: + optional: true, + parse: String, + }, + "ai-search-options-query-rewrite-enabled": { + kind: "boolean", + brief: "The ai_search_options.query_rewrite.enabled field", + optional: true, + }, + "ai-search-options-query-rewrite-model": { + kind: "parsed", + brief: "A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.", - }) - .option("ai-search-options-query-rewrite-rewrite-prompt", { - type: "string", - description: "The ai_search_options.query_rewrite.rewrite_prompt field", - }) - .option("ai-search-options-reranking-enabled", { - type: "boolean", - description: "The ai_search_options.reranking.enabled field", - }) - .option("ai-search-options-reranking-match-threshold", { - type: "number", - description: + optional: true, + parse: String, + }, + "ai-search-options-query-rewrite-rewrite-prompt": { + kind: "parsed", + brief: "The ai_search_options.query_rewrite.rewrite_prompt field", + optional: true, + parse: String, + }, + "ai-search-options-reranking-enabled": { + kind: "boolean", + brief: "The ai_search_options.reranking.enabled field", + optional: true, + }, + "ai-search-options-reranking-match-threshold": { + kind: "parsed", + brief: "Minimum reranker relevance score a chunk must reach to be returned. When omitted, falls back to the instance-level score_threshold, then to 0.4.", - }) - .option("ai-search-options-reranking-model", { - type: "string", - description: "The ai_search_options.reranking.model field", - }) - .option("ai-search-options-retrieval-boost-by", { - type: "string", - description: + optional: true, + parse: Number, + }, + "ai-search-options-reranking-model": { + kind: "parsed", + brief: "The ai_search_options.reranking.model field", + optional: true, + parse: String, + }, + "ai-search-options-retrieval-boost-by": { + kind: "parsed", + brief: 'Metadata fields to boost search results by. Overrides the instance-level boost_by config. Direction defaults to \'asc\' for numeric/datetime fields, \'exists\' for text/boolean fields. Fields must match \'timestamp\' or a defined custom_metadata field. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"field": string, "direction"?: "asc" | "desc" | "exists" | ...more}]. ? marks optional keys.', - }) - .option("ai-search-options-retrieval-context-expansion", { - type: "number", - description: "The ai_search_options.retrieval.context_expansion field", - }) - .option("ai-search-options-retrieval-filters", { - type: "string", - description: + optional: true, + parse: String, + }, + "ai-search-options-retrieval-context-expansion": { + kind: "parsed", + brief: "The ai_search_options.retrieval.context_expansion field", + optional: true, + parse: Number, + }, + "ai-search-options-retrieval-filters": { + kind: "parsed", + brief: 'The ai_search_options.retrieval.filters field. Provide as a JSON object or @path/to/file.json. Shape: {"": unknown}.', - }) - .option("ai-search-options-retrieval-fusion-method", { - type: "string", - description: "The ai_search_options.retrieval.fusion_method field", + optional: true, + parse: String, + }, + "ai-search-options-retrieval-fusion-method": { + kind: "parsed", + brief: "The ai_search_options.retrieval.fusion_method field", + optional: true, choices: ["max", "rrf"], - }) - .coerce("ai-search-options-retrieval-fusion-method", (value) => - resolveFileToken( - value, - "ai-search-options-retrieval-fusion-method", - "text" - ) - ) - .option("ai-search-options-retrieval-keyword-match-mode", { - type: "string", - description: + parse: String, + coerce: (value: string) => + resolveFileToken( + value, + "ai-search-options-retrieval-fusion-method", + "text" + ), + }, + "ai-search-options-retrieval-keyword-match-mode": { + kind: "parsed", + brief: "Controls which documents become candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term and ranks results according to BM25 relevance. When omitted, falls back to the instance-level retrieval_options.keyword_match_mode, then to 'and'.", + optional: true, choices: ["and", "or"], - }) - .coerce("ai-search-options-retrieval-keyword-match-mode", (value) => - resolveFileToken( - value, - "ai-search-options-retrieval-keyword-match-mode", - "text" - ) - ) - .option("ai-search-options-retrieval-match-threshold", { - type: "number", - description: + parse: String, + coerce: (value: string) => + resolveFileToken( + value, + "ai-search-options-retrieval-keyword-match-mode", + "text" + ), + }, + "ai-search-options-retrieval-match-threshold": { + kind: "parsed", + brief: "Minimum similarity score a chunk must reach to be returned. When omitted, falls back to the instance-level score_threshold, then to 0.4.", - }) - .option("ai-search-options-retrieval-max-num-results", { - type: "number", - description: + optional: true, + parse: Number, + }, + "ai-search-options-retrieval-max-num-results": { + kind: "parsed", + brief: "Maximum number of results to return. When omitted, falls back to the instance-level max_num_results, then to 10.", - }) - .option("ai-search-options-retrieval-retrieval-type", { - type: "string", - description: "The ai_search_options.retrieval.retrieval_type field", + optional: true, + parse: Number, + }, + "ai-search-options-retrieval-retrieval-type": { + kind: "parsed", + brief: "The ai_search_options.retrieval.retrieval_type field", + optional: true, choices: ["vector", "keyword", "hybrid"], - }) - .coerce("ai-search-options-retrieval-retrieval-type", (value) => - resolveFileToken( - value, - "ai-search-options-retrieval-retrieval-type", - "text" - ) - ) - .option("ai-search-options-retrieval-return-on-failure", { - type: "boolean", - description: "The ai_search_options.retrieval.return_on_failure field", - }) - .option("messages", { - type: "string", - description: + parse: String, + coerce: (value: string) => + resolveFileToken( + value, + "ai-search-options-retrieval-retrieval-type", + "text" + ), + }, + "ai-search-options-retrieval-return-on-failure": { + kind: "boolean", + brief: "The ai_search_options.retrieval.return_on_failure field", + optional: true, + }, + messages: { + kind: "parsed", + brief: 'The messages field. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"content": (string | [{...}] | null), "role": "system" | "developer" | "user" | ...more, "": unknown}].', - }) - .option("model", { - type: "string", - description: + optional: true, + parse: String, + }, + model: { + kind: "parsed", + brief: "A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.", - }) - .option("stream", { type: "boolean", description: "The stream field" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + stream: { kind: "boolean", brief: "The stream field", optional: true }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "chat-completions ", - describe: "Chat Completions", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "instance-id", + brief: "AI Search instance ID.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -198,7 +232,7 @@ const command: CommandModule = { "stream", "dry-run", ], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -504,6 +538,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/create.ts b/packages/cli/src/commands/_generated/ai-search/create.ts index e53e46caa6..219f04b4a1 100644 --- a/packages/cli/src/commands/_generated/ai-search/create.ts +++ b/packages/cli/src/commands/_generated/ai-search/create.ts @@ -1,11 +1,10 @@ import operation from "../_operations/ai-search/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -25,376 +24,461 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search create \n\nCreate a new AI Search instance with the given configuration. If type is omitted or null, a non-blank HTTP(S) source infers web-crawler and any other source infers r2; r2 sources must name an existing bucket. A missing or blank source without a type creates a managed upload-only instance." - ) - .positional("id", { - type: "string", - description: "Unique ID for the new AI Search instance.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Namespace to use for this operation.", +const command = apiCommand({ + command: "create ", + describe: "Create an AI Search instance.", + usage: + "$0 ai-search create \n\nCreate a new AI Search instance with the given configuration. If type is omitted or null, a non-blank HTTP(S) source infers web-crawler and any other source infers r2; r2 sources must name an existing bucket. A missing or blank source without a type creates a managed upload-only instance.", + flags: { + namespace: { + kind: "parsed", + brief: "Namespace to use for this operation.", default: "default", - }) - .option("ai-gateway-id", { - type: "string", - description: "The ai_gateway_id field", - }) - .option("ai-search-model", { - type: "string", - description: + parse: String, + }, + "ai-gateway-id": { + kind: "parsed", + brief: "The ai_gateway_id field", + optional: true, + parse: String, + }, + "ai-search-model": { + kind: "parsed", + brief: "A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.", - }) - .option("cache", { - type: "boolean", - description: "The cache field", - default: true, - }) - .option("cache-threshold", { - type: "string", - description: "The cache_threshold field", + optional: true, + parse: String, + }, + cache: { kind: "boolean", brief: "The cache field", default: true }, + "cache-threshold": { + kind: "parsed", + brief: "The cache_threshold field", + default: "close_enough", choices: [ "super_strict_match", "close_enough", "flexible_friend", "anything_goes", ], - default: "close_enough", - }) - .coerce("cache-threshold", (value) => - resolveFileToken(value, "cache-threshold", "text") - ) - .option("cache-ttl", { - type: "number", - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "cache-threshold", "text"), + }, + "cache-ttl": { + kind: "parsed", + brief: "Cache entry TTL in seconds. Allowed values: 600 (10min), 1800 (30min), 3600 (1h), 7200 (2h), 21600 (6h), 43200 (12h), 86400 (24h), 172800 (48h), 259200 (72h), 518400 (6d).", - default: 172800, - }) - .option("chunk", { - type: "boolean", - description: "The chunk field", - default: true, - }) - .option("chunk-overlap", { - type: "number", - description: "The chunk_overlap field", - default: 10, - }) - .option("chunk-size", { - type: "number", - description: "The chunk_size field", - }) - .option("custom-metadata", { - type: "string", - description: + default: "172800", + parse: Number, + }, + chunk: { kind: "boolean", brief: "The chunk field", default: true }, + "chunk-overlap": { + kind: "parsed", + brief: "The chunk_overlap field", + default: "10", + parse: Number, + }, + "chunk-size": { + kind: "parsed", + brief: "The chunk_size field", + optional: true, + parse: Number, + }, + "custom-metadata": { + kind: "parsed", + brief: 'The custom_metadata field. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"data_type": "text" | "number" | "boolean" | ...more, "field_name": string}].', - }) - .option("embedding-model", { - type: "string", - description: "The embedding_model field", - }) - .option("fusion-method", { - type: "string", - description: "The fusion_method field", - choices: ["max", "rrf"], + optional: true, + parse: String, + }, + "embedding-model": { + kind: "parsed", + brief: "The embedding_model field", + optional: true, + parse: String, + }, + "fusion-method": { + kind: "parsed", + brief: "The fusion_method field", default: "rrf", - }) - .coerce("fusion-method", (value) => - resolveFileToken(value, "fusion-method", "text") - ) - .option("hybrid-search-enabled", { - type: "boolean", - description: + choices: ["max", "rrf"], + parse: String, + coerce: (value: string) => + resolveFileToken(value, "fusion-method", "text"), + }, + "hybrid-search-enabled": { + kind: "boolean", + brief: "Deprecated — use index_method instead. Defaults to true for new instances; set false to create a vector-only instance.", - }) - .option("index-method-keyword", { - type: "boolean", - description: "Enable keyword (BM25) storage backend.", - }) - .option("index-method-vector", { - type: "boolean", - description: "Enable vector (embedding) storage backend.", - }) - .option("indexing-options-file-summary", { - type: "boolean", - description: + optional: true, + }, + "index-method-keyword": { + kind: "boolean", + brief: "Enable keyword (BM25) storage backend.", + optional: true, + }, + "index-method-vector": { + kind: "boolean", + brief: "Enable vector (embedding) storage backend.", + optional: true, + }, + "indexing-options-file-summary": { + kind: "boolean", + brief: "Generates a per-file summary, topics, and keywords during indexing for text files and media transcripts of at least three chunks. The summary and keywords are stored as the item's context metadata (a context you set is kept), and the topics are added to chunk context headers where they fit. Best effort: a file whose summary fails is indexed without one. The model calls are billed to your account through the instance's AI Gateway. Changing this triggers a full re-index. Defaults to false.", - }) - .option("indexing-options-keyword-tokenizer", { - type: "string", - description: + optional: true, + }, + "indexing-options-keyword-tokenizer": { + kind: "parsed", + brief: "Tokenizer used for keyword search indexing. porter provides word-level tokenization with Porter stemming (good for natural language queries). trigram enables character-level substring matching (good for partial matches, code, identifiers). Changing this triggers a full re-index. Defaults to porter.", + optional: true, choices: ["porter", "trigram"], - }) - .coerce("indexing-options-keyword-tokenizer", (value) => - resolveFileToken(value, "indexing-options-keyword-tokenizer", "text") - ) - .option("indexing-options-use-ocr", { - type: "boolean", - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "indexing-options-keyword-tokenizer", "text"), + }, + "indexing-options-use-ocr": { + kind: "boolean", + brief: "Enables OCR ingestion for PDFs and images. Changing this triggers a full re-index. Defaults to false.", - }) - .option("max-num-results", { - type: "number", - description: "The max_num_results field", - default: 10, - }) - .option("metadata-created-from-aisearch-wizard", { - type: "boolean", - description: "The metadata.created_from_aisearch_wizard field", - }) - .option("metadata-created-from-emdash-plugin-type", { - type: "string", - description: "The metadata.created_from_emdash_plugin.type field", + optional: true, + }, + "max-num-results": { + kind: "parsed", + brief: "The max_num_results field", + default: "10", + parse: Number, + }, + "metadata-created-from-aisearch-wizard": { + kind: "boolean", + brief: "The metadata.created_from_aisearch_wizard field", + optional: true, + }, + "metadata-created-from-emdash-plugin-type": { + kind: "parsed", + brief: "The metadata.created_from_emdash_plugin.type field", + optional: true, choices: ["native", "rest"], - }) - .coerce("metadata-created-from-emdash-plugin-type", (value) => - resolveFileToken( - value, - "metadata-created-from-emdash-plugin-type", - "text" - ) - ) - .option("metadata-created-from-emdash-plugin-version", { - type: "string", - description: "The metadata.created_from_emdash_plugin.version field", - }) - .option("metadata-worker-domain", { - type: "string", - description: "The metadata.worker_domain field", - }) - .option("public-endpoint-params-authorized-hosts", { - type: "string", - array: true, - description: "The public_endpoint_params.authorized_hosts field", - }) - .option("public-endpoint-params-chat-completions-endpoint-disabled", { - type: "boolean", - description: - "Disable chat completions endpoint for this public endpoint.", - }) - .option("public-endpoint-params-custom-domains", { - type: "string", - array: true, - description: + parse: String, + coerce: (value: string) => + resolveFileToken( + value, + "metadata-created-from-emdash-plugin-type", + "text" + ), + }, + "metadata-created-from-emdash-plugin-version": { + kind: "parsed", + brief: "The metadata.created_from_emdash_plugin.version field", + optional: true, + parse: String, + }, + "metadata-worker-domain": { + kind: "parsed", + brief: "The metadata.worker_domain field", + optional: true, + parse: String, + }, + "public-endpoint-params-authorized-hosts": { + kind: "parsed", + brief: "The public_endpoint_params.authorized_hosts field", + variadic: true, + optional: true, + parse: String, + }, + "public-endpoint-params-chat-completions-endpoint-disabled": { + kind: "boolean", + brief: "Disable chat completions endpoint for this public endpoint.", + optional: true, + }, + "public-endpoint-params-custom-domains": { + kind: "parsed", + brief: "Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged).", - }) - .option("public-endpoint-params-default-domain-enabled", { - type: "boolean", - description: + variadic: true, + optional: true, + parse: String, + }, + "public-endpoint-params-default-domain-enabled": { + kind: "boolean", + brief: "When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true.", - }) - .option("public-endpoint-params-enabled", { - type: "boolean", - description: "The public_endpoint_params.enabled field", - }) - .option("public-endpoint-params-mcp-description", { - type: "string", - description: "The public_endpoint_params.mcp.description field", - }) - .option("public-endpoint-params-mcp-disabled", { - type: "boolean", - description: "Disable MCP endpoint for this public endpoint.", - }) - .option("public-endpoint-params-rate-limit-period-ms", { - type: "number", - description: "The public_endpoint_params.rate_limit.period_ms field", - }) - .option("public-endpoint-params-rate-limit-requests", { - type: "number", - description: "The public_endpoint_params.rate_limit.requests field", - }) - .option("public-endpoint-params-rate-limit-technique", { - type: "string", - description: "The public_endpoint_params.rate_limit.technique field", + optional: true, + }, + "public-endpoint-params-enabled": { + kind: "boolean", + brief: "The public_endpoint_params.enabled field", + optional: true, + }, + "public-endpoint-params-mcp-description": { + kind: "parsed", + brief: "The public_endpoint_params.mcp.description field", + optional: true, + parse: String, + }, + "public-endpoint-params-mcp-disabled": { + kind: "boolean", + brief: "Disable MCP endpoint for this public endpoint.", + optional: true, + }, + "public-endpoint-params-rate-limit-period-ms": { + kind: "parsed", + brief: "The public_endpoint_params.rate_limit.period_ms field", + optional: true, + parse: Number, + }, + "public-endpoint-params-rate-limit-requests": { + kind: "parsed", + brief: "The public_endpoint_params.rate_limit.requests field", + optional: true, + parse: Number, + }, + "public-endpoint-params-rate-limit-technique": { + kind: "parsed", + brief: "The public_endpoint_params.rate_limit.technique field", + optional: true, choices: ["fixed", "sliding"], - }) - .coerce("public-endpoint-params-rate-limit-technique", (value) => - resolveFileToken( - value, - "public-endpoint-params-rate-limit-technique", - "text" - ) - ) - .option("public-endpoint-params-search-endpoint-disabled", { - type: "boolean", - description: "Disable search endpoint for this public endpoint.", - }) - .option("reranking", { - type: "boolean", - description: "The reranking field", + parse: String, + coerce: (value: string) => + resolveFileToken( + value, + "public-endpoint-params-rate-limit-technique", + "text" + ), + }, + "public-endpoint-params-search-endpoint-disabled": { + kind: "boolean", + brief: "Disable search endpoint for this public endpoint.", + optional: true, + }, + reranking: { + kind: "boolean", + brief: "The reranking field", default: false, - }) - .option("reranking-model", { - type: "string", - description: "The reranking_model field", - }) - .option("retrieval-options-boost-by", { - type: "string", - description: + }, + "reranking-model": { + kind: "parsed", + brief: "The reranking_model field", + optional: true, + parse: String, + }, + "retrieval-options-boost-by": { + kind: "parsed", + brief: 'Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to \'asc\' for numeric/datetime fields and \'exists\' for text/boolean fields. Fields must match \'timestamp\' or a defined custom_metadata field. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"field": string, "direction"?: "asc" | "desc" | "exists" | ...more}]. ? marks optional keys.', - }) - .option("retrieval-options-keyword-match-mode", { - type: "string", - description: + optional: true, + parse: String, + }, + "retrieval-options-keyword-match-mode": { + kind: "parsed", + brief: "Controls which documents become candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term and ranks results according to BM25 relevance. When omitted on an update, the existing stored value stays unchanged; when never set, search falls back to 'and'.", + optional: true, choices: ["and", "or"], - }) - .coerce("retrieval-options-keyword-match-mode", (value) => - resolveFileToken(value, "retrieval-options-keyword-match-mode", "text") - ) - .option("rewrite-model", { - type: "string", - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "retrieval-options-keyword-match-mode", "text"), + }, + "rewrite-model": { + kind: "parsed", + brief: "A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.", - }) - .option("rewrite-query", { - type: "boolean", - description: "The rewrite_query field", + optional: true, + parse: String, + }, + "rewrite-query": { + kind: "boolean", + brief: "The rewrite_query field", default: false, - }) - .option("score-threshold", { - type: "number", - description: + }, + "score-threshold": { + kind: "parsed", + brief: "Minimum similarity score a chunk must reach to be returned. Defaults to 0.4.", - }) - .option("source", { - type: "string", - description: + optional: true, + parse: Number, + }, + source: { + kind: "parsed", + brief: "R2 bucket name or HTTP(S) root website URL to index. When type is omitted, the source determines it.", - }) - .option("source-params-d1-query", { - type: "string", - description: + optional: true, + parse: String, + }, + "source-params-d1-query": { + kind: "parsed", + brief: "Read-only SELECT query run against the D1 database. It must return an `id` column that uniquely identifies each row. Columns named `title` and `content` set the document title and body, and up to 5 `meta_*` columns become filterable custom metadata; any other column is indexed as a labelled field. Every sync reads the full result, up to 100,000 rows, with the instance's token, and those reads count against your D1 usage. Leading and trailing whitespace is trimmed before the query is stored.", - }) - .option("source-params-d1-template", { - type: "string", - description: + optional: true, + parse: String, + }, + "source-params-d1-template": { + kind: "parsed", + brief: "How each row is rendered into the indexed document: labelled renders the title, the labelled fields, then the content; content_only renders the title and content (labelled fields only when there is no content); key_value renders every column as name: value; json renders every column as a JSON object.", + optional: true, choices: ["labelled", "content_only", "key_value", "json"], - }) - .coerce("source-params-d1-template", (value) => - resolveFileToken(value, "source-params-d1-template", "text") - ) - .option("source-params-exclude-items", { - type: "string", - array: true, - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "source-params-d1-template", "text"), + }, + "source-params-exclude-items": { + kind: "parsed", + brief: "List of path patterns to exclude. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /admin/** matches /admin/users and /admin/settings/advanced). Most accounts have a limit of 10 rules; contact support to raise it.", - }) - .option("source-params-include-items", { - type: "string", - array: true, - description: + variadic: true, + optional: true, + parse: String, + }, + "source-params-include-items": { + kind: "parsed", + brief: "List of path patterns to include. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /blog/** matches /blog/post and /blog/2024/post). Most accounts have a limit of 10 rules; contact support to raise it.", - }) - .option("source-params-prefix", { - type: "string", - description: "The source_params.prefix field", - }) - .option("source-params-r2-jurisdiction", { - type: "string", - description: "The source_params.r2_jurisdiction field", - }) - .option("source-params-web-crawler-discover-options-depth", { - type: "number", - description: "Maximum link-follow depth from the seed URL.", - }) - .option( - "source-params-web-crawler-discover-options-include-external-links", - { - type: "boolean", - description: - "Follow links that point outside the source domain. Must stay `false` because discover crawls only cover the zone you own.", - } - ) - .option("source-params-web-crawler-discover-options-include-subdomains", { - type: "boolean", - description: "Follow links to subdomains of the source host.", - }) - .option("source-params-web-crawler-discover-options-limit", { - type: "number", - description: "Maximum number of pages to crawl (1-100000).", - }) - .option("source-params-web-crawler-discover-options-max-age", { - type: "number", - description: "Maximum content age in seconds to accept (0–604800).", - }) - .option("source-params-web-crawler-discover-options-source", { - type: "string", - description: + variadic: true, + optional: true, + parse: String, + }, + "source-params-prefix": { + kind: "parsed", + brief: "The source_params.prefix field", + optional: true, + parse: String, + }, + "source-params-r2-jurisdiction": { + kind: "parsed", + brief: "The source_params.r2_jurisdiction field", + optional: true, + parse: String, + }, + "source-params-web-crawler-discover-options-depth": { + kind: "parsed", + brief: "Maximum link-follow depth from the seed URL.", + optional: true, + parse: Number, + }, + "source-params-web-crawler-discover-options-include-external-links": { + kind: "boolean", + brief: + "Follow links that point outside the source domain. Must stay `false` because discover crawls only cover the zone you own.", + optional: true, + }, + "source-params-web-crawler-discover-options-include-subdomains": { + kind: "boolean", + brief: "Follow links to subdomains of the source host.", + optional: true, + }, + "source-params-web-crawler-discover-options-limit": { + kind: "parsed", + brief: "Maximum number of pages to crawl (1-100000).", + optional: true, + parse: Number, + }, + "source-params-web-crawler-discover-options-max-age": { + kind: "parsed", + brief: "Maximum content age in seconds to accept (0–604800).", + optional: true, + parse: Number, + }, + "source-params-web-crawler-discover-options-source": { + kind: "parsed", + brief: "Where the crawler looks for URLs: 'sitemaps' reads sitemap XML only, 'links' follows page links only, 'all' does both.", + optional: true, choices: ["all", "sitemaps", "links"], - }) - .coerce("source-params-web-crawler-discover-options-source", (value) => - resolveFileToken( - value, - "source-params-web-crawler-discover-options-source", - "text" - ) - ) - .option("source-params-web-crawler-parse-options-content-selector", { - type: "string", - description: + parse: String, + coerce: (value: string) => + resolveFileToken( + value, + "source-params-web-crawler-discover-options-source", + "text" + ), + }, + "source-params-web-crawler-parse-options-content-selector": { + kind: "parsed", + brief: 'List of path-to-selector mappings for extracting specific content from crawled pages. Each entry pairs a URL glob pattern with a CSS selector. The first matching path wins. The crawler stores and indexes only the matched HTML fragment. Omit the field to disable content selection; the API rejects empty arrays. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"path": string, "selector": string}].', - }) - .option("source-params-web-crawler-parse-options-include-headers", { - type: "string", - description: + optional: true, + parse: String, + }, + "source-params-web-crawler-parse-options-include-headers": { + kind: "parsed", + brief: 'Up to 5 custom HTTP headers sent with each crawl request. Names must use RFC-7230 token characters, excluding spaces, colons, and control characters. Values must use HTAB and printable ASCII only, excluding CR and LF. Provide as a JSON object or @path/to/file.json. Shape: {"": string}.', - }) - .option("source-params-web-crawler-parse-options-include-images", { - type: "boolean", - description: - "The source_params.web_crawler.parse_options.include_images field", - }) - .option("source-params-web-crawler-parse-options-specific-sitemaps", { - type: "string", - array: true, - description: + optional: true, + parse: String, + }, + "source-params-web-crawler-parse-options-include-images": { + kind: "boolean", + brief: "The source_params.web_crawler.parse_options.include_images field", + optional: true, + }, + "source-params-web-crawler-parse-options-specific-sitemaps": { + kind: "parsed", + brief: "List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'.", - }) - .option("source-params-web-crawler-parse-options-use-browser-rendering", { - type: "boolean", - description: + variadic: true, + optional: true, + parse: String, + }, + "source-params-web-crawler-parse-options-use-browser-rendering": { + kind: "boolean", + brief: "The source_params.web_crawler.parse_options.use_browser_rendering field", - }) - .option("source-params-web-crawler-parse-type", { - type: "string", - description: + optional: true, + }, + "source-params-web-crawler-parse-type": { + kind: "parsed", + brief: "How the crawler finds URLs. 'sitemap' reads XML sitemaps; 'discover' follows links recursively and requires the source to belong to a Verified zone on this account.", + optional: true, choices: ["sitemap", "discover"], - }) - .coerce("source-params-web-crawler-parse-type", (value) => - resolveFileToken(value, "source-params-web-crawler-parse-type", "text") - ) - .option("sync-interval", { - type: "number", - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "source-params-web-crawler-parse-type", "text"), + }, + "sync-interval": { + kind: "parsed", + brief: "Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). Defaults to 86400 (24h).", - }) - .option("token-id", { type: "string", description: "The token_id field" }) - .option("type", { - type: "string", - description: "Data source type: r2 or web-crawler.", + optional: true, + parse: Number, + }, + "token-id": { + kind: "parsed", + brief: "The token_id field", + optional: true, + parse: String, + }, + type: { + kind: "parsed", + brief: "Data source type: r2 or web-crawler.", + optional: true, choices: ["r2", "web-crawler", "d1"], - }) - .coerce("type", (value) => resolveFileToken(value, "type", "text")) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + parse: String, + coerce: (value: string) => resolveFileToken(value, "type", "text"), + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }) - .check((argv) => { + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "id", + brief: "Unique ID for the new AI Search instance.", + parse: String, + }, + ], + rules(rules) { + rules.check((argv) => { const groupSet = ["index-method-keyword", "index-method-vector"].some( (k) => argv[k] !== undefined ); @@ -409,8 +493,8 @@ function builder(yargs: Argv) { } } return true; - }) - .check((argv) => { + }); + rules.check((argv) => { const groupSet = [ "metadata-created-from-emdash-plugin-type", "metadata-created-from-emdash-plugin-version", @@ -427,8 +511,8 @@ function builder(yargs: Argv) { } } return true; - }) - .check((argv) => { + }); + rules.check((argv) => { const groupSet = [ "source-params-d1-query", "source-params-d1-template", @@ -445,14 +529,7 @@ function builder(yargs: Argv) { } return true; }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "create ", - describe: "Create an AI Search instance.", - builder, + }, handler: async (argv): Promise => runWithTelemetry( { @@ -490,7 +567,7 @@ const command: CommandModule = { "type", "dry-run", ], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -965,6 +1042,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/delete.ts b/packages/cli/src/commands/_generated/ai-search/delete.ts index fca78819cb..586cdbff34 100644 --- a/packages/cli/src/commands/_generated/ai-search/delete.ts +++ b/packages/cli/src/commands/_generated/ai-search/delete.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,40 +17,37 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search delete \n\nDeletes an AI Search instance and all its indexed data permanently." - ) - .positional("instance-id", { - type: "string", - description: "AI Search instance ID.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Namespace to use for this operation.", +const command = apiCommand({ + command: "delete ", + describe: "Delete an AI Search instance.", + usage: + "$0 ai-search delete \n\nDeletes an AI Search instance and all its indexed data permanently.", + flags: { + namespace: { + kind: "parsed", + brief: "Namespace to use for this operation.", default: "default", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete an AI Search instance.", - builder, + }, + }, + operands: [ + { + placeholder: "instance-id", + brief: "AI Search instance ID.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -59,7 +55,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -100,6 +96,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/get.ts b/packages/cli/src/commands/_generated/ai-search/get.ts index 4272016920..8dcc9c570c 100644 --- a/packages/cli/src/commands/_generated/ai-search/get.ts +++ b/packages/cli/src/commands/_generated/ai-search/get.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,41 +16,38 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search get \n\nRetrieve the configuration and status of an AI Search instance." - ) - .positional("instance-id", { - type: "string", - description: "AI Search instance ID.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Namespace to use for this operation.", - default: "default", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get an AI Search instance.", - builder, + usage: + "$0 ai-search get \n\nRetrieve the configuration and status of an AI Search instance.", + flags: { + namespace: { + kind: "parsed", + brief: "Namespace to use for this operation.", + default: "default", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "instance-id", + brief: "AI Search instance ID.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "ai-search get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -83,6 +79,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/index.ts b/packages/cli/src/commands/_generated/ai-search/index.ts index 3ad6770026..e31318e4c1 100644 --- a/packages/cli/src/commands/_generated/ai-search/index.ts +++ b/packages/cli/src/commands/_generated/ai-search/index.ts @@ -14,40 +14,35 @@ import $search from "./search.js"; import $stats from "./stats.js"; import $tokens from "./tokens/index.js"; import $update from "./update.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * ai-search command * @generated from apis/overlays/ai-search.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "ai-search", describe: "Managed search-as-a-service: crawl, index, and query content with AI-powered relevance and chat completions", - builder: (yargs) => { - return yargs - .command($chatcompletions) - .command($create) - .command($delete) - .command($get) - .command($list) - .command($move) - .command($multichatcompletions) - .command($multisearch) - .command($purgecache) - .command($search) - .command($stats) - .command($update) - .command($items) - .command($jobs) - .command($namespace) - .command($tokens) - .demandCommand(1, "Please specify a subcommand"); + routes: { + "chat-completions": $chatcompletions, + create: $create, + delete: $delete, + get: $get, + list: $list, + move: $move, + "multi-chat-completions": $multichatcompletions, + "multi-search": $multisearch, + "purge-cache": $purgecache, + search: $search, + stats: $stats, + update: $update, + items: $items, + jobs: $jobs, + namespace: $namespace, + tokens: $tokens, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/items/chunks.ts b/packages/cli/src/commands/_generated/ai-search/items/chunks.ts index a2c54bcead..25d6772451 100644 --- a/packages/cli/src/commands/_generated/ai-search/items/chunks.ts +++ b/packages/cli/src/commands/_generated/ai-search/items/chunks.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * chunks command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,48 +16,41 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search items chunks \n\nLists chunks for a specific item in an AI Search instance, including their text content." - ) - .positional("item-id", { - type: "string", - description: "Indexed item ID.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Namespace to use for this operation.", - default: "default", - }) - .option("instance-id", { - type: "string", - description: "AI Search instance ID.", - demandOption: true, - }) - .option("limit", { type: "number", description: "Limit" }) - .option("offset", { type: "number", description: "Offset" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "chunks ", describe: "List Item Chunks.", - builder, + usage: + "$0 ai-search items chunks \n\nLists chunks for a specific item in an AI Search instance, including their text content.", + flags: { + namespace: { + kind: "parsed", + brief: "Namespace to use for this operation.", + default: "default", + parse: String, + }, + "instance-id": { + kind: "parsed", + brief: "AI Search instance ID.", + parse: String, + }, + limit: { kind: "parsed", brief: "Limit", optional: true, parse: Number }, + offset: { kind: "parsed", brief: "Offset", optional: true, parse: Number }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { placeholder: "item-id", brief: "Indexed item ID.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "ai-search items chunks", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -97,6 +89,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/items/delete.ts b/packages/cli/src/commands/_generated/ai-search/items/delete.ts index 408287f04c..0c78be7f4d 100644 --- a/packages/cli/src/commands/_generated/ai-search/items/delete.ts +++ b/packages/cli/src/commands/_generated/ai-search/items/delete.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,45 +17,38 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search items delete \n\nDeletes a file from a managed AI Search instance and removes its indexed data." - ) - .positional("item-id", { - type: "string", - description: "Indexed item ID.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Namespace to use for this operation.", +const command = apiCommand({ + command: "delete ", + describe: "Delete Item.", + usage: + "$0 ai-search items delete \n\nDeletes a file from a managed AI Search instance and removes its indexed data.", + flags: { + namespace: { + kind: "parsed", + brief: "Namespace to use for this operation.", default: "default", - }) - .option("instance-id", { - type: "string", - description: "AI Search instance ID.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + parse: String, + }, + "instance-id": { + kind: "parsed", + brief: "AI Search instance ID.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete Item.", - builder, + }, + }, + operands: [ + { placeholder: "item-id", brief: "Indexed item ID.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -64,7 +56,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -101,6 +93,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/items/download.ts b/packages/cli/src/commands/_generated/ai-search/items/download.ts index 61cf146d24..cfb0db11d6 100644 --- a/packages/cli/src/commands/_generated/ai-search/items/download.ts +++ b/packages/cli/src/commands/_generated/ai-search/items/download.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * download command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,52 +16,45 @@ import { withProgress } from "#lib/progress.js"; import { fetchRawBytes, writeRawOutput } from "#lib/raw-fetch.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search items download \n\nDownloads the raw file content for a specific item from the managed AI Search instance storage." - ) - .positional("item-id", { - type: "string", - description: "Indexed item ID.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Namespace to use for this operation.", +const command = apiCommand({ + command: "download ", + describe: "Download Item Content.", + usage: + "$0 ai-search items download \n\nDownloads the raw file content for a specific item from the managed AI Search instance storage.", + flags: { + namespace: { + kind: "parsed", + brief: "Namespace to use for this operation.", default: "default", - }) - .option("instance-id", { - type: "string", - description: "AI Search instance ID.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + parse: String, + }, + "instance-id": { + kind: "parsed", + brief: "AI Search instance ID.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("text", { - type: "boolean", - description: + }, + text: { + kind: "boolean", + brief: "Decode the response body as UTF-8 text instead of writing raw bytes", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "download ", - describe: "Download Item Content.", - builder, + }, + }, + operands: [ + { placeholder: "item-id", brief: "Indexed item ID.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "ai-search items download", classification: { safeFlags: ["dry-run", "text"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -101,6 +93,6 @@ const command: CommandModule = { return; } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/items/get.ts b/packages/cli/src/commands/_generated/ai-search/items/get.ts index 3415d0bc4d..042073c280 100644 --- a/packages/cli/src/commands/_generated/ai-search/items/get.ts +++ b/packages/cli/src/commands/_generated/ai-search/items/get.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,46 +16,39 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search items get \n\nRetrieves a specific indexed item from an AI Search instance." - ) - .positional("item-id", { - type: "string", - description: "Indexed item ID.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Namespace to use for this operation.", - default: "default", - }) - .option("instance-id", { - type: "string", - description: "AI Search instance ID.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get Item.", - builder, + usage: + "$0 ai-search items get \n\nRetrieves a specific indexed item from an AI Search instance.", + flags: { + namespace: { + kind: "parsed", + brief: "Namespace to use for this operation.", + default: "default", + parse: String, + }, + "instance-id": { + kind: "parsed", + brief: "AI Search instance ID.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { placeholder: "item-id", brief: "Indexed item ID.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "ai-search items get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -89,6 +81,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/items/index.ts b/packages/cli/src/commands/_generated/ai-search/items/index.ts index 1f78164bba..3425f3f929 100644 --- a/packages/cli/src/commands/_generated/ai-search/items/index.ts +++ b/packages/cli/src/commands/_generated/ai-search/items/index.ts @@ -7,32 +7,27 @@ import $logs from "./logs.js"; import $sync from "./sync.js"; import $upload from "./upload.js"; import $upsert from "./upsert.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * items command group * @generated from apis/overlays/ai-search.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "items", describe: "Content indexed by AI Search instances", - builder: (yargs) => { - return yargs - .command($chunks) - .command($delete) - .command($download) - .command($get) - .command($list) - .command($logs) - .command($sync) - .command($upload) - .command($upsert) - .demandCommand(1, "Please specify a subcommand"); + routes: { + chunks: $chunks, + delete: $delete, + download: $download, + get: $get, + list: $list, + logs: $logs, + sync: $sync, + upload: $upload, + upsert: $upsert, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/items/list.ts b/packages/cli/src/commands/_generated/ai-search/items/list.ts index 75db14ddff..44b009a942 100644 --- a/packages/cli/src/commands/_generated/ai-search/items/list.ts +++ b/packages/cli/src/commands/_generated/ai-search/items/list.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,34 +16,42 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search items list\n\nLists indexed items in an AI Search instance." - ) - .option("namespace", { - type: "string", - description: "Namespace to use for this operation.", +const command = apiCommand({ + command: "list", + describe: "Items List.", + usage: + "$0 ai-search items list\n\nLists indexed items in an AI Search instance.", + flags: { + namespace: { + kind: "parsed", + brief: "Namespace to use for this operation.", default: "default", - }) - .option("instance-id", { - type: "string", - description: "AI Search instance ID.", - demandOption: true, - }) - .option("page", { type: "number", description: "Page" }) - .option("per-page", { type: "number", description: "Per page" }) - .option("search", { type: "string", description: "Search" }) - .option("sort-by", { - type: "string", - description: + parse: String, + }, + "instance-id": { + kind: "parsed", + brief: "AI Search instance ID.", + parse: String, + }, + page: { kind: "parsed", brief: "Page", optional: true, parse: Number }, + "per-page": { + kind: "parsed", + brief: "Per page", + optional: true, + parse: Number, + }, + search: { kind: "parsed", brief: "Search", optional: true, parse: String }, + "sort-by": { + kind: "enum", + brief: 'Sort order for items. "status" (default) sorts items according to status priority, then last_seen_at. "modified_at" sorts items according to file modification time (most recent first), falling back to created_at.', - choices: ["status", "modified_at"], - }) - .option("status", { - type: "string", - description: "Status", - choices: [ + values: ["status", "modified_at"], + optional: true, + }, + status: { + kind: "enum", + brief: "Status", + values: [ "queued", "running", "completed", @@ -52,47 +59,50 @@ function builder(yargs: Argv) { "skipped", "outdated", ], - }) - .option("source", { - type: "string", - description: + optional: true, + }, + source: { + kind: "parsed", + brief: 'Return only items with this source_id. Use "builtin" for uploaded files, or a source identifier like "web-crawler:https://example.com".', - }) - .option("metadata-filter", { - type: "string", - description: + optional: true, + parse: String, + }, + "metadata-filter": { + kind: "parsed", + brief: 'JSON-encoded metadata filter using Vectorize filter syntax. Examples: {"folder":"reports/"}, {"timestamp":{"$gte":1700000000000}}, {"folder":{"$in":["docs/","reports/"]}}.', - }) - .option("item-id", { - type: "string", - description: + optional: true, + parse: String, + }, + "item-id": { + kind: "parsed", + brief: "Return only the item with this unique ID. Returns at most one item.", - }) - .option("key", { - type: "string", - description: + optional: true, + parse: String, + }, + key: { + kind: "parsed", + brief: "Return only items with this exact key (object key / filename). Each key is unique within a source, so combine with `source` to disambiguate across data sources.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "list", - describe: "Items List.", - builder, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "ai-search items list", classification: { safeFlags: ["sort-by", "status", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -137,6 +147,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/items/logs.ts b/packages/cli/src/commands/_generated/ai-search/items/logs.ts index b9720c7b95..2234229c0a 100644 --- a/packages/cli/src/commands/_generated/ai-search/items/logs.ts +++ b/packages/cli/src/commands/_generated/ai-search/items/logs.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * logs command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,48 +16,41 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search items logs \n\nLists processing logs for a specific item in an AI Search instance." - ) - .positional("item-id", { - type: "string", - description: "Indexed item ID.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Namespace to use for this operation.", - default: "default", - }) - .option("instance-id", { - type: "string", - description: "AI Search instance ID.", - demandOption: true, - }) - .option("limit", { type: "number", description: "Limit" }) - .option("cursor", { type: "string", description: "Cursor" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "logs ", describe: "Item Logs.", - builder, + usage: + "$0 ai-search items logs \n\nLists processing logs for a specific item in an AI Search instance.", + flags: { + namespace: { + kind: "parsed", + brief: "Namespace to use for this operation.", + default: "default", + parse: String, + }, + "instance-id": { + kind: "parsed", + brief: "AI Search instance ID.", + parse: String, + }, + limit: { kind: "parsed", brief: "Limit", optional: true, parse: Number }, + cursor: { kind: "parsed", brief: "Cursor", optional: true, parse: String }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { placeholder: "item-id", brief: "Indexed item ID.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "ai-search items logs", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -97,6 +89,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/items/sync.ts b/packages/cli/src/commands/_generated/ai-search/items/sync.ts index 27aa13f285..05c4e6f2f9 100644 --- a/packages/cli/src/commands/_generated/ai-search/items/sync.ts +++ b/packages/cli/src/commands/_generated/ai-search/items/sync.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * sync command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,63 +19,59 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredEnumField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search items sync \n\nSynchronizes an item to an AI Search instance index." - ) - .positional("item-id", { - type: "string", - description: "Indexed item ID.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Namespace to use for this operation.", +const command = apiCommand({ + command: "sync ", + describe: "Sync Item.", + usage: + "$0 ai-search items sync \n\nSynchronizes an item to an AI Search instance index.", + flags: { + namespace: { + kind: "parsed", + brief: "Namespace to use for this operation.", default: "default", - }) - .option("instance-id", { - type: "string", - description: "AI Search instance ID.", - demandOption: true, - }) - .option("next-action", { - type: "string", - description: "The next_action field", + parse: String, + }, + "instance-id": { + kind: "parsed", + brief: "AI Search instance ID.", + parse: String, + }, + "next-action": { + kind: "parsed", + brief: "The next_action field", + optional: true, choices: ["INDEX"], - }) - .coerce("next-action", (value) => - resolveFileToken(value, "next-action", "text") - ) - .option("wait-for-completion", { - type: "boolean", - description: + parse: String, + coerce: (value: string) => resolveFileToken(value, "next-action", "text"), + }, + "wait-for-completion": { + kind: "boolean", + brief: "Wait for indexing before responding. After processing, vector-indexed instances use any time remaining in a 25s wait budget to confirm Vectorize ingestion. Processing itself continues uninterrupted and can exceed that budget. If confirmation times out, the response returns the current item state and background indexing continues. Defaults to false.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "sync ", - describe: "Sync Item.", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { placeholder: "item-id", brief: "Indexed item ID.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "ai-search items sync", classification: { safeFlags: ["next-action", "wait-for-completion", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -156,6 +151,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/items/upload.ts b/packages/cli/src/commands/_generated/ai-search/items/upload.ts index 9bd7b05134..ae3cebcac3 100644 --- a/packages/cli/src/commands/_generated/ai-search/items/upload.ts +++ b/packages/cli/src/commands/_generated/ai-search/items/upload.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * upload command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,58 +17,62 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search items upload \n\nUploads a file to a managed AI Search instance via multipart/form-data." - ) - .positional("instance-id", { - type: "string", - description: "AI Search instance ID.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Namespace to use for this operation.", +const command = apiCommand({ + command: "upload ", + describe: "Upload Item.", + usage: + "$0 ai-search items upload \n\nUploads a file to a managed AI Search instance via multipart/form-data.", + flags: { + namespace: { + kind: "parsed", + brief: "Namespace to use for this operation.", default: "default", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }) - .option("file", { - type: "string", - description: "Path to a file to upload as the request body", - }) - .option("metadata", { - type: "string", - description: "JSON string of custom metadata key-value pairs.", - }) - .option("wait-for-completion", { - type: "boolean", - description: + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + file: { + kind: "parsed", + brief: "Path to a file to upload as the request body", + optional: true, + parse: String, + }, + metadata: { + kind: "parsed", + brief: "JSON string of custom metadata key-value pairs.", + optional: true, + parse: String, + }, + "wait-for-completion": { + kind: "boolean", + brief: "Wait for indexing before responding. After processing, vector-indexed instances use any time remaining in a 25s wait budget to confirm Vectorize ingestion. Processing itself continues uninterrupted and can exceed that budget. If confirmation times out, the response returns the current item state and background indexing continues. Defaults to false.", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "upload ", - describe: "Upload Item.", - builder, + optional: true, + }, + }, + operands: [ + { + placeholder: "instance-id", + brief: "AI Search instance ID.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "ai-search items upload", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -172,6 +175,6 @@ const command: CommandModule = { } } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/items/upsert.ts b/packages/cli/src/commands/_generated/ai-search/items/upsert.ts index 4080438152..39d018d213 100644 --- a/packages/cli/src/commands/_generated/ai-search/items/upsert.ts +++ b/packages/cli/src/commands/_generated/ai-search/items/upsert.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * upsert command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -23,62 +22,64 @@ import { } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search items upsert \n\nCreates or updates an indexed item in an AI Search instance." - ) - .positional("instance-id", { - type: "string", - description: "AI Search instance ID.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Namespace to use for this operation.", +const command = apiCommand({ + command: "upsert ", + describe: "Create or Update Item.", + usage: + "$0 ai-search items upsert \n\nCreates or updates an indexed item in an AI Search instance.", + flags: { + namespace: { + kind: "parsed", + brief: "Namespace to use for this operation.", default: "default", - }) - .option("key", { - type: "string", - description: "Item key / filename. Must not exceed 128 characters.", - }) - .option("next-action", { - type: "string", - description: "The next_action field", + parse: String, + }, + key: { + kind: "parsed", + brief: "Item key / filename. Must not exceed 128 characters.", + optional: true, + parse: String, + }, + "next-action": { + kind: "parsed", + brief: "The next_action field", + optional: true, choices: ["INDEX"], - }) - .coerce("next-action", (value) => - resolveFileToken(value, "next-action", "text") - ) - .option("wait-for-completion", { - type: "boolean", - description: + parse: String, + coerce: (value: string) => resolveFileToken(value, "next-action", "text"), + }, + "wait-for-completion": { + kind: "boolean", + brief: "Wait for indexing before responding. After processing, vector-indexed instances use any time remaining in a 25s wait budget to confirm Vectorize ingestion. Processing itself continues uninterrupted and can exceed that budget. If confirmation times out, the response returns the current item state and background indexing continues. Defaults to false.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "upsert ", - describe: "Create or Update Item.", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "instance-id", + brief: "AI Search instance ID.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "ai-search items upsert", classification: { safeFlags: ["next-action", "wait-for-completion", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -174,6 +175,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/jobs/cancel.ts b/packages/cli/src/commands/_generated/ai-search/jobs/cancel.ts index 4e7989f281..106ef71326 100644 --- a/packages/cli/src/commands/_generated/ai-search/jobs/cancel.ts +++ b/packages/cli/src/commands/_generated/ai-search/jobs/cancel.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * cancel command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,55 +19,52 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete, promptForRequiredEnumField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search jobs cancel \n\nCancels an in-progress indexing job for an AI Search instance." - ) - .positional("job-id", { - type: "string", - description: "Indexing job ID.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Namespace to use for this operation.", +const command = apiCommand({ + command: "cancel ", + describe: "Cancel an indexing job.", + usage: + "$0 ai-search jobs cancel \n\nCancels an in-progress indexing job for an AI Search instance.", + flags: { + namespace: { + kind: "parsed", + brief: "Namespace to use for this operation.", default: "default", - }) - .option("instance-id", { - type: "string", - description: "AI Search instance ID.", - demandOption: true, - }) - .option("action", { - type: "string", - description: "The action field", + parse: String, + }, + "instance-id": { + kind: "parsed", + brief: "AI Search instance ID.", + parse: String, + }, + action: { + kind: "parsed", + brief: "The action field", + optional: true, choices: ["cancel"], - }) - .coerce("action", (value) => resolveFileToken(value, "action", "text")) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + parse: String, + coerce: (value: string) => resolveFileToken(value, "action", "text"), + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "cancel ", - describe: "Cancel an indexing job.", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { placeholder: "job-id", brief: "Indexing job ID.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -76,7 +72,7 @@ const command: CommandModule = { classification: { safeFlags: ["action", "dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -158,6 +154,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/jobs/create.ts b/packages/cli/src/commands/_generated/ai-search/jobs/create.ts index f184b16464..7b1cfdf419 100644 --- a/packages/cli/src/commands/_generated/ai-search/jobs/create.ts +++ b/packages/cli/src/commands/_generated/ai-search/jobs/create.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,49 +18,50 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search jobs create \n\nCreates a new indexing job for an AI Search instance." - ) - .positional("instance-id", { - type: "string", - description: "AI Search instance ID.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Namespace to use for this operation.", - default: "default", - }) - .option("description", { - type: "string", - description: "Optional description for the indexing job.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create ", describe: "Create new job", - builder, + usage: + "$0 ai-search jobs create \n\nCreates a new indexing job for an AI Search instance.", + flags: { + namespace: { + kind: "parsed", + brief: "Namespace to use for this operation.", + default: "default", + parse: String, + }, + description: { + kind: "parsed", + brief: "Optional description for the indexing job.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "instance-id", + brief: "AI Search instance ID.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "ai-search jobs create", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -132,6 +132,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/jobs/get.ts b/packages/cli/src/commands/_generated/ai-search/jobs/get.ts index 85ce386124..39c473edee 100644 --- a/packages/cli/src/commands/_generated/ai-search/jobs/get.ts +++ b/packages/cli/src/commands/_generated/ai-search/jobs/get.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,46 +16,39 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search jobs get \n\nRetrieves details for a specific AI Search indexing job." - ) - .positional("job-id", { - type: "string", - description: "Indexing job ID.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Namespace to use for this operation.", - default: "default", - }) - .option("instance-id", { - type: "string", - description: "AI Search instance ID.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get a Job Details", - builder, + usage: + "$0 ai-search jobs get \n\nRetrieves details for a specific AI Search indexing job.", + flags: { + namespace: { + kind: "parsed", + brief: "Namespace to use for this operation.", + default: "default", + parse: String, + }, + "instance-id": { + kind: "parsed", + brief: "AI Search instance ID.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { placeholder: "job-id", brief: "Indexing job ID.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "ai-search jobs get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -89,6 +81,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/jobs/index.ts b/packages/cli/src/commands/_generated/ai-search/jobs/index.ts index 9ac1b90caf..71899a1d14 100644 --- a/packages/cli/src/commands/_generated/ai-search/jobs/index.ts +++ b/packages/cli/src/commands/_generated/ai-search/jobs/index.ts @@ -3,28 +3,23 @@ import $create from "./create.js"; import $get from "./get.js"; import $list from "./list.js"; import $logs from "./logs.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * jobs command group * @generated from apis/overlays/ai-search.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "jobs", describe: "Indexing job lifecycle for AI Search instances", - builder: (yargs) => { - return yargs - .command($cancel) - .command($create) - .command($get) - .command($list) - .command($logs) - .demandCommand(1, "Please specify a subcommand"); + routes: { + cancel: $cancel, + create: $create, + get: $get, + list: $list, + logs: $logs, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/jobs/list.ts b/packages/cli/src/commands/_generated/ai-search/jobs/list.ts index b039dfdb0f..7c0c30e6ca 100644 --- a/packages/cli/src/commands/_generated/ai-search/jobs/list.ts +++ b/packages/cli/src/commands/_generated/ai-search/jobs/list.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,43 +16,44 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search jobs list\n\nLists indexing jobs for an AI Search instance." - ) - .option("namespace", { - type: "string", - description: "Namespace to use for this operation.", - default: "default", - }) - .option("instance-id", { - type: "string", - description: "AI Search instance ID.", - demandOption: true, - }) - .option("page", { type: "number", description: "Page" }) - .option("per-page", { type: "number", description: "Per page" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List Jobs", - builder, + usage: + "$0 ai-search jobs list\n\nLists indexing jobs for an AI Search instance.", + flags: { + namespace: { + kind: "parsed", + brief: "Namespace to use for this operation.", + default: "default", + parse: String, + }, + "instance-id": { + kind: "parsed", + brief: "AI Search instance ID.", + parse: String, + }, + page: { kind: "parsed", brief: "Page", optional: true, parse: Number }, + "per-page": { + kind: "parsed", + brief: "Per page", + optional: true, + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "ai-search jobs list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -91,6 +91,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/jobs/logs.ts b/packages/cli/src/commands/_generated/ai-search/jobs/logs.ts index fa3b6b6a15..b35f8c225a 100644 --- a/packages/cli/src/commands/_generated/ai-search/jobs/logs.ts +++ b/packages/cli/src/commands/_generated/ai-search/jobs/logs.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * logs command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,48 +16,46 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search jobs logs \n\nLists log entries for an AI Search indexing job." - ) - .positional("job-id", { - type: "string", - description: "Indexing job ID.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Namespace to use for this operation.", - default: "default", - }) - .option("instance-id", { - type: "string", - description: "AI Search instance ID.", - demandOption: true, - }) - .option("page", { type: "number", description: "Page" }) - .option("per-page", { type: "number", description: "Per page" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "logs ", describe: "List Job Logs", - builder, + usage: + "$0 ai-search jobs logs \n\nLists log entries for an AI Search indexing job.", + flags: { + namespace: { + kind: "parsed", + brief: "Namespace to use for this operation.", + default: "default", + parse: String, + }, + "instance-id": { + kind: "parsed", + brief: "AI Search instance ID.", + parse: String, + }, + page: { kind: "parsed", brief: "Page", optional: true, parse: Number }, + "per-page": { + kind: "parsed", + brief: "Per page", + optional: true, + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { placeholder: "job-id", brief: "Indexing job ID.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "ai-search jobs logs", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -97,6 +94,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/list.ts b/packages/cli/src/commands/_generated/ai-search/list.ts index ccc7e29e00..4bf56657fb 100644 --- a/packages/cli/src/commands/_generated/ai-search/list.ts +++ b/packages/cli/src/commands/_generated/ai-search/list.ts @@ -1,11 +1,10 @@ import operation from "../_operations/ai-search/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,59 +16,69 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage("$0 ai-search list\n\nLists all AI Search instances in the account.") - .option("namespace", { - type: "string", - description: "Namespace to use for this operation.", +const command = apiCommand({ + command: "list", + describe: "List AI Search instances.", + usage: "$0 ai-search list\n\nLists all AI Search instances in the account.", + flags: { + namespace: { + kind: "parsed", + brief: "Namespace to use for this operation.", default: "default", - }) - .option("page", { type: "number", description: "Page number (1-indexed)." }) - .option("per-page", { - type: "number", - description: "Number of results per page.", - }) - .option("search", { - type: "string", - description: + parse: String, + }, + page: { + kind: "parsed", + brief: "Page number (1-indexed).", + optional: true, + parse: Number, + }, + "per-page": { + kind: "parsed", + brief: "Number of results per page.", + optional: true, + parse: Number, + }, + search: { + kind: "parsed", + brief: "Filter instances whose id contains this string (case-insensitive).", - }) - .option("hostname", { - type: "string", - description: + optional: true, + parse: String, + }, + hostname: { + kind: "parsed", + brief: "Return only instances with this exact Search for Agents hostname (case-insensitive).", - }) - .option("order-by", { - type: "string", - description: "Field to order results by.", - choices: ["created_at"], - }) - .option("order-by-direction", { - type: "string", - description: "Order direction.", - choices: ["asc", "desc"], - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "order-by": { + kind: "enum", + brief: "Field to order results by.", + values: ["created_at"], + optional: true, + }, + "order-by-direction": { + kind: "enum", + brief: "Order direction.", + values: ["asc", "desc"], + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "list", - describe: "List AI Search instances.", - builder, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "ai-search list", classification: { safeFlags: ["order-by", "order-by-direction", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -107,6 +116,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/move.ts b/packages/cli/src/commands/_generated/ai-search/move.ts index bf9c9cb177..a3142b655a 100644 --- a/packages/cli/src/commands/_generated/ai-search/move.ts +++ b/packages/cli/src/commands/_generated/ai-search/move.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * move command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,49 +19,50 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search move \n\nMoves an instance from its current namespace to the specified target namespace. Use 'default' with --destination-namespace to move the instance back to the default namespace. Fails with 400 if the target namespace already has an instance with the same id (ids must be unique within a namespace — the same id can exist in different namespaces)." - ) - .positional("instance-id", { - type: "string", - description: "AI Search instance ID.", - demandOption: true, - }) - .option("source-namespace", { - type: "string", - description: "Namespace currently containing the instance.", - default: "default", - }) - .option("destination-namespace", { - type: "string", - description: "Namespace to move the instance into.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "move ", describe: "Move an instance to a different namespace.", - builder, + usage: + "$0 ai-search move \n\nMoves an instance from its current namespace to the specified target namespace. Use 'default' with --destination-namespace to move the instance back to the default namespace. Fails with 400 if the target namespace already has an instance with the same id (ids must be unique within a namespace — the same id can exist in different namespaces).", + flags: { + "source-namespace": { + kind: "parsed", + brief: "Namespace currently containing the instance.", + default: "default", + parse: String, + }, + "destination-namespace": { + kind: "parsed", + brief: "Namespace to move the instance into.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "instance-id", + brief: "AI Search instance ID.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "ai-search move", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -145,6 +145,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/multi-chat-completions.ts b/packages/cli/src/commands/_generated/ai-search/multi-chat-completions.ts index 4c43e02ad3..8bc92ca1d3 100644 --- a/packages/cli/src/commands/_generated/ai-search/multi-chat-completions.ts +++ b/packages/cli/src/commands/_generated/ai-search/multi-chat-completions.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * multi-chat-completions command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -25,162 +24,198 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search multi-chat-completions\n\nPerforms a chat completion request against multiple AI Search instances in parallel, merging retrieved content as context for generating a response." - ) - .option("namespace", { - type: "string", - description: "Namespace to use for this operation.", +const command = apiCommand({ + command: "multi-chat-completions", + describe: "Multi-Instance Chat Completions", + usage: + "$0 ai-search multi-chat-completions\n\nPerforms a chat completion request against multiple AI Search instances in parallel, merging retrieved content as context for generating a response.", + flags: { + namespace: { + kind: "parsed", + brief: "Namespace to use for this operation.", default: "default", - }) - .option("ai-search-options-cache-cache-threshold", { - type: "string", - description: "The ai_search_options.cache.cache_threshold field", + parse: String, + }, + "ai-search-options-cache-cache-threshold": { + kind: "parsed", + brief: "The ai_search_options.cache.cache_threshold field", + optional: true, choices: [ "super_strict_match", "close_enough", "flexible_friend", "anything_goes", ], - }) - .coerce("ai-search-options-cache-cache-threshold", (value) => - resolveFileToken(value, "ai-search-options-cache-cache-threshold", "text") - ) - .option("ai-search-options-cache-enabled", { - type: "boolean", - description: "The ai_search_options.cache.enabled field", - }) - .option("ai-search-options-custom-metadata", { - type: "string", - description: + parse: String, + coerce: (value: string) => + resolveFileToken( + value, + "ai-search-options-cache-cache-threshold", + "text" + ), + }, + "ai-search-options-cache-enabled": { + kind: "boolean", + brief: "The ai_search_options.cache.enabled field", + optional: true, + }, + "ai-search-options-custom-metadata": { + kind: "parsed", + brief: "Metadata added to AI Gateway logs for requests this operation triggers. Accepts up to 2 string, number, or boolean entries. Reserved keys: 'ai-search', 'task', 'origin', and any key beginning with 'cf.'. Provide as a JSON object or @path/to/file.json. Shape: {\"\": (string | number | boolean)}.", - }) - .option("ai-search-options-instance-ids", { - type: "string", - array: true, - description: "The ai_search_options.instance_ids field", - }) - .option("ai-search-options-query-rewrite-enabled", { - type: "boolean", - description: "The ai_search_options.query_rewrite.enabled field", - }) - .option("ai-search-options-query-rewrite-model", { - type: "string", - description: + optional: true, + parse: String, + }, + "ai-search-options-instance-ids": { + kind: "parsed", + brief: "The ai_search_options.instance_ids field", + variadic: true, + optional: true, + parse: String, + }, + "ai-search-options-query-rewrite-enabled": { + kind: "boolean", + brief: "The ai_search_options.query_rewrite.enabled field", + optional: true, + }, + "ai-search-options-query-rewrite-model": { + kind: "parsed", + brief: "A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.", - }) - .option("ai-search-options-query-rewrite-rewrite-prompt", { - type: "string", - description: "The ai_search_options.query_rewrite.rewrite_prompt field", - }) - .option("ai-search-options-reranking-enabled", { - type: "boolean", - description: "The ai_search_options.reranking.enabled field", - }) - .option("ai-search-options-reranking-match-threshold", { - type: "number", - description: + optional: true, + parse: String, + }, + "ai-search-options-query-rewrite-rewrite-prompt": { + kind: "parsed", + brief: "The ai_search_options.query_rewrite.rewrite_prompt field", + optional: true, + parse: String, + }, + "ai-search-options-reranking-enabled": { + kind: "boolean", + brief: "The ai_search_options.reranking.enabled field", + optional: true, + }, + "ai-search-options-reranking-match-threshold": { + kind: "parsed", + brief: "Minimum reranker relevance score a chunk must reach to be returned. When omitted, falls back to the instance-level score_threshold, then to 0.4.", - }) - .option("ai-search-options-reranking-model", { - type: "string", - description: "The ai_search_options.reranking.model field", - }) - .option("ai-search-options-retrieval-boost-by", { - type: "string", - description: + optional: true, + parse: Number, + }, + "ai-search-options-reranking-model": { + kind: "parsed", + brief: "The ai_search_options.reranking.model field", + optional: true, + parse: String, + }, + "ai-search-options-retrieval-boost-by": { + kind: "parsed", + brief: 'Metadata fields to boost search results by. Overrides the instance-level boost_by config. Direction defaults to \'asc\' for numeric/datetime fields, \'exists\' for text/boolean fields. Fields must match \'timestamp\' or a defined custom_metadata field. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"field": string, "direction"?: "asc" | "desc" | "exists" | ...more}]. ? marks optional keys.', - }) - .option("ai-search-options-retrieval-context-expansion", { - type: "number", - description: "The ai_search_options.retrieval.context_expansion field", - }) - .option("ai-search-options-retrieval-filters", { - type: "string", - description: + optional: true, + parse: String, + }, + "ai-search-options-retrieval-context-expansion": { + kind: "parsed", + brief: "The ai_search_options.retrieval.context_expansion field", + optional: true, + parse: Number, + }, + "ai-search-options-retrieval-filters": { + kind: "parsed", + brief: 'The ai_search_options.retrieval.filters field. Provide as a JSON object or @path/to/file.json. Shape: {"": unknown}.', - }) - .option("ai-search-options-retrieval-fusion-method", { - type: "string", - description: "The ai_search_options.retrieval.fusion_method field", + optional: true, + parse: String, + }, + "ai-search-options-retrieval-fusion-method": { + kind: "parsed", + brief: "The ai_search_options.retrieval.fusion_method field", + optional: true, choices: ["max", "rrf"], - }) - .coerce("ai-search-options-retrieval-fusion-method", (value) => - resolveFileToken( - value, - "ai-search-options-retrieval-fusion-method", - "text" - ) - ) - .option("ai-search-options-retrieval-keyword-match-mode", { - type: "string", - description: + parse: String, + coerce: (value: string) => + resolveFileToken( + value, + "ai-search-options-retrieval-fusion-method", + "text" + ), + }, + "ai-search-options-retrieval-keyword-match-mode": { + kind: "parsed", + brief: "Controls which documents become candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term and ranks results according to BM25 relevance. When omitted, falls back to the instance-level retrieval_options.keyword_match_mode, then to 'and'.", + optional: true, choices: ["and", "or"], - }) - .coerce("ai-search-options-retrieval-keyword-match-mode", (value) => - resolveFileToken( - value, - "ai-search-options-retrieval-keyword-match-mode", - "text" - ) - ) - .option("ai-search-options-retrieval-match-threshold", { - type: "number", - description: + parse: String, + coerce: (value: string) => + resolveFileToken( + value, + "ai-search-options-retrieval-keyword-match-mode", + "text" + ), + }, + "ai-search-options-retrieval-match-threshold": { + kind: "parsed", + brief: "Minimum score a chunk must reach to be returned. When omitted, each instance's chunks are filtered by that instance's score_threshold, capped at the lower of the first instance's score_threshold and 0.4.", - }) - .option("ai-search-options-retrieval-max-num-results", { - type: "number", - description: + optional: true, + parse: Number, + }, + "ai-search-options-retrieval-max-num-results": { + kind: "parsed", + brief: "Maximum number of merged results to return. When omitted, defaults to the first instance's max_num_results, then 10.", - }) - .option("ai-search-options-retrieval-retrieval-type", { - type: "string", - description: "The ai_search_options.retrieval.retrieval_type field", + optional: true, + parse: Number, + }, + "ai-search-options-retrieval-retrieval-type": { + kind: "parsed", + brief: "The ai_search_options.retrieval.retrieval_type field", + optional: true, choices: ["vector", "keyword", "hybrid"], - }) - .coerce("ai-search-options-retrieval-retrieval-type", (value) => - resolveFileToken( - value, - "ai-search-options-retrieval-retrieval-type", - "text" - ) - ) - .option("ai-search-options-retrieval-return-on-failure", { - type: "boolean", - description: "The ai_search_options.retrieval.return_on_failure field", - }) - .option("messages", { - type: "string", - description: + parse: String, + coerce: (value: string) => + resolveFileToken( + value, + "ai-search-options-retrieval-retrieval-type", + "text" + ), + }, + "ai-search-options-retrieval-return-on-failure": { + kind: "boolean", + brief: "The ai_search_options.retrieval.return_on_failure field", + optional: true, + }, + messages: { + kind: "parsed", + brief: 'The messages field. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"content": (string | [{...}] | null), "role": "system" | "developer" | "user" | ...more, "": unknown}].', - }) - .option("model", { - type: "string", - description: + optional: true, + parse: String, + }, + model: { + kind: "parsed", + brief: "A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.", - }) - .option("stream", { type: "boolean", description: "The stream field" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + stream: { kind: "boolean", brief: "The stream field", optional: true }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "multi-chat-completions", - describe: "Multi-Instance Chat Completions", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { @@ -198,7 +233,7 @@ const command: CommandModule = { "stream", "dry-run", ], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -513,6 +548,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/multi-search.ts b/packages/cli/src/commands/_generated/ai-search/multi-search.ts index e18e651bce..09231ee00a 100644 --- a/packages/cli/src/commands/_generated/ai-search/multi-search.ts +++ b/packages/cli/src/commands/_generated/ai-search/multi-search.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * multi-search command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -26,160 +25,197 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search multi-search [query]\n\nPerforms a semantic search query against multiple AI Search instances in parallel, merging the retrieved results into a single ranked response." - ) - .positional("query", { - type: "string", - description: "Text to search for.", - }) - .option("namespace", { - type: "string", - description: "Namespace to use for this operation.", +const command = apiCommand({ + command: "multi-search [query]", + describe: "Multi-Instance Search", + usage: + "$0 ai-search multi-search [query]\n\nPerforms a semantic search query against multiple AI Search instances in parallel, merging the retrieved results into a single ranked response.", + flags: { + namespace: { + kind: "parsed", + brief: "Namespace to use for this operation.", default: "default", - }) - .option("ai-search-options-cache-cache-threshold", { - type: "string", - description: "The ai_search_options.cache.cache_threshold field", + parse: String, + }, + "ai-search-options-cache-cache-threshold": { + kind: "parsed", + brief: "The ai_search_options.cache.cache_threshold field", + optional: true, choices: [ "super_strict_match", "close_enough", "flexible_friend", "anything_goes", ], - }) - .coerce("ai-search-options-cache-cache-threshold", (value) => - resolveFileToken(value, "ai-search-options-cache-cache-threshold", "text") - ) - .option("ai-search-options-cache-enabled", { - type: "boolean", - description: "The ai_search_options.cache.enabled field", - }) - .option("ai-search-options-custom-metadata", { - type: "string", - description: + parse: String, + coerce: (value: string) => + resolveFileToken( + value, + "ai-search-options-cache-cache-threshold", + "text" + ), + }, + "ai-search-options-cache-enabled": { + kind: "boolean", + brief: "The ai_search_options.cache.enabled field", + optional: true, + }, + "ai-search-options-custom-metadata": { + kind: "parsed", + brief: "Metadata added to AI Gateway logs for requests this operation triggers. Accepts up to 2 string, number, or boolean entries. Reserved keys: 'ai-search', 'task', 'origin', and any key beginning with 'cf.'. Provide as a JSON object or @path/to/file.json. Shape: {\"\": (string | number | boolean)}.", - }) - .option("ai-search-options-instance-ids", { - type: "string", - array: true, - description: "The ai_search_options.instance_ids field", - }) - .option("ai-search-options-query-rewrite-enabled", { - type: "boolean", - description: "The ai_search_options.query_rewrite.enabled field", - }) - .option("ai-search-options-query-rewrite-model", { - type: "string", - description: + optional: true, + parse: String, + }, + "ai-search-options-instance-ids": { + kind: "parsed", + brief: "The ai_search_options.instance_ids field", + variadic: true, + optional: true, + parse: String, + }, + "ai-search-options-query-rewrite-enabled": { + kind: "boolean", + brief: "The ai_search_options.query_rewrite.enabled field", + optional: true, + }, + "ai-search-options-query-rewrite-model": { + kind: "parsed", + brief: "A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.", - }) - .option("ai-search-options-query-rewrite-rewrite-prompt", { - type: "string", - description: "The ai_search_options.query_rewrite.rewrite_prompt field", - }) - .option("ai-search-options-reranking-enabled", { - type: "boolean", - description: "The ai_search_options.reranking.enabled field", - }) - .option("ai-search-options-reranking-match-threshold", { - type: "number", - description: + optional: true, + parse: String, + }, + "ai-search-options-query-rewrite-rewrite-prompt": { + kind: "parsed", + brief: "The ai_search_options.query_rewrite.rewrite_prompt field", + optional: true, + parse: String, + }, + "ai-search-options-reranking-enabled": { + kind: "boolean", + brief: "The ai_search_options.reranking.enabled field", + optional: true, + }, + "ai-search-options-reranking-match-threshold": { + kind: "parsed", + brief: "Minimum reranker relevance score a chunk must reach to be returned. When omitted, falls back to the instance-level score_threshold, then to 0.4.", - }) - .option("ai-search-options-reranking-model", { - type: "string", - description: "The ai_search_options.reranking.model field", - }) - .option("ai-search-options-retrieval-boost-by", { - type: "string", - description: + optional: true, + parse: Number, + }, + "ai-search-options-reranking-model": { + kind: "parsed", + brief: "The ai_search_options.reranking.model field", + optional: true, + parse: String, + }, + "ai-search-options-retrieval-boost-by": { + kind: "parsed", + brief: 'Metadata fields to boost search results by. Overrides the instance-level boost_by config. Direction defaults to \'asc\' for numeric/datetime fields, \'exists\' for text/boolean fields. Fields must match \'timestamp\' or a defined custom_metadata field. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"field": string, "direction"?: "asc" | "desc" | "exists" | ...more}]. ? marks optional keys.', - }) - .option("ai-search-options-retrieval-context-expansion", { - type: "number", - description: "The ai_search_options.retrieval.context_expansion field", - }) - .option("ai-search-options-retrieval-filters", { - type: "string", - description: + optional: true, + parse: String, + }, + "ai-search-options-retrieval-context-expansion": { + kind: "parsed", + brief: "The ai_search_options.retrieval.context_expansion field", + optional: true, + parse: Number, + }, + "ai-search-options-retrieval-filters": { + kind: "parsed", + brief: 'The ai_search_options.retrieval.filters field. Provide as a JSON object or @path/to/file.json. Shape: {"": unknown}.', - }) - .option("ai-search-options-retrieval-fusion-method", { - type: "string", - description: "The ai_search_options.retrieval.fusion_method field", + optional: true, + parse: String, + }, + "ai-search-options-retrieval-fusion-method": { + kind: "parsed", + brief: "The ai_search_options.retrieval.fusion_method field", + optional: true, choices: ["max", "rrf"], - }) - .coerce("ai-search-options-retrieval-fusion-method", (value) => - resolveFileToken( - value, - "ai-search-options-retrieval-fusion-method", - "text" - ) - ) - .option("ai-search-options-retrieval-keyword-match-mode", { - type: "string", - description: + parse: String, + coerce: (value: string) => + resolveFileToken( + value, + "ai-search-options-retrieval-fusion-method", + "text" + ), + }, + "ai-search-options-retrieval-keyword-match-mode": { + kind: "parsed", + brief: "Controls which documents become candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term and ranks results according to BM25 relevance. When omitted, falls back to the instance-level retrieval_options.keyword_match_mode, then to 'and'.", + optional: true, choices: ["and", "or"], - }) - .coerce("ai-search-options-retrieval-keyword-match-mode", (value) => - resolveFileToken( - value, - "ai-search-options-retrieval-keyword-match-mode", - "text" - ) - ) - .option("ai-search-options-retrieval-match-threshold", { - type: "number", - description: + parse: String, + coerce: (value: string) => + resolveFileToken( + value, + "ai-search-options-retrieval-keyword-match-mode", + "text" + ), + }, + "ai-search-options-retrieval-match-threshold": { + kind: "parsed", + brief: "Minimum score a chunk must reach to be returned. When omitted, each instance's chunks are filtered by that instance's score_threshold, capped at 0.4.", - }) - .option("ai-search-options-retrieval-max-num-results", { - type: "number", - description: + optional: true, + parse: Number, + }, + "ai-search-options-retrieval-max-num-results": { + kind: "parsed", + brief: "Maximum number of merged results to return. When omitted, defaults to the sum of the searched instances' max_num_results (each falling back to 10), up to 50.", - }) - .option("ai-search-options-retrieval-retrieval-type", { - type: "string", - description: "The ai_search_options.retrieval.retrieval_type field", + optional: true, + parse: Number, + }, + "ai-search-options-retrieval-retrieval-type": { + kind: "parsed", + brief: "The ai_search_options.retrieval.retrieval_type field", + optional: true, choices: ["vector", "keyword", "hybrid"], - }) - .coerce("ai-search-options-retrieval-retrieval-type", (value) => - resolveFileToken( - value, - "ai-search-options-retrieval-retrieval-type", - "text" - ) - ) - .option("ai-search-options-retrieval-return-on-failure", { - type: "boolean", - description: "The ai_search_options.retrieval.return_on_failure field", - }) - .option("messages", { - type: "string", - description: + parse: String, + coerce: (value: string) => + resolveFileToken( + value, + "ai-search-options-retrieval-retrieval-type", + "text" + ), + }, + "ai-search-options-retrieval-return-on-failure": { + kind: "boolean", + brief: "The ai_search_options.retrieval.return_on_failure field", + optional: true, + }, + messages: { + kind: "parsed", + brief: "OpenAI-compatible message array. For multimodal queries, set the last user message's `content` to an array of typed parts: `[{type:'text', text:'…'}, {type:'image_url', image_url:{url:'…'}}]`. Image inputs require the RAG's embedding_model to declare 'image' in supported_modalities. Provide as a JSON array of objects or @path/to/file.json. Shape: [{\"content\": (string | [{...}] | null), \"role\": \"system\" | \"developer\" | \"user\" | ...more, \"\": unknown}].", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "multi-search [query]", - describe: "Multi-Instance Search", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "query", + brief: "Text to search for.", + parse: String, + optional: true, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -196,7 +232,7 @@ const command: CommandModule = { "ai-search-options-retrieval-return-on-failure", "dry-run", ], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -496,6 +532,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/namespace/create.ts b/packages/cli/src/commands/_generated/ai-search/namespace/create.ts index 1239760e6e..caf1b65f33 100644 --- a/packages/cli/src/commands/_generated/ai-search/namespace/create.ts +++ b/packages/cli/src/commands/_generated/ai-search/namespace/create.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-search/namespace/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -23,101 +22,117 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search namespace create \n\nCreate a namespace for organizing AI Search instances." - ) - .positional("namespace", { - type: "string", - description: "Name for the new namespace.", - demandOption: true, - }) - .option("description", { - type: "string", - description: - "Optional description for the namespace. Max 256 characters.", - }) - .option("public-endpoint-params-authorized-hosts", { - type: "string", - array: true, - description: "The public_endpoint_params.authorized_hosts field", - }) - .option("public-endpoint-params-chat-completions-endpoint-disabled", { - type: "boolean", - description: - "Disable chat completions endpoint for this public endpoint.", - }) - .option("public-endpoint-params-custom-domains", { - type: "string", - array: true, - description: +const command = apiCommand({ + command: "create ", + describe: "Create a namespace", + usage: + "$0 ai-search namespace create \n\nCreate a namespace for organizing AI Search instances.", + flags: { + description: { + kind: "parsed", + brief: "Optional description for the namespace. Max 256 characters.", + optional: true, + parse: String, + }, + "public-endpoint-params-authorized-hosts": { + kind: "parsed", + brief: "The public_endpoint_params.authorized_hosts field", + variadic: true, + optional: true, + parse: String, + }, + "public-endpoint-params-chat-completions-endpoint-disabled": { + kind: "boolean", + brief: "Disable chat completions endpoint for this public endpoint.", + optional: true, + }, + "public-endpoint-params-custom-domains": { + kind: "parsed", + brief: "Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged).", - }) - .option("public-endpoint-params-default-domain-enabled", { - type: "boolean", - description: + variadic: true, + optional: true, + parse: String, + }, + "public-endpoint-params-default-domain-enabled": { + kind: "boolean", + brief: "When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true.", - }) - .option("public-endpoint-params-enabled", { - type: "boolean", - description: "The public_endpoint_params.enabled field", - }) - .option("public-endpoint-params-instances-allowed", { - type: "string", - array: true, - description: + optional: true, + }, + "public-endpoint-params-enabled": { + kind: "boolean", + brief: "The public_endpoint_params.enabled field", + optional: true, + }, + "public-endpoint-params-instances-allowed": { + kind: "parsed", + brief: "Instance IDs exposed through the namespace public endpoint. Empty means nothing is searchable. Every ID must reference an existing instance in this namespace, and the list must stay within the account's multi-instance search limit.", - }) - .option("public-endpoint-params-mcp-description", { - type: "string", - description: "The public_endpoint_params.mcp.description field", - }) - .option("public-endpoint-params-mcp-disabled", { - type: "boolean", - description: "Disable MCP endpoint for this public endpoint.", - }) - .option("public-endpoint-params-rate-limit-period-ms", { - type: "number", - description: "The public_endpoint_params.rate_limit.period_ms field", - }) - .option("public-endpoint-params-rate-limit-requests", { - type: "number", - description: "The public_endpoint_params.rate_limit.requests field", - }) - .option("public-endpoint-params-rate-limit-technique", { - type: "string", - description: "The public_endpoint_params.rate_limit.technique field", + variadic: true, + optional: true, + parse: String, + }, + "public-endpoint-params-mcp-description": { + kind: "parsed", + brief: "The public_endpoint_params.mcp.description field", + optional: true, + parse: String, + }, + "public-endpoint-params-mcp-disabled": { + kind: "boolean", + brief: "Disable MCP endpoint for this public endpoint.", + optional: true, + }, + "public-endpoint-params-rate-limit-period-ms": { + kind: "parsed", + brief: "The public_endpoint_params.rate_limit.period_ms field", + optional: true, + parse: Number, + }, + "public-endpoint-params-rate-limit-requests": { + kind: "parsed", + brief: "The public_endpoint_params.rate_limit.requests field", + optional: true, + parse: Number, + }, + "public-endpoint-params-rate-limit-technique": { + kind: "parsed", + brief: "The public_endpoint_params.rate_limit.technique field", + optional: true, choices: ["fixed", "sliding"], - }) - .coerce("public-endpoint-params-rate-limit-technique", (value) => - resolveFileToken( - value, - "public-endpoint-params-rate-limit-technique", - "text" - ) - ) - .option("public-endpoint-params-search-endpoint-disabled", { - type: "boolean", - description: "Disable search endpoint for this public endpoint.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + parse: String, + coerce: (value: string) => + resolveFileToken( + value, + "public-endpoint-params-rate-limit-technique", + "text" + ), + }, + "public-endpoint-params-search-endpoint-disabled": { + kind: "boolean", + brief: "Disable search endpoint for this public endpoint.", + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "create ", - describe: "Create a namespace", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "namespace", + brief: "Name for the new namespace.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -132,7 +147,7 @@ const command: CommandModule = { "public-endpoint-params-search-endpoint-disabled", "dry-run", ], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -271,6 +286,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/namespace/delete.ts b/packages/cli/src/commands/_generated/ai-search/namespace/delete.ts index f24d5b0bed..6499e2048c 100644 --- a/packages/cli/src/commands/_generated/ai-search/namespace/delete.ts +++ b/packages/cli/src/commands/_generated/ai-search/namespace/delete.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,35 +17,27 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search namespace delete \n\nDeletes a namespace permanently. The namespace must not contain any instances (instances whose deletion is still in progress do not count), and the default namespace cannot be deleted." - ) - .positional("namespace", { - type: "string", - description: "Namespace to delete.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete a namespace", + usage: + "$0 ai-search namespace delete \n\nDeletes a namespace permanently. The namespace must not contain any instances (instances whose deletion is still in progress do not count), and the default namespace cannot be deleted.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete a namespace", - builder, + }, + }, + operands: [ + { placeholder: "namespace", brief: "Namespace to delete.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -54,7 +45,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -92,6 +83,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/namespace/get.ts b/packages/cli/src/commands/_generated/ai-search/namespace/get.ts index 89f35d4044..06958fd32b 100644 --- a/packages/cli/src/commands/_generated/ai-search/namespace/get.ts +++ b/packages/cli/src/commands/_generated/ai-search/namespace/get.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,32 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search namespace get \n\nRetrieve a namespace and its description." - ) - .positional("namespace", { - type: "string", - description: "Namespace to retrieve.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get a namespace", - builder, + usage: + "$0 ai-search namespace get \n\nRetrieve a namespace and its description.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "namespace", + brief: "Namespace to retrieve.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "ai-search namespace get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -75,6 +70,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/namespace/index.ts b/packages/cli/src/commands/_generated/ai-search/namespace/index.ts index 48d029ed88..5c6f867261 100644 --- a/packages/cli/src/commands/_generated/ai-search/namespace/index.ts +++ b/packages/cli/src/commands/_generated/ai-search/namespace/index.ts @@ -3,28 +3,23 @@ import $delete from "./delete.js"; import $get from "./get.js"; import $list from "./list.js"; import $update from "./update.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * namespace command group * @generated from apis/overlays/ai-search.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "namespace", describe: "Logical groupings for organizing AI Search instances", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($get) - .command($list) - .command($update) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + get: $get, + list: $list, + update: $update, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/namespace/list.ts b/packages/cli/src/commands/_generated/ai-search/namespace/list.ts index a5eec70757..383d70d359 100644 --- a/packages/cli/src/commands/_generated/ai-search/namespace/list.ts +++ b/packages/cli/src/commands/_generated/ai-search/namespace/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-search/namespace/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,41 +16,45 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search namespace list\n\nLists namespaces in the account, including their descriptions and creation times." - ) - .option("page", { type: "number", description: "Page number (1-indexed)." }) - .option("per-page", { - type: "number", - description: "Number of results per page.", - }) - .option("search", { - type: "string", - description: - "Filter namespaces whose name or description contains this string (case-insensitive).", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List namespaces", - builder, + usage: + "$0 ai-search namespace list\n\nLists namespaces in the account, including their descriptions and creation times.", + flags: { + page: { + kind: "parsed", + brief: "Page number (1-indexed).", + optional: true, + parse: Number, + }, + "per-page": { + kind: "parsed", + brief: "Number of results per page.", + optional: true, + parse: Number, + }, + search: { + kind: "parsed", + brief: + "Filter namespaces whose name or description contains this string (case-insensitive).", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "ai-search namespace list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -82,6 +85,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/namespace/update.ts b/packages/cli/src/commands/_generated/ai-search/namespace/update.ts index 221ce4da83..1115d74523 100644 --- a/packages/cli/src/commands/_generated/ai-search/namespace/update.ts +++ b/packages/cli/src/commands/_generated/ai-search/namespace/update.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,101 +18,113 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search namespace update \n\nUpdates the description and/or the public endpoint configuration of an existing namespace. The default namespace's description cannot be modified, but its public endpoint can." - ) - .positional("namespace", { - type: "string", - description: "Namespace to update.", - demandOption: true, - }) - .option("description", { - type: "string", - description: - "Optional description for the namespace. Max 256 characters.", - }) - .option("public-endpoint-params-authorized-hosts", { - type: "string", - array: true, - description: "The public_endpoint_params.authorized_hosts field", - }) - .option("public-endpoint-params-chat-completions-endpoint-disabled", { - type: "boolean", - description: - "Disable chat completions endpoint for this public endpoint.", - }) - .option("public-endpoint-params-custom-domains", { - type: "string", - array: true, - description: +const command = apiCommand({ + command: "update ", + describe: "Update a namespace", + usage: + "$0 ai-search namespace update \n\nUpdates the description and/or the public endpoint configuration of an existing namespace. The default namespace's description cannot be modified, but its public endpoint can.", + flags: { + description: { + kind: "parsed", + brief: "Optional description for the namespace. Max 256 characters.", + optional: true, + parse: String, + }, + "public-endpoint-params-authorized-hosts": { + kind: "parsed", + brief: "The public_endpoint_params.authorized_hosts field", + variadic: true, + optional: true, + parse: String, + }, + "public-endpoint-params-chat-completions-endpoint-disabled": { + kind: "boolean", + brief: "Disable chat completions endpoint for this public endpoint.", + optional: true, + }, + "public-endpoint-params-custom-domains": { + kind: "parsed", + brief: "Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged).", - }) - .option("public-endpoint-params-default-domain-enabled", { - type: "boolean", - description: + variadic: true, + optional: true, + parse: String, + }, + "public-endpoint-params-default-domain-enabled": { + kind: "boolean", + brief: "When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true.", - }) - .option("public-endpoint-params-enabled", { - type: "boolean", - description: "The public_endpoint_params.enabled field", - }) - .option("public-endpoint-params-instances-allowed", { - type: "string", - array: true, - description: + optional: true, + }, + "public-endpoint-params-enabled": { + kind: "boolean", + brief: "The public_endpoint_params.enabled field", + optional: true, + }, + "public-endpoint-params-instances-allowed": { + kind: "parsed", + brief: "Instance IDs exposed through the namespace public endpoint. Empty means nothing is searchable. Every ID must reference an existing instance in this namespace, and the list must stay within the account's multi-instance search limit.", - }) - .option("public-endpoint-params-mcp-description", { - type: "string", - description: "The public_endpoint_params.mcp.description field", - }) - .option("public-endpoint-params-mcp-disabled", { - type: "boolean", - description: "Disable MCP endpoint for this public endpoint.", - }) - .option("public-endpoint-params-rate-limit-period-ms", { - type: "number", - description: "The public_endpoint_params.rate_limit.period_ms field", - }) - .option("public-endpoint-params-rate-limit-requests", { - type: "number", - description: "The public_endpoint_params.rate_limit.requests field", - }) - .option("public-endpoint-params-rate-limit-technique", { - type: "string", - description: "The public_endpoint_params.rate_limit.technique field", + variadic: true, + optional: true, + parse: String, + }, + "public-endpoint-params-mcp-description": { + kind: "parsed", + brief: "The public_endpoint_params.mcp.description field", + optional: true, + parse: String, + }, + "public-endpoint-params-mcp-disabled": { + kind: "boolean", + brief: "Disable MCP endpoint for this public endpoint.", + optional: true, + }, + "public-endpoint-params-rate-limit-period-ms": { + kind: "parsed", + brief: "The public_endpoint_params.rate_limit.period_ms field", + optional: true, + parse: Number, + }, + "public-endpoint-params-rate-limit-requests": { + kind: "parsed", + brief: "The public_endpoint_params.rate_limit.requests field", + optional: true, + parse: Number, + }, + "public-endpoint-params-rate-limit-technique": { + kind: "parsed", + brief: "The public_endpoint_params.rate_limit.technique field", + optional: true, choices: ["fixed", "sliding"], - }) - .coerce("public-endpoint-params-rate-limit-technique", (value) => - resolveFileToken( - value, - "public-endpoint-params-rate-limit-technique", - "text" - ) - ) - .option("public-endpoint-params-search-endpoint-disabled", { - type: "boolean", - description: "Disable search endpoint for this public endpoint.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + parse: String, + coerce: (value: string) => + resolveFileToken( + value, + "public-endpoint-params-rate-limit-technique", + "text" + ), + }, + "public-endpoint-params-search-endpoint-disabled": { + kind: "boolean", + brief: "Disable search endpoint for this public endpoint.", + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "update ", - describe: "Update a namespace", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { placeholder: "namespace", brief: "Namespace to update.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -128,7 +139,7 @@ const command: CommandModule = { "public-endpoint-params-search-endpoint-disabled", "dry-run", ], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -320,6 +331,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/purge-cache.ts b/packages/cli/src/commands/_generated/ai-search/purge-cache.ts index 9d53eceacc..4b2dd2ba15 100644 --- a/packages/cli/src/commands/_generated/ai-search/purge-cache.ts +++ b/packages/cli/src/commands/_generated/ai-search/purge-cache.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * purge-cache command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,41 +16,38 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search purge-cache \n\nPurges all cached search results for an AI Search instance. A new internal cache key is generated, immediately orphaning all prior cached entries." - ) - .positional("instance-id", { - type: "string", - description: "AI Search instance ID.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Namespace to use for this operation.", - default: "default", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "purge-cache ", describe: "Purge search cache.", - builder, + usage: + "$0 ai-search purge-cache \n\nPurges all cached search results for an AI Search instance. A new internal cache key is generated, immediately orphaning all prior cached entries.", + flags: { + namespace: { + kind: "parsed", + brief: "Namespace to use for this operation.", + default: "default", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "instance-id", + brief: "AI Search instance ID.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "ai-search purge-cache", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -83,6 +79,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/search.ts b/packages/cli/src/commands/_generated/ai-search/search.ts index 0634807cf1..fa4905a3e8 100644 --- a/packages/cli/src/commands/_generated/ai-search/search.ts +++ b/packages/cli/src/commands/_generated/ai-search/search.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * search command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -26,160 +25,195 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search search [query]\n\nExecutes a semantic search query against an AI Search instance to find relevant indexed content." - ) - .positional("instance-id", { - type: "string", - description: "AI Search instance ID.", - demandOption: true, - }) - .positional("query", { - type: "string", - description: "Text to search for.", - }) - .option("namespace", { - type: "string", - description: "Namespace to use for this operation.", +const command = apiCommand({ + command: "search [query]", + describe: "Search", + usage: + "$0 ai-search search [query]\n\nExecutes a semantic search query against an AI Search instance to find relevant indexed content.", + flags: { + namespace: { + kind: "parsed", + brief: "Namespace to use for this operation.", default: "default", - }) - .option("ai-search-options-cache-cache-threshold", { - type: "string", - description: "The ai_search_options.cache.cache_threshold field", + parse: String, + }, + "ai-search-options-cache-cache-threshold": { + kind: "parsed", + brief: "The ai_search_options.cache.cache_threshold field", + optional: true, choices: [ "super_strict_match", "close_enough", "flexible_friend", "anything_goes", ], - }) - .coerce("ai-search-options-cache-cache-threshold", (value) => - resolveFileToken(value, "ai-search-options-cache-cache-threshold", "text") - ) - .option("ai-search-options-cache-enabled", { - type: "boolean", - description: "The ai_search_options.cache.enabled field", - }) - .option("ai-search-options-custom-metadata", { - type: "string", - description: + parse: String, + coerce: (value: string) => + resolveFileToken( + value, + "ai-search-options-cache-cache-threshold", + "text" + ), + }, + "ai-search-options-cache-enabled": { + kind: "boolean", + brief: "The ai_search_options.cache.enabled field", + optional: true, + }, + "ai-search-options-custom-metadata": { + kind: "parsed", + brief: "Metadata added to AI Gateway logs for requests this operation triggers. Accepts up to 2 string, number, or boolean entries. Reserved keys: 'ai-search', 'task', 'origin', and any key beginning with 'cf.'. Provide as a JSON object or @path/to/file.json. Shape: {\"\": (string | number | boolean)}.", - }) - .option("ai-search-options-query-rewrite-enabled", { - type: "boolean", - description: "The ai_search_options.query_rewrite.enabled field", - }) - .option("ai-search-options-query-rewrite-model", { - type: "string", - description: + optional: true, + parse: String, + }, + "ai-search-options-query-rewrite-enabled": { + kind: "boolean", + brief: "The ai_search_options.query_rewrite.enabled field", + optional: true, + }, + "ai-search-options-query-rewrite-model": { + kind: "parsed", + brief: "A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.", - }) - .option("ai-search-options-query-rewrite-rewrite-prompt", { - type: "string", - description: "The ai_search_options.query_rewrite.rewrite_prompt field", - }) - .option("ai-search-options-reranking-enabled", { - type: "boolean", - description: "The ai_search_options.reranking.enabled field", - }) - .option("ai-search-options-reranking-match-threshold", { - type: "number", - description: + optional: true, + parse: String, + }, + "ai-search-options-query-rewrite-rewrite-prompt": { + kind: "parsed", + brief: "The ai_search_options.query_rewrite.rewrite_prompt field", + optional: true, + parse: String, + }, + "ai-search-options-reranking-enabled": { + kind: "boolean", + brief: "The ai_search_options.reranking.enabled field", + optional: true, + }, + "ai-search-options-reranking-match-threshold": { + kind: "parsed", + brief: "Minimum reranker relevance score a chunk must reach to be returned. When omitted, falls back to the instance-level score_threshold, then to 0.4.", - }) - .option("ai-search-options-reranking-model", { - type: "string", - description: "The ai_search_options.reranking.model field", - }) - .option("ai-search-options-retrieval-boost-by", { - type: "string", - description: + optional: true, + parse: Number, + }, + "ai-search-options-reranking-model": { + kind: "parsed", + brief: "The ai_search_options.reranking.model field", + optional: true, + parse: String, + }, + "ai-search-options-retrieval-boost-by": { + kind: "parsed", + brief: 'Metadata fields to boost search results by. Overrides the instance-level boost_by config. Direction defaults to \'asc\' for numeric/datetime fields, \'exists\' for text/boolean fields. Fields must match \'timestamp\' or a defined custom_metadata field. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"field": string, "direction"?: "asc" | "desc" | "exists" | ...more}]. ? marks optional keys.', - }) - .option("ai-search-options-retrieval-context-expansion", { - type: "number", - description: "The ai_search_options.retrieval.context_expansion field", - }) - .option("ai-search-options-retrieval-filters", { - type: "string", - description: + optional: true, + parse: String, + }, + "ai-search-options-retrieval-context-expansion": { + kind: "parsed", + brief: "The ai_search_options.retrieval.context_expansion field", + optional: true, + parse: Number, + }, + "ai-search-options-retrieval-filters": { + kind: "parsed", + brief: 'The ai_search_options.retrieval.filters field. Provide as a JSON object or @path/to/file.json. Shape: {"": unknown}.', - }) - .option("ai-search-options-retrieval-fusion-method", { - type: "string", - description: "The ai_search_options.retrieval.fusion_method field", + optional: true, + parse: String, + }, + "ai-search-options-retrieval-fusion-method": { + kind: "parsed", + brief: "The ai_search_options.retrieval.fusion_method field", + optional: true, choices: ["max", "rrf"], - }) - .coerce("ai-search-options-retrieval-fusion-method", (value) => - resolveFileToken( - value, - "ai-search-options-retrieval-fusion-method", - "text" - ) - ) - .option("ai-search-options-retrieval-keyword-match-mode", { - type: "string", - description: + parse: String, + coerce: (value: string) => + resolveFileToken( + value, + "ai-search-options-retrieval-fusion-method", + "text" + ), + }, + "ai-search-options-retrieval-keyword-match-mode": { + kind: "parsed", + brief: "Controls which documents become candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term and ranks results according to BM25 relevance. When omitted, falls back to the instance-level retrieval_options.keyword_match_mode, then to 'and'.", + optional: true, choices: ["and", "or"], - }) - .coerce("ai-search-options-retrieval-keyword-match-mode", (value) => - resolveFileToken( - value, - "ai-search-options-retrieval-keyword-match-mode", - "text" - ) - ) - .option("ai-search-options-retrieval-match-threshold", { - type: "number", - description: + parse: String, + coerce: (value: string) => + resolveFileToken( + value, + "ai-search-options-retrieval-keyword-match-mode", + "text" + ), + }, + "ai-search-options-retrieval-match-threshold": { + kind: "parsed", + brief: "Minimum similarity score a chunk must reach to be returned. When omitted, falls back to the instance-level score_threshold, then to 0.4.", - }) - .option("ai-search-options-retrieval-max-num-results", { - type: "number", - description: + optional: true, + parse: Number, + }, + "ai-search-options-retrieval-max-num-results": { + kind: "parsed", + brief: "Maximum number of results to return. When omitted, falls back to the instance-level max_num_results, then to 10.", - }) - .option("ai-search-options-retrieval-retrieval-type", { - type: "string", - description: "The ai_search_options.retrieval.retrieval_type field", + optional: true, + parse: Number, + }, + "ai-search-options-retrieval-retrieval-type": { + kind: "parsed", + brief: "The ai_search_options.retrieval.retrieval_type field", + optional: true, choices: ["vector", "keyword", "hybrid"], - }) - .coerce("ai-search-options-retrieval-retrieval-type", (value) => - resolveFileToken( - value, - "ai-search-options-retrieval-retrieval-type", - "text" - ) - ) - .option("ai-search-options-retrieval-return-on-failure", { - type: "boolean", - description: "The ai_search_options.retrieval.return_on_failure field", - }) - .option("messages", { - type: "string", - description: + parse: String, + coerce: (value: string) => + resolveFileToken( + value, + "ai-search-options-retrieval-retrieval-type", + "text" + ), + }, + "ai-search-options-retrieval-return-on-failure": { + kind: "boolean", + brief: "The ai_search_options.retrieval.return_on_failure field", + optional: true, + }, + messages: { + kind: "parsed", + brief: "OpenAI-compatible message array. For multimodal queries, set the last user message's `content` to an array of typed parts: `[{type:'text', text:'…'}, {type:'image_url', image_url:{url:'…'}}]`. Image inputs require the RAG's embedding_model to declare 'image' in supported_modalities. Provide as a JSON array of objects or @path/to/file.json. Shape: [{\"content\": (string | [{...}] | null), \"role\": \"system\" | \"developer\" | \"user\" | ...more, \"\": unknown}].", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "search [query]", - describe: "Search", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "instance-id", + brief: "AI Search instance ID.", + parse: String, + }, + { + placeholder: "query", + brief: "Text to search for.", + parse: String, + optional: true, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -196,7 +230,7 @@ const command: CommandModule = { "ai-search-options-retrieval-return-on-failure", "dry-run", ], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -481,6 +515,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/stats.ts b/packages/cli/src/commands/_generated/ai-search/stats.ts index 1b51a1064a..89ad480207 100644 --- a/packages/cli/src/commands/_generated/ai-search/stats.ts +++ b/packages/cli/src/commands/_generated/ai-search/stats.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * stats command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,41 +16,38 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search stats \n\nRetrieve usage and indexing statistics for an AI Search instance." - ) - .positional("instance-id", { - type: "string", - description: "AI Search instance ID.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Namespace to use for this operation.", - default: "default", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "stats ", describe: "Get instance statistics.", - builder, + usage: + "$0 ai-search stats \n\nRetrieve usage and indexing statistics for an AI Search instance.", + flags: { + namespace: { + kind: "parsed", + brief: "Namespace to use for this operation.", + default: "default", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "instance-id", + brief: "AI Search instance ID.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "ai-search stats", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -83,6 +79,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/tokens/create.ts b/packages/cli/src/commands/_generated/ai-search/tokens/create.ts index 0cda884edd..5cb83b590a 100644 --- a/packages/cli/src/commands/_generated/ai-search/tokens/create.ts +++ b/packages/cli/src/commands/_generated/ai-search/tokens/create.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-search/tokens/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -24,53 +23,55 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search tokens create \n\nCreate a stored Cloudflare credential for an AI Search instance to access its data source." - ) - .positional("name", { - type: "string", - description: "Human-readable name for the credential.", - demandOption: true, - }) - .option("api-token-id", { - type: "string", - description: "Cloudflare API token ID.", - }) - .option("api-token", { - type: "string", - description: "Cloudflare API token value.", - }) - .option("legacy", { - type: "boolean", - description: "Whether the credential uses the legacy API key format.", - default: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create ", describe: "Create a token", - builder, + usage: + "$0 ai-search tokens create \n\nCreate a stored Cloudflare credential for an AI Search instance to access its data source.", + flags: { + "api-token-id": { + kind: "parsed", + brief: "Cloudflare API token ID.", + optional: true, + parse: String, + }, + "api-token": { + kind: "parsed", + brief: "Cloudflare API token value.", + optional: true, + parse: String, + }, + legacy: { + kind: "boolean", + brief: "Whether the credential uses the legacy API key format.", + default: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "name", + brief: "Human-readable name for the credential.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "ai-search tokens create", classification: { safeFlags: ["legacy", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -164,6 +165,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/tokens/delete.ts b/packages/cli/src/commands/_generated/ai-search/tokens/delete.ts index 25f270988b..f04ce1289d 100644 --- a/packages/cli/src/commands/_generated/ai-search/tokens/delete.ts +++ b/packages/cli/src/commands/_generated/ai-search/tokens/delete.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,35 +17,31 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search tokens delete \n\nDeletes a stored AI Search credential permanently. Credentials in use by an instance cannot be deleted." - ) - .positional("token-id", { - type: "string", - description: "Stored credential record ID.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete a token", + usage: + "$0 ai-search tokens delete \n\nDeletes a stored AI Search credential permanently. Credentials in use by an instance cannot be deleted.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete a token", - builder, + }, + }, + operands: [ + { + placeholder: "token-id", + brief: "Stored credential record ID.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -54,7 +49,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -92,6 +87,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/tokens/get.ts b/packages/cli/src/commands/_generated/ai-search/tokens/get.ts index 6ab7a2a4d9..c957133707 100644 --- a/packages/cli/src/commands/_generated/ai-search/tokens/get.ts +++ b/packages/cli/src/commands/_generated/ai-search/tokens/get.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,32 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search tokens get \n\nRetrieve a stored AI Search credential without exposing its secret." - ) - .positional("token-id", { - type: "string", - description: "Stored credential record ID.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get a token", - builder, + usage: + "$0 ai-search tokens get \n\nRetrieve a stored AI Search credential without exposing its secret.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "token-id", + brief: "Stored credential record ID.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "ai-search tokens get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -75,6 +70,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/tokens/index.ts b/packages/cli/src/commands/_generated/ai-search/tokens/index.ts index 70b659e5e8..cb5dc12b4c 100644 --- a/packages/cli/src/commands/_generated/ai-search/tokens/index.ts +++ b/packages/cli/src/commands/_generated/ai-search/tokens/index.ts @@ -3,28 +3,23 @@ import $delete from "./delete.js"; import $get from "./get.js"; import $list from "./list.js"; import $update from "./update.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * tokens command group * @generated from apis/overlays/ai-search.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "tokens", describe: "Credentials used by AI Search instances", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($get) - .command($list) - .command($update) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + get: $get, + list: $list, + update: $update, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/tokens/list.ts b/packages/cli/src/commands/_generated/ai-search/tokens/list.ts index 1c4907c783..50177fe264 100644 --- a/packages/cli/src/commands/_generated/ai-search/tokens/list.ts +++ b/packages/cli/src/commands/_generated/ai-search/tokens/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-search/tokens/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,41 +16,45 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search tokens list\n\nLists stored AI Search credentials in the account without exposing their secrets." - ) - .option("page", { type: "number", description: "Page number (1-indexed)." }) - .option("per-page", { - type: "number", - description: "Number of results per page.", - }) - .option("search", { - type: "string", - description: - "Filter tokens whose name contains this string (case-insensitive).", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List tokens", - builder, + usage: + "$0 ai-search tokens list\n\nLists stored AI Search credentials in the account without exposing their secrets.", + flags: { + page: { + kind: "parsed", + brief: "Page number (1-indexed).", + optional: true, + parse: Number, + }, + "per-page": { + kind: "parsed", + brief: "Number of results per page.", + optional: true, + parse: Number, + }, + search: { + kind: "parsed", + brief: + "Filter tokens whose name contains this string (case-insensitive).", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "ai-search tokens list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -82,6 +85,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/tokens/update.ts b/packages/cli/src/commands/_generated/ai-search/tokens/update.ts index f0fd4d83ab..4ea9214724 100644 --- a/packages/cli/src/commands/_generated/ai-search/tokens/update.ts +++ b/packages/cli/src/commands/_generated/ai-search/tokens/update.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,56 +19,61 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search tokens update \n\nReplace a stored AI Search credential and invalidate cached credentials for instances that use it." - ) - .positional("token-id", { - type: "string", - description: "Stored credential record ID.", - demandOption: true, - }) - .option("api-token-id", { - type: "string", - description: "Cloudflare API token ID.", - }) - .option("api-token", { - type: "string", - description: "Cloudflare API token value.", - }) - .option("legacy", { - type: "boolean", - description: "Whether the credential uses the legacy API key format.", - }) - .option("name", { - type: "string", - description: "Human-readable name for the credential.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "update ", describe: "Update a token", - builder, + usage: + "$0 ai-search tokens update \n\nReplace a stored AI Search credential and invalidate cached credentials for instances that use it.", + flags: { + "api-token-id": { + kind: "parsed", + brief: "Cloudflare API token ID.", + optional: true, + parse: String, + }, + "api-token": { + kind: "parsed", + brief: "Cloudflare API token value.", + optional: true, + parse: String, + }, + legacy: { + kind: "boolean", + brief: "Whether the credential uses the legacy API key format.", + optional: true, + }, + name: { + kind: "parsed", + brief: "Human-readable name for the credential.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "token-id", + brief: "Stored credential record ID.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "ai-search tokens update", classification: { safeFlags: ["legacy", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -192,6 +196,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-search/update.ts b/packages/cli/src/commands/_generated/ai-search/update.ts index f7037adf8e..59210141cf 100644 --- a/packages/cli/src/commands/_generated/ai-search/update.ts +++ b/packages/cli/src/commands/_generated/ai-search/update.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/ai-search.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -25,373 +24,479 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-search update \n\nUpdates the configuration of an AI Search instance." - ) - .positional("instance-id", { - type: "string", - description: "AI Search instance ID.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Namespace to use for this operation.", +const command = apiCommand({ + command: "update ", + describe: "Update an AI Search instance.", + usage: + "$0 ai-search update \n\nUpdates the configuration of an AI Search instance.", + flags: { + namespace: { + kind: "parsed", + brief: "Namespace to use for this operation.", default: "default", - }) - .option("ai-gateway-id", { - type: "string", - description: "The ai_gateway_id field", - }) - .option("ai-search-model", { - type: "string", - description: + parse: String, + }, + "ai-gateway-id": { + kind: "parsed", + brief: "The ai_gateway_id field", + optional: true, + parse: String, + }, + "ai-search-model": { + kind: "parsed", + brief: "A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.", - }) - .option("cache", { type: "boolean", description: "The cache field" }) - .option("cache-threshold", { - type: "string", - description: "The cache_threshold field", + optional: true, + parse: String, + }, + cache: { kind: "boolean", brief: "The cache field", optional: true }, + "cache-threshold": { + kind: "parsed", + brief: "The cache_threshold field", + optional: true, choices: [ "super_strict_match", "close_enough", "flexible_friend", "anything_goes", ], - }) - .coerce("cache-threshold", (value) => - resolveFileToken(value, "cache-threshold", "text") - ) - .option("cache-ttl", { - type: "number", - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "cache-threshold", "text"), + }, + "cache-ttl": { + kind: "parsed", + brief: "Cache entry TTL in seconds. Allowed values: 600 (10min), 1800 (30min), 3600 (1h), 7200 (2h), 21600 (6h), 43200 (12h), 86400 (24h), 172800 (48h), 259200 (72h), 518400 (6d).", - }) - .option("chunk", { type: "boolean", description: "The chunk field" }) - .option("chunk-overlap", { - type: "number", - description: "The chunk_overlap field", - }) - .option("chunk-size", { - type: "number", - description: "The chunk_size field", - }) - .option("custom-metadata", { - type: "string", - description: + optional: true, + parse: Number, + }, + chunk: { kind: "boolean", brief: "The chunk field", optional: true }, + "chunk-overlap": { + kind: "parsed", + brief: "The chunk_overlap field", + optional: true, + parse: Number, + }, + "chunk-size": { + kind: "parsed", + brief: "The chunk_size field", + optional: true, + parse: Number, + }, + "custom-metadata": { + kind: "parsed", + brief: 'The custom_metadata field. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"data_type": "text" | "number" | "boolean" | ...more, "field_name": string}].', - }) - .option("embedding-model", { - type: "string", - description: "The embedding_model field", - }) - .option("fusion-method", { - type: "string", - description: "The fusion_method field", + optional: true, + parse: String, + }, + "embedding-model": { + kind: "parsed", + brief: "The embedding_model field", + optional: true, + parse: String, + }, + "fusion-method": { + kind: "parsed", + brief: "The fusion_method field", + optional: true, choices: ["max", "rrf"], - }) - .coerce("fusion-method", (value) => - resolveFileToken(value, "fusion-method", "text") - ) - .option("index-method-keyword", { - type: "boolean", - description: "Enable keyword (BM25) storage backend.", - }) - .option("index-method-vector", { - type: "boolean", - description: "Enable vector (embedding) storage backend.", - }) - .option("indexing-options-file-summary", { - type: "boolean", - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "fusion-method", "text"), + }, + "index-method-keyword": { + kind: "boolean", + brief: "Enable keyword (BM25) storage backend.", + optional: true, + }, + "index-method-vector": { + kind: "boolean", + brief: "Enable vector (embedding) storage backend.", + optional: true, + }, + "indexing-options-file-summary": { + kind: "boolean", + brief: "Generates a per-file summary, topics, and keywords during indexing for text files and media transcripts of at least three chunks. The summary and keywords are stored as the item's context metadata (a context you set is kept), and the topics are added to chunk context headers where they fit. Best effort: a file whose summary fails is indexed without one. The model calls are billed to your account through the instance's AI Gateway. Changing this triggers a full re-index. Defaults to false.", - }) - .option("indexing-options-keyword-tokenizer", { - type: "string", - description: + optional: true, + }, + "indexing-options-keyword-tokenizer": { + kind: "parsed", + brief: "Tokenizer used for keyword search indexing. porter provides word-level tokenization with Porter stemming (good for natural language queries). trigram enables character-level substring matching (good for partial matches, code, identifiers). Changing this triggers a full re-index. Defaults to porter.", + optional: true, choices: ["porter", "trigram"], - }) - .coerce("indexing-options-keyword-tokenizer", (value) => - resolveFileToken(value, "indexing-options-keyword-tokenizer", "text") - ) - .option("indexing-options-use-ocr", { - type: "boolean", - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "indexing-options-keyword-tokenizer", "text"), + }, + "indexing-options-use-ocr": { + kind: "boolean", + brief: "Enables OCR ingestion for PDFs and images. Changing this triggers a full re-index. Defaults to false.", - }) - .option("max-num-results", { - type: "number", - description: "The max_num_results field", - }) - .option("metadata-created-from-aisearch-wizard", { - type: "boolean", - description: "The metadata.created_from_aisearch_wizard field", - }) - .option("metadata-created-from-emdash-plugin-type", { - type: "string", - description: "The metadata.created_from_emdash_plugin.type field", + optional: true, + }, + "max-num-results": { + kind: "parsed", + brief: "The max_num_results field", + optional: true, + parse: Number, + }, + "metadata-created-from-aisearch-wizard": { + kind: "boolean", + brief: "The metadata.created_from_aisearch_wizard field", + optional: true, + }, + "metadata-created-from-emdash-plugin-type": { + kind: "parsed", + brief: "The metadata.created_from_emdash_plugin.type field", + optional: true, choices: ["native", "rest"], - }) - .coerce("metadata-created-from-emdash-plugin-type", (value) => - resolveFileToken( - value, - "metadata-created-from-emdash-plugin-type", - "text" - ) - ) - .option("metadata-created-from-emdash-plugin-version", { - type: "string", - description: "The metadata.created_from_emdash_plugin.version field", - }) - .option("metadata-worker-domain", { - type: "string", - description: "The metadata.worker_domain field", - }) - .option("paused", { type: "boolean", description: "The paused field" }) - .option("public-endpoint-params-authorized-hosts", { - type: "string", - array: true, - description: "The public_endpoint_params.authorized_hosts field", - }) - .option("public-endpoint-params-chat-completions-endpoint-disabled", { - type: "boolean", - description: - "Disable chat completions endpoint for this public endpoint.", - }) - .option("public-endpoint-params-custom-domains", { - type: "string", - array: true, - description: + parse: String, + coerce: (value: string) => + resolveFileToken( + value, + "metadata-created-from-emdash-plugin-type", + "text" + ), + }, + "metadata-created-from-emdash-plugin-version": { + kind: "parsed", + brief: "The metadata.created_from_emdash_plugin.version field", + optional: true, + parse: String, + }, + "metadata-worker-domain": { + kind: "parsed", + brief: "The metadata.worker_domain field", + optional: true, + parse: String, + }, + paused: { kind: "boolean", brief: "The paused field", optional: true }, + "public-endpoint-params-authorized-hosts": { + kind: "parsed", + brief: "The public_endpoint_params.authorized_hosts field", + variadic: true, + optional: true, + parse: String, + }, + "public-endpoint-params-chat-completions-endpoint-disabled": { + kind: "boolean", + brief: "Disable chat completions endpoint for this public endpoint.", + optional: true, + }, + "public-endpoint-params-custom-domains": { + kind: "parsed", + brief: "Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged).", - }) - .option("public-endpoint-params-default-domain-enabled", { - type: "boolean", - description: + variadic: true, + optional: true, + parse: String, + }, + "public-endpoint-params-default-domain-enabled": { + kind: "boolean", + brief: "When false, the instance is reachable only via a registered custom domain and the default .search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true.", - }) - .option("public-endpoint-params-enabled", { - type: "boolean", - description: "The public_endpoint_params.enabled field", - }) - .option("public-endpoint-params-mcp-description", { - type: "string", - description: "The public_endpoint_params.mcp.description field", - }) - .option("public-endpoint-params-mcp-disabled", { - type: "boolean", - description: "Disable MCP endpoint for this public endpoint.", - }) - .option("public-endpoint-params-rate-limit-period-ms", { - type: "number", - description: "The public_endpoint_params.rate_limit.period_ms field", - }) - .option("public-endpoint-params-rate-limit-requests", { - type: "number", - description: "The public_endpoint_params.rate_limit.requests field", - }) - .option("public-endpoint-params-rate-limit-technique", { - type: "string", - description: "The public_endpoint_params.rate_limit.technique field", + optional: true, + }, + "public-endpoint-params-enabled": { + kind: "boolean", + brief: "The public_endpoint_params.enabled field", + optional: true, + }, + "public-endpoint-params-mcp-description": { + kind: "parsed", + brief: "The public_endpoint_params.mcp.description field", + optional: true, + parse: String, + }, + "public-endpoint-params-mcp-disabled": { + kind: "boolean", + brief: "Disable MCP endpoint for this public endpoint.", + optional: true, + }, + "public-endpoint-params-rate-limit-period-ms": { + kind: "parsed", + brief: "The public_endpoint_params.rate_limit.period_ms field", + optional: true, + parse: Number, + }, + "public-endpoint-params-rate-limit-requests": { + kind: "parsed", + brief: "The public_endpoint_params.rate_limit.requests field", + optional: true, + parse: Number, + }, + "public-endpoint-params-rate-limit-technique": { + kind: "parsed", + brief: "The public_endpoint_params.rate_limit.technique field", + optional: true, choices: ["fixed", "sliding"], - }) - .coerce("public-endpoint-params-rate-limit-technique", (value) => - resolveFileToken( - value, - "public-endpoint-params-rate-limit-technique", - "text" - ) - ) - .option("public-endpoint-params-search-endpoint-disabled", { - type: "boolean", - description: "Disable search endpoint for this public endpoint.", - }) - .option("reranking", { - type: "boolean", - description: "The reranking field", - }) - .option("reranking-model", { - type: "string", - description: "The reranking_model field", - }) - .option("retrieval-options-boost-by", { - type: "string", - description: + parse: String, + coerce: (value: string) => + resolveFileToken( + value, + "public-endpoint-params-rate-limit-technique", + "text" + ), + }, + "public-endpoint-params-search-endpoint-disabled": { + kind: "boolean", + brief: "Disable search endpoint for this public endpoint.", + optional: true, + }, + reranking: { + kind: "boolean", + brief: "The reranking field", + optional: true, + }, + "reranking-model": { + kind: "parsed", + brief: "The reranking_model field", + optional: true, + parse: String, + }, + "retrieval-options-boost-by": { + kind: "parsed", + brief: 'Metadata fields to boost search results by. Each entry specifies a metadata field and an optional direction. Direction defaults to \'asc\' for numeric/datetime fields and \'exists\' for text/boolean fields. Fields must match \'timestamp\' or a defined custom_metadata field. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"field": string, "direction"?: "asc" | "desc" | "exists" | ...more}]. ? marks optional keys.', - }) - .option("retrieval-options-keyword-match-mode", { - type: "string", - description: + optional: true, + parse: String, + }, + "retrieval-options-keyword-match-mode": { + kind: "parsed", + brief: "Controls which documents become candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term and ranks results according to BM25 relevance. When omitted on an update, the existing stored value stays unchanged; when never set, search falls back to 'and'.", + optional: true, choices: ["and", "or"], - }) - .coerce("retrieval-options-keyword-match-mode", (value) => - resolveFileToken(value, "retrieval-options-keyword-match-mode", "text") - ) - .option("rewrite-model", { - type: "string", - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "retrieval-options-keyword-match-mode", "text"), + }, + "rewrite-model": { + kind: "parsed", + brief: "A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.", - }) - .option("rewrite-query", { - type: "boolean", - description: "The rewrite_query field", - }) - .option("score-threshold", { - type: "number", - description: + optional: true, + parse: String, + }, + "rewrite-query": { + kind: "boolean", + brief: "The rewrite_query field", + optional: true, + }, + "score-threshold": { + kind: "parsed", + brief: "Minimum similarity score a chunk must reach to be returned. Defaults to 0.4.", - }) - .option("source", { - type: "string", - description: "R2 bucket name or HTTP(S) root website URL to index.", - }) - .option("source-params-d1-query", { - type: "string", - description: + optional: true, + parse: Number, + }, + source: { + kind: "parsed", + brief: "R2 bucket name or HTTP(S) root website URL to index.", + optional: true, + parse: String, + }, + "source-params-d1-query": { + kind: "parsed", + brief: "Read-only SELECT query run against the D1 database. It must return an `id` column that uniquely identifies each row. Columns named `title` and `content` set the document title and body, and up to 5 `meta_*` columns become filterable custom metadata; any other column is indexed as a labelled field. Every sync reads the full result, up to 100,000 rows, with the instance's token, and those reads count against your D1 usage. Leading and trailing whitespace is trimmed before the query is stored. Omit to keep the stored query.", - }) - .option("source-params-d1-template", { - type: "string", - description: + optional: true, + parse: String, + }, + "source-params-d1-template": { + kind: "parsed", + brief: "How each row is rendered into the indexed document: labelled renders the title, the labelled fields, then the content; content_only renders the title and content (labelled fields only when there is no content); key_value renders every column as name: value; json renders every column as a JSON object. Omit to keep the stored template.", + optional: true, choices: ["labelled", "content_only", "key_value", "json"], - }) - .coerce("source-params-d1-template", (value) => - resolveFileToken(value, "source-params-d1-template", "text") - ) - .option("source-params-exclude-items", { - type: "string", - array: true, - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "source-params-d1-template", "text"), + }, + "source-params-exclude-items": { + kind: "parsed", + brief: "List of path patterns to exclude. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /admin/** matches /admin/users and /admin/settings/advanced). Most accounts have a limit of 10 rules; contact support to raise it.", - }) - .option("source-params-include-items", { - type: "string", - array: true, - description: + variadic: true, + optional: true, + parse: String, + }, + "source-params-include-items": { + kind: "parsed", + brief: "List of path patterns to include. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /blog/** matches /blog/post and /blog/2024/post). Most accounts have a limit of 10 rules; contact support to raise it.", - }) - .option("source-params-prefix", { - type: "string", - description: "The source_params.prefix field", - }) - .option("source-params-r2-jurisdiction", { - type: "string", - description: "The source_params.r2_jurisdiction field", - }) - .option("source-params-web-crawler-discover-options-depth", { - type: "number", - description: "Maximum link-follow depth from the seed URL.", - }) - .option( - "source-params-web-crawler-discover-options-include-external-links", - { - type: "boolean", - description: - "Follow links that point outside the source domain. Must stay `false` because discover crawls only cover the zone you own.", - } - ) - .option("source-params-web-crawler-discover-options-include-subdomains", { - type: "boolean", - description: "Follow links to subdomains of the source host.", - }) - .option("source-params-web-crawler-discover-options-limit", { - type: "number", - description: "Maximum number of pages to crawl (1-100000).", - }) - .option("source-params-web-crawler-discover-options-max-age", { - type: "number", - description: "Maximum content age in seconds to accept (0–604800).", - }) - .option("source-params-web-crawler-discover-options-source", { - type: "string", - description: + variadic: true, + optional: true, + parse: String, + }, + "source-params-prefix": { + kind: "parsed", + brief: "The source_params.prefix field", + optional: true, + parse: String, + }, + "source-params-r2-jurisdiction": { + kind: "parsed", + brief: "The source_params.r2_jurisdiction field", + optional: true, + parse: String, + }, + "source-params-web-crawler-discover-options-depth": { + kind: "parsed", + brief: "Maximum link-follow depth from the seed URL.", + optional: true, + parse: Number, + }, + "source-params-web-crawler-discover-options-include-external-links": { + kind: "boolean", + brief: + "Follow links that point outside the source domain. Must stay `false` because discover crawls only cover the zone you own.", + optional: true, + }, + "source-params-web-crawler-discover-options-include-subdomains": { + kind: "boolean", + brief: "Follow links to subdomains of the source host.", + optional: true, + }, + "source-params-web-crawler-discover-options-limit": { + kind: "parsed", + brief: "Maximum number of pages to crawl (1-100000).", + optional: true, + parse: Number, + }, + "source-params-web-crawler-discover-options-max-age": { + kind: "parsed", + brief: "Maximum content age in seconds to accept (0–604800).", + optional: true, + parse: Number, + }, + "source-params-web-crawler-discover-options-source": { + kind: "parsed", + brief: "Where the crawler looks for URLs: 'sitemaps' reads sitemap XML only, 'links' follows page links only, 'all' does both.", + optional: true, choices: ["all", "sitemaps", "links"], - }) - .coerce("source-params-web-crawler-discover-options-source", (value) => - resolveFileToken( - value, - "source-params-web-crawler-discover-options-source", - "text" - ) - ) - .option("source-params-web-crawler-parse-options-content-selector", { - type: "string", - description: + parse: String, + coerce: (value: string) => + resolveFileToken( + value, + "source-params-web-crawler-discover-options-source", + "text" + ), + }, + "source-params-web-crawler-parse-options-content-selector": { + kind: "parsed", + brief: 'List of path-to-selector mappings for extracting specific content from crawled pages. Each entry pairs a URL glob pattern with a CSS selector. The first matching path wins. The crawler stores and indexes only the matched HTML fragment. Omit the field to disable content selection; the API rejects empty arrays. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"path": string, "selector": string}].', - }) - .option("source-params-web-crawler-parse-options-include-headers", { - type: "string", - description: + optional: true, + parse: String, + }, + "source-params-web-crawler-parse-options-include-headers": { + kind: "parsed", + brief: 'Up to 5 custom HTTP headers sent with each crawl request. Names must use RFC-7230 token characters, excluding spaces, colons, and control characters. Values must use HTAB and printable ASCII only, excluding CR and LF. Provide as a JSON object or @path/to/file.json. Shape: {"": string}.', - }) - .option("source-params-web-crawler-parse-options-include-images", { - type: "boolean", - description: - "The source_params.web_crawler.parse_options.include_images field", - }) - .option("source-params-web-crawler-parse-options-specific-sitemaps", { - type: "string", - array: true, - description: + optional: true, + parse: String, + }, + "source-params-web-crawler-parse-options-include-images": { + kind: "boolean", + brief: "The source_params.web_crawler.parse_options.include_images field", + optional: true, + }, + "source-params-web-crawler-parse-options-specific-sitemaps": { + kind: "parsed", + brief: "List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'.", - }) - .option("source-params-web-crawler-parse-options-use-browser-rendering", { - type: "boolean", - description: + variadic: true, + optional: true, + parse: String, + }, + "source-params-web-crawler-parse-options-use-browser-rendering": { + kind: "boolean", + brief: "The source_params.web_crawler.parse_options.use_browser_rendering field", - }) - .option("source-params-web-crawler-parse-type", { - type: "string", - description: + optional: true, + }, + "source-params-web-crawler-parse-type": { + kind: "parsed", + brief: "How the crawler finds URLs. 'sitemap' reads XML sitemaps; 'discover' follows links recursively and requires the source to belong to a Verified zone on this account.", + optional: true, choices: ["sitemap", "discover"], - }) - .coerce("source-params-web-crawler-parse-type", (value) => - resolveFileToken(value, "source-params-web-crawler-parse-type", "text") - ) - .option("summarization", { - type: "boolean", - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "source-params-web-crawler-parse-type", "text"), + }, + summarization: { + kind: "boolean", + brief: "Deprecated and ignored during indexing and search; changing it still re-indexes existing files on the next sync. Use indexing_options.file_summary instead.", - }) - .option("summarization-model", { - type: "string", - description: + optional: true, + }, + "summarization-model": { + kind: "parsed", + brief: "Deprecated and ignored during indexing and search; changing it still re-indexes existing files on the next sync. Use indexing_options.file_summary instead.", - }) - .option("sync-interval", { - type: "number", - description: + optional: true, + parse: String, + }, + "sync-interval": { + kind: "parsed", + brief: "Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). Defaults to 86400 (24h).", - }) - .option("system-prompt-ai-search", { - type: "string", - description: "The system_prompt_ai_search field", - }) - .option("system-prompt-index-summarization", { - type: "string", - description: + optional: true, + parse: Number, + }, + "system-prompt-ai-search": { + kind: "parsed", + brief: "The system_prompt_ai_search field", + optional: true, + parse: String, + }, + "system-prompt-index-summarization": { + kind: "parsed", + brief: "Deprecated and has no effect. Use indexing_options.file_summary instead.", - }) - .option("system-prompt-rewrite-query", { - type: "string", - description: "The system_prompt_rewrite_query field", - }) - .option("token-id", { type: "string", description: "The token_id field" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "system-prompt-rewrite-query": { + kind: "parsed", + brief: "The system_prompt_rewrite_query field", + optional: true, + parse: String, + }, + "token-id": { + kind: "parsed", + brief: "The token_id field", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }) - .check((argv) => { + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "instance-id", + brief: "AI Search instance ID.", + parse: String, + }, + ], + rules(rules) { + rules.check((argv) => { const groupSet = ["index-method-keyword", "index-method-vector"].some( (k) => argv[k] !== undefined ); @@ -406,8 +511,8 @@ function builder(yargs: Argv) { } } return true; - }) - .check((argv) => { + }); + rules.check((argv) => { const groupSet = [ "metadata-created-from-emdash-plugin-type", "metadata-created-from-emdash-plugin-version", @@ -425,14 +530,7 @@ function builder(yargs: Argv) { } return true; }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "update ", - describe: "Update an AI Search instance.", - builder, + }, handler: async (argv): Promise => runWithTelemetry( { @@ -470,7 +568,7 @@ const command: CommandModule = { "summarization", "dry-run", ], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -1281,6 +1379,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-security/custom-topics/get.ts b/packages/cli/src/commands/_generated/ai-security/custom-topics/get.ts index 0eabe2dffa..84e1ae72f0 100644 --- a/packages/cli/src/commands/_generated/ai-security/custom-topics/get.ts +++ b/packages/cli/src/commands/_generated/ai-security/custom-topics/get.ts @@ -1,42 +1,36 @@ import operation from "../../_operations/ai-security/custom-topics/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/ai-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-security custom-topics get\n\nGet the custom topic categories defined for the zone. While AI Security for Apps is enabled, it scores every incoming prompt against these topics and writes the scores to the `cf.llm.prompt.custom_topic_categories` field, keyed by topic label. Topics can be configured while the detection is disabled, but no prompt is scored until you enable it." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get", describe: "Get the AI Security for Apps custom topics of a zone.", - builder, + usage: + "$0 ai-security custom-topics get\n\nGet the custom topic categories defined for the zone. While AI Security for Apps is enabled, it scores every incoming prompt against these topics and writes the scores to the `cf.llm.prompt.custom_topic_categories` field, keyed by topic label. Topics can be configured while the detection is disabled, but no prompt is scored until you enable it.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "ai-security custom-topics get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -64,6 +58,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-security/custom-topics/index.ts b/packages/cli/src/commands/_generated/ai-security/custom-topics/index.ts index 0810d90ba8..f0a6ea16f0 100644 --- a/packages/cli/src/commands/_generated/ai-security/custom-topics/index.ts +++ b/packages/cli/src/commands/_generated/ai-security/custom-topics/index.ts @@ -1,25 +1,20 @@ import $get from "./get.js"; import $update from "./update.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * custom-topics command group * @generated from apis/overlays/ai-security.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "custom-topics", describe: "Organization-specific topic categories used by AI Security for Apps content detection", - builder: (yargs) => { - return yargs - .command($get) - .command($update) - .demandCommand(1, "Please specify a subcommand"); + routes: { + get: $get, + update: $update, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-security/custom-topics/update.ts b/packages/cli/src/commands/_generated/ai-security/custom-topics/update.ts index 750be60515..a59e109962 100644 --- a/packages/cli/src/commands/_generated/ai-security/custom-topics/update.ts +++ b/packages/cli/src/commands/_generated/ai-security/custom-topics/update.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai-security/custom-topics/update.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/ai-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { compactBody, parseBody, parseObjectArray } from "#lib/body-parser.js"; import { formatDryRun } from "#lib/dry-run.js"; @@ -14,39 +13,38 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-security custom-topics update\n\nUpdate the custom topic list of the zone, overwriting it entirely with the topics in the request, so include every topic you want to keep. Changes can take up to a minute to propagate. Each entry has a `label`, used to reference the topic in rule expressions and analytics, and a `topic` description, which the classifier scores prompts against while AI Security for Apps is enabled. The following rules apply: - A zone can hold at most 20 topics. - `label` must be 2–20 characters, using only lowercase letters (a–z), digits (0–9), and hyphens. - `topic` must be 2–50 UTF-8 bytes. Text in any language is supported, including spaces, numbers, punctuation, and symbols. Tabs, line breaks, invalid text, and invisible formatting characters are not allowed. - Labels must be unique within the zone, and so must topic descriptions." - ) - .option("topics", { - type: "string", - description: +const command = apiCommand({ + command: "update", + describe: "Update the AI Security for Apps custom topics of a zone.", + usage: + "$0 ai-security custom-topics update\n\nUpdate the custom topic list of the zone, overwriting it entirely with the topics in the request, so include every topic you want to keep. Changes can take up to a minute to propagate. Each entry has a `label`, used to reference the topic in rule expressions and analytics, and a `topic` description, which the classifier scores prompts against while AI Security for Apps is enabled. The following rules apply: - A zone can hold at most 20 topics. - `label` must be 2–20 characters, using only lowercase letters (a–z), digits (0–9), and hyphens. - `topic` must be 2–50 UTF-8 bytes. Text in any language is supported, including spaces, numbers, punctuation, and symbols. Tabs, line breaks, invalid text, and invisible formatting characters are not allowed. - Labels must be unique within the zone, and so must topic descriptions.", + flags: { + topics: { + kind: "parsed", + brief: 'Custom topic categories for AI Security for Apps content detection. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"label": string, "topic": string}].', - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "update", - describe: "Update the AI Security for Apps custom topics of a zone.", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { @@ -54,7 +52,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -112,6 +110,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-security/get.ts b/packages/cli/src/commands/_generated/ai-security/get.ts index c7374336fe..3d82015748 100644 --- a/packages/cli/src/commands/_generated/ai-security/get.ts +++ b/packages/cli/src/commands/_generated/ai-security/get.ts @@ -1,42 +1,36 @@ import operation from "../_operations/ai-security/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/ai-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-security get\n\nGet the current AI Security for Apps status for the zone. While enabled, Cloudflare scans prompts sent to endpoints labeled `cf-llm` for personally identifiable information, unsafe topics, and prompt injection attempts." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get", describe: "Get the AI Security for Apps status for a zone.", - builder, + usage: + "$0 ai-security get\n\nGet the current AI Security for Apps status for the zone. While enabled, Cloudflare scans prompts sent to endpoints labeled `cf-llm` for personally identifiable information, unsafe topics, and prompt injection attempts.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "ai-security get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -64,6 +58,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-security/index.ts b/packages/cli/src/commands/_generated/ai-security/index.ts index 4498c16075..5284cc7f4c 100644 --- a/packages/cli/src/commands/_generated/ai-security/index.ts +++ b/packages/cli/src/commands/_generated/ai-security/index.ts @@ -1,27 +1,22 @@ import $customtopics from "./custom-topics/index.js"; import $get from "./get.js"; import $update from "./update.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * ai-security command * @generated from apis/overlays/ai-security.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "ai-security", describe: "Detect prompt injection, PII, and unsafe topics in traffic to your AI applications", - builder: (yargs) => { - return yargs - .command($get) - .command($update) - .command($customtopics) - .demandCommand(1, "Please specify a subcommand"); + routes: { + get: $get, + update: $update, + "custom-topics": $customtopics, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai-security/update.ts b/packages/cli/src/commands/_generated/ai-security/update.ts index 3c48a3e9a6..c609890215 100644 --- a/packages/cli/src/commands/_generated/ai-security/update.ts +++ b/packages/cli/src/commands/_generated/ai-security/update.ts @@ -1,11 +1,10 @@ import operation from "../_operations/ai-security/update.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/ai-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { compactBody, parseBody } from "#lib/body-parser.js"; import { formatDryRun } from "#lib/dry-run.js"; @@ -14,38 +13,36 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai-security update\n\nUpdate the AI Security for Apps status for the zone, enabling or disabling the detection. The detection results are exposed as `cf.llm.prompt.*` fields for use in custom rules and rate limiting rules; changes can take up to a minute to propagate." - ) - .option("enabled", { - type: "boolean", - description: "Whether AI Security for Apps is enabled on the zone.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "update", + describe: "Update the AI Security for Apps status for a zone.", + usage: + "$0 ai-security update\n\nUpdate the AI Security for Apps status for the zone, enabling or disabling the detection. The detection results are exposed as `cf.llm.prompt.*` fields for use in custom rules and rate limiting rules; changes can take up to a minute to propagate.", + flags: { + enabled: { + kind: "boolean", + brief: "Whether AI Security for Apps is enabled on the zone.", + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }) - .option("body", { - type: "string", - description: "AI Security for Apps enablement status for a zone.", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "update", - describe: "Update the AI Security for Apps status for a zone.", - builder, + }, + body: { + kind: "parsed", + brief: "AI Security for Apps enablement status for a zone.", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { @@ -53,7 +50,7 @@ const command: CommandModule = { classification: { safeFlags: ["enabled", "dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -111,6 +108,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai/authors/index.ts b/packages/cli/src/commands/_generated/ai/authors/index.ts index 133917d223..18d2163007 100644 --- a/packages/cli/src/commands/_generated/ai/authors/index.ts +++ b/packages/cli/src/commands/_generated/ai/authors/index.ts @@ -1,20 +1,17 @@ import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * authors command group * @generated from apis/overlays/ai.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "authors", describe: "Operations for authors", - builder: (yargs) => { - return yargs.command($list).demandCommand(1, "Please specify a subcommand"); + routes: { + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai/authors/list.ts b/packages/cli/src/commands/_generated/ai/authors/list.ts index d17a149a79..2496f7d0ef 100644 --- a/packages/cli/src/commands/_generated/ai/authors/list.ts +++ b/packages/cli/src/commands/_generated/ai/authors/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai/authors/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/ai.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai authors list\n\nSearches Workers AI models by author or organization name." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "Author Search", - builder, + usage: + "$0 ai authors list\n\nSearches Workers AI models by author or organization name.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "ai authors list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai/finetunes/assets/create.ts b/packages/cli/src/commands/_generated/ai/finetunes/assets/create.ts index f9dd5c82db..2da47d59e7 100644 --- a/packages/cli/src/commands/_generated/ai/finetunes/assets/create.ts +++ b/packages/cli/src/commands/_generated/ai/finetunes/assets/create.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/ai.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,49 +17,47 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai finetunes assets create \n\nUploads training data assets for a Workers AI fine-tuning job." - ) - .positional("finetune-id", { - type: "string", - description: "Finetune ID", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Finetune asset file upload.", - }) - .option("file", { - type: "string", - description: "Path to a file to upload as the request body", - }) - .option("file-name", { - type: "string", - description: - "Name of the file (adapter_config.json or adapter_model.safetensors).", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create ", describe: "Upload a Finetune Asset", - builder, + usage: + "$0 ai finetunes assets create \n\nUploads training data assets for a Workers AI fine-tuning job.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Finetune asset file upload.", + optional: true, + parse: String, + }, + file: { + kind: "parsed", + brief: "Path to a file to upload as the request body", + optional: true, + parse: String, + }, + "file-name": { + kind: "parsed", + brief: + "Name of the file (adapter_config.json or adapter_model.safetensors).", + optional: true, + parse: String, + }, + }, + operands: [ + { placeholder: "finetune-id", brief: "Finetune ID", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "ai finetunes assets create", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -152,6 +149,6 @@ const command: CommandModule = { } } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai/finetunes/assets/download.ts b/packages/cli/src/commands/_generated/ai/finetunes/assets/download.ts index bcfd36aec0..59148602a4 100644 --- a/packages/cli/src/commands/_generated/ai/finetunes/assets/download.ts +++ b/packages/cli/src/commands/_generated/ai/finetunes/assets/download.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/ai/finetunes/assets/download.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * download command * @generated from apis/overlays/ai.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,41 +16,27 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai finetunes assets download \n\nReturns a pre-signed R2 URL for downloading a finetune asset file." - ) - .positional("file-name", { - type: "string", - description: "File name", - demandOption: true, - }) - .option("finetune-id", { - type: "string", - description: "Finetune ID", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "download ", describe: "Download a Finetune Asset", - builder, + usage: + "$0 ai finetunes assets download \n\nReturns a pre-signed R2 URL for downloading a finetune asset file.", + flags: { + "finetune-id": { kind: "parsed", brief: "Finetune ID", parse: String }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [{ placeholder: "file-name", brief: "File name", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "ai finetunes assets download", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -83,6 +68,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai/finetunes/assets/index.ts b/packages/cli/src/commands/_generated/ai/finetunes/assets/index.ts index e5720e357a..f09c67062f 100644 --- a/packages/cli/src/commands/_generated/ai/finetunes/assets/index.ts +++ b/packages/cli/src/commands/_generated/ai/finetunes/assets/index.ts @@ -1,24 +1,19 @@ import $create from "./create.js"; import $download from "./download.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * assets command group * @generated from apis/overlays/ai.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "assets", describe: "Operations for finetunes.assets", - builder: (yargs) => { - return yargs - .command($create) - .command($download) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + download: $download, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai/finetunes/create.ts b/packages/cli/src/commands/_generated/ai/finetunes/create.ts index ed4d4d4aed..5ced7459b8 100644 --- a/packages/cli/src/commands/_generated/ai/finetunes/create.ts +++ b/packages/cli/src/commands/_generated/ai/finetunes/create.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai/finetunes/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/ai.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,46 +19,51 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai finetunes create\n\nCreates a new fine-tuning job for a Workers AI model using custom training data." - ) - .option("description", { - type: "string", - description: "The description field", - }) - .option("model", { type: "string", description: "The model field" }) - .option("name", { type: "string", description: "The name field" }) - .option("public", { - type: "boolean", - description: "The public field", - default: false, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create", describe: "Create a new Finetune", - builder, + usage: + "$0 ai finetunes create\n\nCreates a new fine-tuning job for a Workers AI model using custom training data.", + flags: { + description: { + kind: "parsed", + brief: "The description field", + optional: true, + parse: String, + }, + model: { + kind: "parsed", + brief: "The model field", + optional: true, + parse: String, + }, + name: { + kind: "parsed", + brief: "The name field", + optional: true, + parse: String, + }, + public: { kind: "boolean", brief: "The public field", default: false }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "ai finetunes create", classification: { safeFlags: ["public", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -153,6 +157,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai/finetunes/delete.ts b/packages/cli/src/commands/_generated/ai/finetunes/delete.ts index 0e18f32625..d54b66e071 100644 --- a/packages/cli/src/commands/_generated/ai/finetunes/delete.ts +++ b/packages/cli/src/commands/_generated/ai/finetunes/delete.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai/finetunes/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/ai.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,35 +17,27 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai finetunes delete \n\nDelete a finetune. Any in-flight requests referencing the lora will fail after the files are deleted." - ) - .positional("finetune-id", { - type: "string", - description: "Finetune ID", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete a Finetune", + usage: + "$0 ai finetunes delete \n\nDelete a finetune. Any in-flight requests referencing the lora will fail after the files are deleted.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete a Finetune", - builder, + }, + }, + operands: [ + { placeholder: "finetune-id", brief: "Finetune ID", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -54,7 +45,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -86,6 +77,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai/finetunes/index.ts b/packages/cli/src/commands/_generated/ai/finetunes/index.ts index fe6bade1bc..50317497bd 100644 --- a/packages/cli/src/commands/_generated/ai/finetunes/index.ts +++ b/packages/cli/src/commands/_generated/ai/finetunes/index.ts @@ -3,28 +3,23 @@ import $create from "./create.js"; import $delete from "./delete.js"; import $list from "./list.js"; import $public from "./public/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * finetunes command group * @generated from apis/overlays/ai.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "finetunes", describe: "Operations for finetunes", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($list) - .command($assets) - .command($public) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + list: $list, + assets: $assets, + public: $public, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai/finetunes/list.ts b/packages/cli/src/commands/_generated/ai/finetunes/list.ts index 4ffbe0d182..d163c0e3b1 100644 --- a/packages/cli/src/commands/_generated/ai/finetunes/list.ts +++ b/packages/cli/src/commands/_generated/ai/finetunes/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai/finetunes/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/ai.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai finetunes list\n\nLists all fine-tuning jobs created by the account, including status and metrics." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List Finetunes", - builder, + usage: + "$0 ai finetunes list\n\nLists all fine-tuning jobs created by the account, including status and metrics.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "ai finetunes list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai/finetunes/public/index.ts b/packages/cli/src/commands/_generated/ai/finetunes/public/index.ts index 0830f8b5c9..ceef2cc948 100644 --- a/packages/cli/src/commands/_generated/ai/finetunes/public/index.ts +++ b/packages/cli/src/commands/_generated/ai/finetunes/public/index.ts @@ -1,20 +1,17 @@ import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * public command group * @generated from apis/overlays/ai.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "public", describe: "Operations for finetunes.public", - builder: (yargs) => { - return yargs.command($list).demandCommand(1, "Please specify a subcommand"); + routes: { + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai/finetunes/public/list.ts b/packages/cli/src/commands/_generated/ai/finetunes/public/list.ts index 1c62e466ef..963482f88e 100644 --- a/packages/cli/src/commands/_generated/ai/finetunes/public/list.ts +++ b/packages/cli/src/commands/_generated/ai/finetunes/public/list.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/ai/finetunes/public/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/ai.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,37 +16,44 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai finetunes public list\n\nLists publicly available fine-tuned models that can be used with Workers AI." - ) - .option("limit", { type: "number", description: "Pagination Limit." }) - .option("offset", { type: "number", description: "Pagination Offset." }) - .option("order-by", { - type: "string", - description: "Order By Column Name.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List Public Finetunes", - builder, + usage: + "$0 ai finetunes public list\n\nLists publicly available fine-tuned models that can be used with Workers AI.", + flags: { + limit: { + kind: "parsed", + brief: "Pagination Limit.", + optional: true, + parse: Number, + }, + offset: { + kind: "parsed", + brief: "Pagination Offset.", + optional: true, + parse: Number, + }, + "order-by": { + kind: "parsed", + brief: "Order By Column Name.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "ai finetunes public list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -78,6 +84,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai/get-model-schema.ts b/packages/cli/src/commands/_generated/ai/get-model-schema.ts index 2175805799..9afc963e86 100644 --- a/packages/cli/src/commands/_generated/ai/get-model-schema.ts +++ b/packages/cli/src/commands/_generated/ai/get-model-schema.ts @@ -1,11 +1,10 @@ import operation from "../_operations/ai/get-model-schema.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get-model-schema command * @generated from apis/overlays/ai.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,37 +16,31 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai get-model-schema\n\nRetrieves the input and output JSON Schema definitions for an AI model. Use these definitions to determine the model-specific request fields and response format." - ) - .option("model", { - type: "string", - description: - "AI model identifier, including its namespace and model name.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get-model-schema", describe: "Get an AI model's input and output schemas", - builder, + usage: + "$0 ai get-model-schema\n\nRetrieves the input and output JSON Schema definitions for an AI model. Use these definitions to determine the model-specific request fields and response format.", + flags: { + model: { + kind: "parsed", + brief: "AI model identifier, including its namespace and model name.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "ai get-model-schema", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -76,6 +69,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai/index.ts b/packages/cli/src/commands/_generated/ai/index.ts index 794eb3eff0..d22212bd86 100644 --- a/packages/cli/src/commands/_generated/ai/index.ts +++ b/packages/cli/src/commands/_generated/ai/index.ts @@ -6,33 +6,28 @@ import $models from "./models/index.js"; import $tasks from "./tasks/index.js"; import $tomarkdown from "./to-markdown.js"; import $websearch from "./websearch.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; +import $run from "#commands/ai/run/index.js"; /** * ai command * @generated from apis/overlays/ai.ts */ -import type { CommandModule } from "yargs"; -import $run from "#commands/ai/run/index.js"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "ai", describe: "ai", - builder: (yargs) => { - return yargs - .command($getmodelschema) - .command($listmarkdownsupportedformats) - .command($run) - .command($tomarkdown) - .command($websearch) - .command($authors) - .command($finetunes) - .command($models) - .command($tasks) - .demandCommand(1, "Please specify a subcommand"); + routes: { + "get-model-schema": $getmodelschema, + "list-markdown-supported-formats": $listmarkdownsupportedformats, + run: $run, + "to-markdown": $tomarkdown, + websearch: $websearch, + authors: $authors, + finetunes: $finetunes, + models: $models, + tasks: $tasks, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai/list-markdown-supported-formats.ts b/packages/cli/src/commands/_generated/ai/list-markdown-supported-formats.ts index d65849ea9d..c9c2349dd5 100644 --- a/packages/cli/src/commands/_generated/ai/list-markdown-supported-formats.ts +++ b/packages/cli/src/commands/_generated/ai/list-markdown-supported-formats.ts @@ -1,11 +1,10 @@ import operation from "../_operations/ai/list-markdown-supported-formats.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list-markdown-supported-formats command * @generated from apis/overlays/ai.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai list-markdown-supported-formats\n\nLists the file extensions and MIME types accepted by Workers AI's Markdown conversion endpoint. Use this list to check whether a file can be converted before uploading it." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list-markdown-supported-formats", describe: "List supported Markdown conversion formats", - builder, + usage: + "$0 ai list-markdown-supported-formats\n\nLists the file extensions and MIME types accepted by Workers AI's Markdown conversion endpoint. Use this list to check whether a file can be converted before uploading it.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "ai list-markdown-supported-formats", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai/models/index.ts b/packages/cli/src/commands/_generated/ai/models/index.ts index 5682a68026..9a0d3e49ae 100644 --- a/packages/cli/src/commands/_generated/ai/models/index.ts +++ b/packages/cli/src/commands/_generated/ai/models/index.ts @@ -1,20 +1,17 @@ import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * models command group * @generated from apis/overlays/ai.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "models", describe: "Operations for models", - builder: (yargs) => { - return yargs.command($list).demandCommand(1, "Please specify a subcommand"); + routes: { + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai/models/list.ts b/packages/cli/src/commands/_generated/ai/models/list.ts index 037516a5ba..7ead13a858 100644 --- a/packages/cli/src/commands/_generated/ai/models/list.ts +++ b/packages/cli/src/commands/_generated/ai/models/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai/models/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/ai.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,45 +16,63 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai models list\n\nSearches Workers AI models by name or description." - ) - .option("per-page", { type: "number", description: "Per page" }) - .option("page", { type: "number", description: "Page" }) - .option("task", { type: "string", description: "Filter by Task Name." }) - .option("author", { type: "string", description: "Filter by Author." }) - .option("source", { type: "number", description: "Filter by Source Id." }) - .option("hide-experimental", { - type: "boolean", - description: "Filter to hide experimental models.", - }) - .option("search", { type: "string", description: "Search." }) - .option("include-deprecated", { - type: "boolean", - description: +const command = apiCommand({ + command: "list", + describe: "Model Search", + usage: + "$0 ai models list\n\nSearches Workers AI models by name or description.", + flags: { + "per-page": { + kind: "parsed", + brief: "Per page", + optional: true, + parse: Number, + }, + page: { kind: "parsed", brief: "Page", optional: true, parse: Number }, + task: { + kind: "parsed", + brief: "Filter by Task Name.", + optional: true, + parse: String, + }, + author: { + kind: "parsed", + brief: "Filter by Author.", + optional: true, + parse: String, + }, + source: { + kind: "parsed", + brief: "Filter by Source Id.", + optional: true, + parse: Number, + }, + "hide-experimental": { + kind: "boolean", + brief: "Filter to hide experimental models.", + optional: true, + }, + search: { kind: "parsed", brief: "Search.", optional: true, parse: String }, + "include-deprecated": { + kind: "boolean", + brief: "If true, include models for up to three months after their deprecation date. Defaults to false.", - }) - .option("format", { - type: "string", - description: + optional: true, + }, + format: { + kind: "enum", + brief: "If set, return models in the requested marketplace format instead of the default response.", - choices: ["openrouter"], - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + values: ["openrouter"], + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "list", - describe: "Model Search", - builder, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { @@ -67,7 +84,7 @@ const command: CommandModule = { "format", "dry-run", ], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -104,6 +121,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai/tasks/index.ts b/packages/cli/src/commands/_generated/ai/tasks/index.ts index bcc416504a..8728b9f06f 100644 --- a/packages/cli/src/commands/_generated/ai/tasks/index.ts +++ b/packages/cli/src/commands/_generated/ai/tasks/index.ts @@ -1,20 +1,17 @@ import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * tasks command group * @generated from apis/overlays/ai.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "tasks", describe: "Operations for tasks", - builder: (yargs) => { - return yargs.command($list).demandCommand(1, "Please specify a subcommand"); + routes: { + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai/tasks/list.ts b/packages/cli/src/commands/_generated/ai/tasks/list.ts index 306e6f94b1..20727103c0 100644 --- a/packages/cli/src/commands/_generated/ai/tasks/list.ts +++ b/packages/cli/src/commands/_generated/ai/tasks/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/ai/tasks/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/ai.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai tasks list\n\nSearches Workers AI models by task type (e.g., text-generation, embeddings)." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "Task Search", - builder, + usage: + "$0 ai tasks list\n\nSearches Workers AI models by task type (e.g., text-generation, embeddings).", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "ai tasks list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai/to-markdown.ts b/packages/cli/src/commands/_generated/ai/to-markdown.ts index f23d5b24c0..8d1895a63f 100644 --- a/packages/cli/src/commands/_generated/ai/to-markdown.ts +++ b/packages/cli/src/commands/_generated/ai/to-markdown.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * to-markdown command * @generated from apis/overlays/ai.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,46 +17,47 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai to-markdown\n\nConverts files uploaded as multipart form data into Markdown using Workers AI. Returns a conversion result for each file. Use the supported-formats endpoint to check accepted file types." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }) - .option("file", { - type: "string", - description: "Path to a file to upload as the request body", - }) - .option("files", { - type: "string", - array: true, - requiresArg: true, - description: - "Literal content or @path/to/file for the `files` form field. Repeat for multiple files. Files to convert, supplied as multipart file uploads.", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "to-markdown", describe: "Convert uploaded files to Markdown", - builder, + usage: + "$0 ai to-markdown\n\nConverts files uploaded as multipart form data into Markdown using Workers AI. Returns a conversion result for each file. Use the supported-formats endpoint to check accepted file types.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + file: { + kind: "parsed", + brief: "Path to a file to upload as the request body", + optional: true, + parse: String, + }, + files: { + kind: "parsed", + brief: + "Literal content or @path/to/file for the `files` form field. Repeat for multiple files. Files to convert, supplied as multipart file uploads.", + variadic: true, + optional: true, + requiresArg: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "ai to-markdown", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -157,6 +157,6 @@ const command: CommandModule = { } } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/ai/websearch.ts b/packages/cli/src/commands/_generated/ai/websearch.ts index ff6aeecb8f..a914edaab3 100644 --- a/packages/cli/src/commands/_generated/ai/websearch.ts +++ b/packages/cli/src/commands/_generated/ai/websearch.ts @@ -1,11 +1,10 @@ import operation from "../_operations/ai/websearch.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * websearch command * @generated from apis/overlays/ai.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,46 +19,61 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 ai websearch\n\nRun a web search through a configured AI Gateway." - ) - .option("byok-alias", { - type: "string", - description: "The byokAlias field", - }) - .option("limit", { type: "number", description: "The limit field" }) - .option("options-gateway-id", { - type: "string", - description: "The options.gateway.id field", - }) - .option("provider", { type: "string", description: "The provider field" }) - .option("query", { type: "string", description: "The query field" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "websearch", describe: "Search the web through AI Gateway", - builder, + usage: "$0 ai websearch\n\nRun a web search through a configured AI Gateway.", + flags: { + "byok-alias": { + kind: "parsed", + brief: "The byokAlias field", + optional: true, + parse: String, + }, + limit: { + kind: "parsed", + brief: "The limit field", + optional: true, + parse: Number, + }, + "options-gateway-id": { + kind: "parsed", + brief: "The options.gateway.id field", + optional: true, + parse: String, + }, + provider: { + kind: "parsed", + brief: "The provider field", + optional: true, + parse: String, + }, + query: { + kind: "parsed", + brief: "The query field", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "ai websearch", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -171,6 +185,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/available-alerts/index.ts b/packages/cli/src/commands/_generated/alerting/available-alerts/index.ts index f6a64555ab..da6d603ede 100644 --- a/packages/cli/src/commands/_generated/alerting/available-alerts/index.ts +++ b/packages/cli/src/commands/_generated/alerting/available-alerts/index.ts @@ -1,20 +1,17 @@ import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * available-alerts command group * @generated from apis/overlays/alerting.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "available-alerts", describe: "Operations for available-alerts", - builder: (yargs) => { - return yargs.command($list).demandCommand(1, "Please specify a subcommand"); + routes: { + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/available-alerts/list.ts b/packages/cli/src/commands/_generated/alerting/available-alerts/list.ts index 64c15a0128..bac78e6510 100644 --- a/packages/cli/src/commands/_generated/alerting/available-alerts/list.ts +++ b/packages/cli/src/commands/_generated/alerting/available-alerts/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/alerting/available-alerts/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/alerting.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 alerting available-alerts list\n\nGets a list of all alert types for which an account is eligible." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "Get Alert Types", - builder, + usage: + "$0 alerting available-alerts list\n\nGets a list of all alert types for which an account is eligible.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "alerting available-alerts list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/destinations/eligible/get.ts b/packages/cli/src/commands/_generated/alerting/destinations/eligible/get.ts index 5b678813f1..0567d78ce8 100644 --- a/packages/cli/src/commands/_generated/alerting/destinations/eligible/get.ts +++ b/packages/cli/src/commands/_generated/alerting/destinations/eligible/get.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/alerting/destinations/eligible/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/alerting.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 alerting destinations eligible get\n\nGet a list of all delivery mechanism types for which an account is eligible." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get", describe: "Get delivery mechanism eligibility", - builder, + usage: + "$0 alerting destinations eligible get\n\nGet a list of all delivery mechanism types for which an account is eligible.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "alerting destinations eligible get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/destinations/eligible/index.ts b/packages/cli/src/commands/_generated/alerting/destinations/eligible/index.ts index 74c3881fba..12b6436b40 100644 --- a/packages/cli/src/commands/_generated/alerting/destinations/eligible/index.ts +++ b/packages/cli/src/commands/_generated/alerting/destinations/eligible/index.ts @@ -1,20 +1,17 @@ import $get from "./get.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * eligible command group * @generated from apis/overlays/alerting.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "eligible", describe: "Operations for destinations.eligible", - builder: (yargs) => { - return yargs.command($get).demandCommand(1, "Please specify a subcommand"); + routes: { + get: $get, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/destinations/index.ts b/packages/cli/src/commands/_generated/alerting/destinations/index.ts index 0bb57b520e..97b3e30809 100644 --- a/packages/cli/src/commands/_generated/alerting/destinations/index.ts +++ b/packages/cli/src/commands/_generated/alerting/destinations/index.ts @@ -1,26 +1,21 @@ import $eligible from "./eligible/index.js"; import $pagerduty from "./pagerduty/index.js"; import $webhooks from "./webhooks/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * destinations command group * @generated from apis/overlays/alerting.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "destinations", describe: "Operations for destinations", - builder: (yargs) => { - return yargs - .command($eligible) - .command($pagerduty) - .command($webhooks) - .demandCommand(1, "Please specify a subcommand"); + routes: { + eligible: $eligible, + pagerduty: $pagerduty, + webhooks: $webhooks, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/destinations/pagerduty/create.ts b/packages/cli/src/commands/_generated/alerting/destinations/pagerduty/create.ts index 66f29af84d..211c0f57f2 100644 --- a/packages/cli/src/commands/_generated/alerting/destinations/pagerduty/create.ts +++ b/packages/cli/src/commands/_generated/alerting/destinations/pagerduty/create.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/alerting/destinations/pagerduty/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/alerting.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 alerting destinations pagerduty create\n\nCreates a new token for integrating with PagerDuty." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create", describe: "Create PagerDuty integration token", - builder, + usage: + "$0 alerting destinations pagerduty create\n\nCreates a new token for integrating with PagerDuty.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "alerting destinations pagerduty create", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/destinations/pagerduty/delete.ts b/packages/cli/src/commands/_generated/alerting/destinations/pagerduty/delete.ts index e8e3306e6e..990018efcc 100644 --- a/packages/cli/src/commands/_generated/alerting/destinations/pagerduty/delete.ts +++ b/packages/cli/src/commands/_generated/alerting/destinations/pagerduty/delete.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/alerting/destinations/pagerduty/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/alerting.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,30 +17,25 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 alerting destinations pagerduty delete\n\nDeletes all the PagerDuty Services connected to the account." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete", + describe: "Delete PagerDuty Services", + usage: + "$0 alerting destinations pagerduty delete\n\nDeletes all the PagerDuty Services connected to the account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete", - describe: "Delete PagerDuty Services", - builder, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { @@ -49,7 +43,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -83,6 +77,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/destinations/pagerduty/get.ts b/packages/cli/src/commands/_generated/alerting/destinations/pagerduty/get.ts index 5c741161ca..e0aeaaa0b8 100644 --- a/packages/cli/src/commands/_generated/alerting/destinations/pagerduty/get.ts +++ b/packages/cli/src/commands/_generated/alerting/destinations/pagerduty/get.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/alerting/destinations/pagerduty/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/alerting.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 alerting destinations pagerduty get\n\nGet a list of all configured PagerDuty services." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get", describe: "List PagerDuty services", - builder, + usage: + "$0 alerting destinations pagerduty get\n\nGet a list of all configured PagerDuty services.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "alerting destinations pagerduty get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/destinations/pagerduty/index.ts b/packages/cli/src/commands/_generated/alerting/destinations/pagerduty/index.ts index 0a5f16bde4..2eac8b7344 100644 --- a/packages/cli/src/commands/_generated/alerting/destinations/pagerduty/index.ts +++ b/packages/cli/src/commands/_generated/alerting/destinations/pagerduty/index.ts @@ -2,27 +2,22 @@ import $create from "./create.js"; import $delete from "./delete.js"; import $get from "./get.js"; import $link from "./link.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * pagerduty command group * @generated from apis/overlays/alerting.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "pagerduty", describe: "Operations for destinations.pagerduty", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($get) - .command($link) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + get: $get, + link: $link, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/destinations/pagerduty/link.ts b/packages/cli/src/commands/_generated/alerting/destinations/pagerduty/link.ts index 56754f877e..2ea21deda9 100644 --- a/packages/cli/src/commands/_generated/alerting/destinations/pagerduty/link.ts +++ b/packages/cli/src/commands/_generated/alerting/destinations/pagerduty/link.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/alerting/destinations/pagerduty/link.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * link command * @generated from apis/overlays/alerting.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,32 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 alerting destinations pagerduty link \n\nLinks PagerDuty with the account using the integration token." - ) - .positional("token-id", { - type: "string", - description: "The token integration key", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "link ", describe: "Connect PagerDuty", - builder, + usage: + "$0 alerting destinations pagerduty link \n\nLinks PagerDuty with the account using the integration token.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "token-id", + brief: "The token integration key", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "alerting destinations pagerduty link", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -74,6 +69,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/destinations/webhooks/create.ts b/packages/cli/src/commands/_generated/alerting/destinations/webhooks/create.ts index 5fb8c098cb..430d4f07e3 100644 --- a/packages/cli/src/commands/_generated/alerting/destinations/webhooks/create.ts +++ b/packages/cli/src/commands/_generated/alerting/destinations/webhooks/create.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/alerting/destinations/webhooks/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/alerting.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,49 +19,52 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 alerting destinations webhooks create\n\nCreates a new webhook destination." - ) - .option("name", { - type: "string", - description: +const command = apiCommand({ + command: "create", + describe: "Create a webhook", + usage: + "$0 alerting destinations webhooks create\n\nCreates a new webhook destination.", + flags: { + name: { + kind: "parsed", + brief: "The name of the webhook destination. This will be included in the request body when you receive a webhook notification.", - }) - .option("secret", { - type: "string", - description: + optional: true, + parse: String, + }, + secret: { + kind: "parsed", + brief: "Optional secret that will be passed in the `cf-webhook-auth` header when dispatching generic webhook notifications or formatted for supported destinations. Secrets are not returned in any API response body.", - }) - .option("url", { - type: "string", - description: "The POST endpoint to call when dispatching a notification.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + url: { + kind: "parsed", + brief: "The POST endpoint to call when dispatching a notification.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "create", - describe: "Create a webhook", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "alerting destinations webhooks create", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -155,6 +157,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/destinations/webhooks/delete.ts b/packages/cli/src/commands/_generated/alerting/destinations/webhooks/delete.ts index a1d8bb0faf..bbe0851e04 100644 --- a/packages/cli/src/commands/_generated/alerting/destinations/webhooks/delete.ts +++ b/packages/cli/src/commands/_generated/alerting/destinations/webhooks/delete.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/alerting/destinations/webhooks/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/alerting.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,35 +17,31 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 alerting destinations webhooks delete \n\nDelete a configured webhook destination." - ) - .positional("webhook-id", { - type: "string", - description: "The unique identifier of a webhook", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete a webhook", + usage: + "$0 alerting destinations webhooks delete \n\nDelete a configured webhook destination.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete a webhook", - builder, + }, + }, + operands: [ + { + placeholder: "webhook-id", + brief: "The unique identifier of a webhook", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -54,7 +49,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -91,6 +86,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/destinations/webhooks/get.ts b/packages/cli/src/commands/_generated/alerting/destinations/webhooks/get.ts index 82871b6afb..3f23687735 100644 --- a/packages/cli/src/commands/_generated/alerting/destinations/webhooks/get.ts +++ b/packages/cli/src/commands/_generated/alerting/destinations/webhooks/get.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/alerting/destinations/webhooks/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/alerting.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,32 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 alerting destinations webhooks get \n\nGet details for a single webhooks destination." - ) - .positional("webhook-id", { - type: "string", - description: "The unique identifier of a webhook", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get a webhook", - builder, + usage: + "$0 alerting destinations webhooks get \n\nGet details for a single webhooks destination.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "webhook-id", + brief: "The unique identifier of a webhook", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "alerting destinations webhooks get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -74,6 +69,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/destinations/webhooks/index.ts b/packages/cli/src/commands/_generated/alerting/destinations/webhooks/index.ts index b97c5df929..ed07a9cebe 100644 --- a/packages/cli/src/commands/_generated/alerting/destinations/webhooks/index.ts +++ b/packages/cli/src/commands/_generated/alerting/destinations/webhooks/index.ts @@ -3,28 +3,23 @@ import $delete from "./delete.js"; import $get from "./get.js"; import $list from "./list.js"; import $update from "./update.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * webhooks command group * @generated from apis/overlays/alerting.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "webhooks", describe: "Operations for destinations.webhooks", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($get) - .command($list) - .command($update) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + get: $get, + list: $list, + update: $update, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/destinations/webhooks/list.ts b/packages/cli/src/commands/_generated/alerting/destinations/webhooks/list.ts index 264cc1907a..ba222d7a88 100644 --- a/packages/cli/src/commands/_generated/alerting/destinations/webhooks/list.ts +++ b/packages/cli/src/commands/_generated/alerting/destinations/webhooks/list.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/alerting/destinations/webhooks/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/alerting.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 alerting destinations webhooks list\n\nGets a list of all configured webhook destinations." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List webhooks", - builder, + usage: + "$0 alerting destinations webhooks list\n\nGets a list of all configured webhook destinations.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "alerting destinations webhooks list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/destinations/webhooks/update.ts b/packages/cli/src/commands/_generated/alerting/destinations/webhooks/update.ts index 01b2a63b6c..7dd77d1468 100644 --- a/packages/cli/src/commands/_generated/alerting/destinations/webhooks/update.ts +++ b/packages/cli/src/commands/_generated/alerting/destinations/webhooks/update.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/alerting/destinations/webhooks/update.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/alerting.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,45 +19,45 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 alerting destinations webhooks update \n\nUpdate a webhook destination. Only `name` can be updated. `url` and `secret` are immutable; to change them, delete the webhook and create a new one." - ) - .positional("webhook-id", { - type: "string", - description: "The unique identifier of a webhook", - demandOption: true, - }) - .option("name", { - type: "string", - description: - "The name of the webhook destination. This will be included in the request body when you receive a webhook notification.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "update ", describe: "Update a webhook", - builder, + usage: + "$0 alerting destinations webhooks update \n\nUpdate a webhook destination. Only `name` can be updated. `url` and `secret` are immutable; to change them, delete the webhook and create a new one.", + flags: { + name: { + kind: "parsed", + brief: + "The name of the webhook destination. This will be included in the request body when you receive a webhook notification.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "webhook-id", + brief: "The unique identifier of a webhook", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "alerting destinations webhooks update", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -132,6 +131,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/history/index.ts b/packages/cli/src/commands/_generated/alerting/history/index.ts index 6878db0fd7..236694fede 100644 --- a/packages/cli/src/commands/_generated/alerting/history/index.ts +++ b/packages/cli/src/commands/_generated/alerting/history/index.ts @@ -1,20 +1,17 @@ import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * history command group * @generated from apis/overlays/alerting.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "history", describe: "Operations for history", - builder: (yargs) => { - return yargs.command($list).demandCommand(1, "Please specify a subcommand"); + routes: { + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/history/list.ts b/packages/cli/src/commands/_generated/alerting/history/list.ts index 37cab838be..21254f3ecd 100644 --- a/packages/cli/src/commands/_generated/alerting/history/list.ts +++ b/packages/cli/src/commands/_generated/alerting/history/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/alerting/history/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/alerting.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,49 +16,52 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 alerting history list\n\nGets a list of history records for notifications sent to an account. The records are displayed for last `x` number of days based on the zone plan (free = 30, pro = 30, biz = 30, ent = 90)." - ) - .option("per-page", { - type: "number", - description: "Number of items per page.", - }) - .option("before", { - type: "string", - description: +const command = apiCommand({ + command: "list", + describe: "List History", + usage: + "$0 alerting history list\n\nGets a list of history records for notifications sent to an account. The records are displayed for last `x` number of days based on the zone plan (free = 30, pro = 30, biz = 30, ent = 90).", + flags: { + "per-page": { + kind: "parsed", + brief: "Number of items per page.", + optional: true, + parse: Number, + }, + before: { + kind: "parsed", + brief: "Limit the returned results to history records older than the specified date. This must be a timestamp that conforms to RFC3339.", - }) - .option("page", { - type: "number", - description: "Page number of paginated results.", - }) - .option("since", { - type: "string", - description: + optional: true, + parse: String, + }, + page: { + kind: "parsed", + brief: "Page number of paginated results.", + optional: true, + parse: Number, + }, + since: { + kind: "parsed", + brief: "Limit the returned results to history records newer than the specified date. This must be a timestamp that conforms to RFC3339.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "list", - describe: "List History", - builder, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "alerting history list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -91,6 +93,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/index.ts b/packages/cli/src/commands/_generated/alerting/index.ts index dd2312fbd4..b01aaad3d5 100644 --- a/packages/cli/src/commands/_generated/alerting/index.ts +++ b/packages/cli/src/commands/_generated/alerting/index.ts @@ -3,28 +3,23 @@ import $destinations from "./destinations/index.js"; import $history from "./history/index.js"; import $policies from "./policies/index.js"; import $silences from "./silences/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * alerting command * @generated from apis/overlays/alerting.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "alerting", describe: "alerting", - builder: (yargs) => { - return yargs - .command($availablealerts) - .command($destinations) - .command($history) - .command($policies) - .command($silences) - .demandCommand(1, "Please specify a subcommand"); + routes: { + "available-alerts": $availablealerts, + destinations: $destinations, + history: $history, + policies: $policies, + silences: $silences, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/policies/create.ts b/packages/cli/src/commands/_generated/alerting/policies/create.ts index ef5502d1f9..8b34841ac4 100644 --- a/packages/cli/src/commands/_generated/alerting/policies/create.ts +++ b/packages/cli/src/commands/_generated/alerting/policies/create.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/alerting/policies/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/alerting.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -23,18 +22,23 @@ import { } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage("$0 alerting policies create\n\nCreates a new Notification policy.") - .option("alert-interval", { - type: "string", - description: +const command = apiCommand({ + command: "create", + describe: "Create a Notification policy", + usage: "$0 alerting policies create\n\nCreates a new Notification policy.", + flags: { + "alert-interval": { + kind: "parsed", + brief: "Optional specification of how often to re-alert from the same incident, not support on all alert types.", - }) - .option("alert-type", { - type: "string", - description: + optional: true, + parse: String, + }, + "alert-type": { + kind: "parsed", + brief: "Refers to which event will trigger a Notification dispatch. You can use the endpoint to get available alert types which then will give you a list of possible values. This enum lists every alert type, not the ones a given account can create, since some types depend on entitlements or account type. To get the alert types an account can create, call `GET /accounts/{account_id}/alerting/v3/available_alerts`.", + optional: true, choices: [ "abuse_report_alert", "access_custom_certificate_expiration_type", @@ -128,298 +132,400 @@ function builder(yargs: Argv) { "workers_observability_real_time_issue", "zone_aop_custom_certificate_expiration_type", ], - }) - .coerce("alert-type", (value) => - resolveFileToken(value, "alert-type", "text") - ) - .option("description", { - type: "string", - description: "Optional description for the Notification policy.", - }) - .option("enabled", { - type: "boolean", - description: "Whether or not the Notification policy is enabled.", + parse: String, + coerce: (value: string) => resolveFileToken(value, "alert-type", "text"), + }, + description: { + kind: "parsed", + brief: "Optional description for the Notification policy.", + optional: true, + parse: String, + }, + enabled: { + kind: "boolean", + brief: "Whether or not the Notification policy is enabled.", default: true, - }) - .option("filters-actions", { - type: "string", - array: true, - description: "Usage depends on specific alert type", - }) - .option("filters-affected-asns", { - type: "string", - array: true, - description: "Used for configuring radar_notification", - }) - .option("filters-affected-components", { - type: "string", - array: true, - description: "Used for configuring incident_alert", - }) - .option("filters-affected-locations", { - type: "string", - array: true, - description: "Used for configuring radar_notification", - }) - .option("filters-airport-code", { - type: "string", - array: true, - description: "Used for configuring maintenance_event_notification", - }) - .option("filters-alert-trigger-preferences", { - type: "string", - array: true, - description: "Usage depends on specific alert type", - }) - .option("filters-alert-trigger-preferences-value", { - type: "string", - array: true, - description: "Usage depends on specific alert type", - }) - .option("filters-check-id", { - type: "string", - array: true, - description: + }, + "filters-actions": { + kind: "parsed", + brief: "Usage depends on specific alert type", + variadic: true, + optional: true, + parse: String, + }, + "filters-affected-asns": { + kind: "parsed", + brief: "Used for configuring radar_notification", + variadic: true, + optional: true, + parse: String, + }, + "filters-affected-components": { + kind: "parsed", + brief: "Used for configuring incident_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-affected-locations": { + kind: "parsed", + brief: "Used for configuring radar_notification", + variadic: true, + optional: true, + parse: String, + }, + "filters-airport-code": { + kind: "parsed", + brief: "Used for configuring maintenance_event_notification", + variadic: true, + optional: true, + parse: String, + }, + "filters-alert-trigger-preferences": { + kind: "parsed", + brief: "Usage depends on specific alert type", + variadic: true, + optional: true, + parse: String, + }, + "filters-alert-trigger-preferences-value": { + kind: "parsed", + brief: "Usage depends on specific alert type", + variadic: true, + optional: true, + parse: String, + }, + "filters-check-id": { + kind: "parsed", + brief: "Used for configuring magic_endpoint_healthcheck_alert. Takes one or more health check IDs, each a UUID. That alert type requires check_id together with alert_trigger_preferences set to slo, a numeric alert_trigger_preferences_value, and selectors set to failures.", - }) - .option("filters-enabled", { - type: "string", - array: true, - description: "Used for configuring load_balancing_pool_enablement_alert", - }) - .option("filters-environment", { - type: "string", - array: true, - description: "Used for configuring pages_event_alert", - }) - .option("filters-event", { - type: "string", - array: true, - description: "Used for configuring pages_event_alert", - }) - .option("filters-event-source", { - type: "string", - array: true, - description: "Used for configuring load_balancing_health_alert", - }) - .option("filters-event-type", { - type: "string", - array: true, - description: "Usage depends on specific alert type", - }) - .option("filters-group-by", { - type: "string", - array: true, - description: "Usage depends on specific alert type", - }) - .option("filters-health-check-id", { - type: "string", - array: true, - description: "Used for configuring health_check_status_notification", - }) - .option("filters-incident-impact", { - type: "string", - array: true, - description: "Used for configuring incident_alert", - }) - .option("filters-input-id", { - type: "string", - array: true, - description: "Used for configuring stream_live_notifications", - }) - .option("filters-insight-class", { - type: "string", - array: true, - description: "Used for configuring security_insights_alert", - }) - .option("filters-limit", { - type: "string", - array: true, - description: "Used for configuring billing_usage_alert", - }) - .option("filters-logo-tag", { - type: "string", - array: true, - description: "Used for configuring logo_match_alert", - }) - .option("filters-megabits-per-second", { - type: "string", - array: true, - description: "Used for configuring advanced_ddos_attack_l4_alert", - }) - .option("filters-new-health", { - type: "string", - array: true, - description: "Used for configuring load_balancing_health_alert", - }) - .option("filters-new-status", { - type: "string", - array: true, - description: "Used for configuring tunnel_health_event", - }) - .option("filters-packets-per-second", { - type: "string", - array: true, - description: "Used for configuring advanced_ddos_attack_l4_alert", - }) - .option("filters-pool-id", { - type: "string", - array: true, - description: "Usage depends on specific alert type", - }) - .option("filters-pop-names", { - type: "string", - array: true, - description: "Usage depends on specific alert type", - }) - .option("filters-product", { - type: "string", - array: true, - description: "Used for configuring billing_usage_alert", - }) - .option("filters-project-id", { - type: "string", - array: true, - description: "Used for configuring pages_event_alert", - }) - .option("filters-protocol", { - type: "string", - array: true, - description: "Used for configuring advanced_ddos_attack_l4_alert", - }) - .option("filters-query-id", { - type: "string", - array: true, - description: + variadic: true, + optional: true, + parse: String, + }, + "filters-enabled": { + kind: "parsed", + brief: "Used for configuring load_balancing_pool_enablement_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-environment": { + kind: "parsed", + brief: "Used for configuring pages_event_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-event": { + kind: "parsed", + brief: "Used for configuring pages_event_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-event-source": { + kind: "parsed", + brief: "Used for configuring load_balancing_health_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-event-type": { + kind: "parsed", + brief: "Usage depends on specific alert type", + variadic: true, + optional: true, + parse: String, + }, + "filters-group-by": { + kind: "parsed", + brief: "Usage depends on specific alert type", + variadic: true, + optional: true, + parse: String, + }, + "filters-health-check-id": { + kind: "parsed", + brief: "Used for configuring health_check_status_notification", + variadic: true, + optional: true, + parse: String, + }, + "filters-incident-impact": { + kind: "parsed", + brief: "Used for configuring incident_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-input-id": { + kind: "parsed", + brief: "Used for configuring stream_live_notifications", + variadic: true, + optional: true, + parse: String, + }, + "filters-insight-class": { + kind: "parsed", + brief: "Used for configuring security_insights_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-limit": { + kind: "parsed", + brief: "Used for configuring billing_usage_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-logo-tag": { + kind: "parsed", + brief: "Used for configuring logo_match_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-megabits-per-second": { + kind: "parsed", + brief: "Used for configuring advanced_ddos_attack_l4_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-new-health": { + kind: "parsed", + brief: "Used for configuring load_balancing_health_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-new-status": { + kind: "parsed", + brief: "Used for configuring tunnel_health_event", + variadic: true, + optional: true, + parse: String, + }, + "filters-packets-per-second": { + kind: "parsed", + brief: "Used for configuring advanced_ddos_attack_l4_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-pool-id": { + kind: "parsed", + brief: "Usage depends on specific alert type", + variadic: true, + optional: true, + parse: String, + }, + "filters-pop-names": { + kind: "parsed", + brief: "Usage depends on specific alert type", + variadic: true, + optional: true, + parse: String, + }, + "filters-product": { + kind: "parsed", + brief: "Used for configuring billing_usage_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-project-id": { + kind: "parsed", + brief: "Used for configuring pages_event_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-protocol": { + kind: "parsed", + brief: "Used for configuring advanced_ddos_attack_l4_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-query-id": { + kind: "parsed", + brief: "Used for configuring stakeout_saved_query_daily_digest_alert and stakeout_saved_query_immediate_alert, which require it. Takes exactly one value, the saved query ID.", - }) - .option("filters-query-tag", { - type: "string", - array: true, - description: "Usage depends on specific alert type", - }) - .option("filters-requests-per-second", { - type: "string", - array: true, - description: "Used for configuring advanced_ddos_attack_l7_alert", - }) - .option("filters-selectors", { - type: "string", - array: true, - description: "Usage depends on specific alert type", - }) - .option("filters-services", { - type: "string", - array: true, - description: "Used for configuring clickhouse_alert_fw_ent_anomaly", - }) - .option("filters-slo", { - type: "string", - array: true, - description: "Usage depends on specific alert type", - }) - .option("filters-status", { - type: "string", - array: true, - description: "Used for configuring health_check_status_notification", - }) - .option("filters-target-hostname", { - type: "string", - array: true, - description: "Used for configuring advanced_ddos_attack_l7_alert", - }) - .option("filters-target-ip", { - type: "string", - array: true, - description: "Used for configuring advanced_ddos_attack_l4_alert", - }) - .option("filters-target-zone-name", { - type: "string", - array: true, - description: "Used for configuring advanced_ddos_attack_l7_alert", - }) - .option("filters-token-id", { - type: "string", - array: true, - description: + variadic: true, + optional: true, + parse: String, + }, + "filters-query-tag": { + kind: "parsed", + brief: "Usage depends on specific alert type", + variadic: true, + optional: true, + parse: String, + }, + "filters-requests-per-second": { + kind: "parsed", + brief: "Used for configuring advanced_ddos_attack_l7_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-selectors": { + kind: "parsed", + brief: "Usage depends on specific alert type", + variadic: true, + optional: true, + parse: String, + }, + "filters-services": { + kind: "parsed", + brief: "Used for configuring clickhouse_alert_fw_ent_anomaly", + variadic: true, + optional: true, + parse: String, + }, + "filters-slo": { + kind: "parsed", + brief: "Usage depends on specific alert type", + variadic: true, + optional: true, + parse: String, + }, + "filters-status": { + kind: "parsed", + brief: "Used for configuring health_check_status_notification", + variadic: true, + optional: true, + parse: String, + }, + "filters-target-hostname": { + kind: "parsed", + brief: "Used for configuring advanced_ddos_attack_l7_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-target-ip": { + kind: "parsed", + brief: "Used for configuring advanced_ddos_attack_l4_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-target-zone-name": { + kind: "parsed", + brief: "Used for configuring advanced_ddos_attack_l7_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-token-id": { + kind: "parsed", + brief: "Access service token IDs to include for expiring_service_token_alert. Omit this property to include all current and future service tokens.", - }) - .option("filters-total-spend-dollars", { - type: "string", - array: true, - description: + variadic: true, + optional: true, + parse: String, + }, + "filters-total-spend-dollars": { + kind: "parsed", + brief: "Used for configuring billing_budget_alert. Takes exactly one value, the budget threshold in US dollars, as a string greater than zero.", - }) - .option("filters-traffic-exclusions", { - type: "string", - array: true, - description: "Used for configuring traffic_anomalies_alert", - }) - .option("filters-tunnel-id", { - type: "string", - array: true, - description: "Used for configuring tunnel_health_event", - }) - .option("filters-tunnel-name", { - type: "string", - array: true, - description: "Usage depends on specific alert type", - }) - .option("filters-type", { - type: "string", - array: true, - description: "Usage depends on specific alert type", - }) - .option("filters-where", { - type: "string", - array: true, - description: "Usage depends on specific alert type", - }) - .option("filters-zones", { - type: "string", - array: true, - description: "Usage depends on specific alert type", - }) - .option("mechanisms-email", { - type: "string", - description: + variadic: true, + optional: true, + parse: String, + }, + "filters-traffic-exclusions": { + kind: "parsed", + brief: "Used for configuring traffic_anomalies_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-tunnel-id": { + kind: "parsed", + brief: "Used for configuring tunnel_health_event", + variadic: true, + optional: true, + parse: String, + }, + "filters-tunnel-name": { + kind: "parsed", + brief: "Usage depends on specific alert type", + variadic: true, + optional: true, + parse: String, + }, + "filters-type": { + kind: "parsed", + brief: "Usage depends on specific alert type", + variadic: true, + optional: true, + parse: String, + }, + "filters-where": { + kind: "parsed", + brief: "Usage depends on specific alert type", + variadic: true, + optional: true, + parse: String, + }, + "filters-zones": { + kind: "parsed", + brief: "Usage depends on specific alert type", + variadic: true, + optional: true, + parse: String, + }, + "mechanisms-email": { + kind: "parsed", + brief: 'The mechanisms.email field. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"id"?: string}]. ? marks optional keys.', - }) - .option("mechanisms-pagerduty", { - type: "string", - description: + optional: true, + parse: String, + }, + "mechanisms-pagerduty": { + kind: "parsed", + brief: 'The mechanisms.pagerduty field. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"id"?: string}]. ? marks optional keys.', - }) - .option("mechanisms-webhooks", { - type: "string", - description: + optional: true, + parse: String, + }, + "mechanisms-webhooks": { + kind: "parsed", + brief: 'The mechanisms.webhooks field. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"id"?: string}]. ? marks optional keys.', - }) - .option("name", { type: "string", description: "Name of the policy." }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + name: { + kind: "parsed", + brief: "Name of the policy.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "create", - describe: "Create a Notification policy", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "alerting policies create", classification: { safeFlags: ["alert-type", "enabled", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -743,6 +849,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/policies/delete.ts b/packages/cli/src/commands/_generated/alerting/policies/delete.ts index b8a9ab7270..15499e0350 100644 --- a/packages/cli/src/commands/_generated/alerting/policies/delete.ts +++ b/packages/cli/src/commands/_generated/alerting/policies/delete.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/alerting/policies/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/alerting.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,35 +17,31 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 alerting policies delete \n\nDelete a Notification policy." - ) - .positional("policy-id", { - type: "string", - description: "The unique identifier of a notification policy", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete a Notification policy", + usage: + "$0 alerting policies delete \n\nDelete a Notification policy.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete a Notification policy", - builder, + }, + }, + operands: [ + { + placeholder: "policy-id", + brief: "The unique identifier of a notification policy", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -54,7 +49,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -91,6 +86,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/policies/email/details.ts b/packages/cli/src/commands/_generated/alerting/policies/email/details.ts index 95ef2e3f7c..811dc891ec 100644 --- a/packages/cli/src/commands/_generated/alerting/policies/email/details.ts +++ b/packages/cli/src/commands/_generated/alerting/policies/email/details.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * details command * @generated from apis/overlays/alerting.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,46 +16,34 @@ import { withProgress } from "#lib/progress.js"; import { fetchRawBytes, writeRawOutput } from "#lib/raw-fetch.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 alerting policies email details \n\nShows details for unsubscribing an email address from a notification policy." - ) - .positional("policy-id", { - type: "string", - description: "The unique identifier of a notification policy", - demandOption: true, - }) - .option("email", { - type: "string", - description: "Email", - demandOption: true, - }) - .option("token", { - type: "string", - description: "Token", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "details ", describe: "Show email unsubscribe details", - builder, + usage: + "$0 alerting policies email details \n\nShows details for unsubscribing an email address from a notification policy.", + flags: { + email: { kind: "parsed", brief: "Email", parse: String }, + token: { kind: "parsed", brief: "Token", parse: String }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "policy-id", + brief: "The unique identifier of a notification policy", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "alerting policies email details", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -99,6 +86,6 @@ const command: CommandModule = { return; } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/policies/email/index.ts b/packages/cli/src/commands/_generated/alerting/policies/email/index.ts index a87a622f2f..bd36bc0735 100644 --- a/packages/cli/src/commands/_generated/alerting/policies/email/index.ts +++ b/packages/cli/src/commands/_generated/alerting/policies/email/index.ts @@ -1,24 +1,19 @@ import $details from "./details.js"; import $unsubscribe from "./unsubscribe.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * email command group * @generated from apis/overlays/alerting.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "email", describe: "Operations for policies.email", - builder: (yargs) => { - return yargs - .command($details) - .command($unsubscribe) - .demandCommand(1, "Please specify a subcommand"); + routes: { + details: $details, + unsubscribe: $unsubscribe, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/policies/email/unsubscribe.ts b/packages/cli/src/commands/_generated/alerting/policies/email/unsubscribe.ts index d8cbb163bd..bf74b9d541 100644 --- a/packages/cli/src/commands/_generated/alerting/policies/email/unsubscribe.ts +++ b/packages/cli/src/commands/_generated/alerting/policies/email/unsubscribe.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * unsubscribe command * @generated from apis/overlays/alerting.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,46 +16,34 @@ import { withProgress } from "#lib/progress.js"; import { fetchRawBytes, writeRawOutput } from "#lib/raw-fetch.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 alerting policies email unsubscribe \n\nUnsubscribes an email address from a notification policy." - ) - .positional("policy-id", { - type: "string", - description: "The unique identifier of a notification policy", - demandOption: true, - }) - .option("email", { - type: "string", - description: "Email", - demandOption: true, - }) - .option("token", { - type: "string", - description: "Token", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "unsubscribe ", describe: "Unsubscribe email from a Notification policy", - builder, + usage: + "$0 alerting policies email unsubscribe \n\nUnsubscribes an email address from a notification policy.", + flags: { + email: { kind: "parsed", brief: "Email", parse: String }, + token: { kind: "parsed", brief: "Token", parse: String }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "policy-id", + brief: "The unique identifier of a notification policy", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "alerting policies email unsubscribe", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -99,6 +86,6 @@ const command: CommandModule = { return; } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/policies/get.ts b/packages/cli/src/commands/_generated/alerting/policies/get.ts index fa43db2077..0dc223c609 100644 --- a/packages/cli/src/commands/_generated/alerting/policies/get.ts +++ b/packages/cli/src/commands/_generated/alerting/policies/get.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/alerting/policies/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/alerting.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,32 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 alerting policies get \n\nGet details for a single policy." - ) - .positional("policy-id", { - type: "string", - description: "The unique identifier of a notification policy", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get a Notification policy", - builder, + usage: + "$0 alerting policies get \n\nGet details for a single policy.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "policy-id", + brief: "The unique identifier of a notification policy", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "alerting policies get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -74,6 +69,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/policies/index.ts b/packages/cli/src/commands/_generated/alerting/policies/index.ts index 36ef0a527f..7de51d0614 100644 --- a/packages/cli/src/commands/_generated/alerting/policies/index.ts +++ b/packages/cli/src/commands/_generated/alerting/policies/index.ts @@ -5,30 +5,25 @@ import $get from "./get.js"; import $list from "./list.js"; import $test from "./test.js"; import $update from "./update.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * policies command group * @generated from apis/overlays/alerting.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "policies", describe: "Operations for policies", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($get) - .command($list) - .command($test) - .command($update) - .command($email) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + get: $get, + list: $list, + test: $test, + update: $update, + email: $email, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/policies/list.ts b/packages/cli/src/commands/_generated/alerting/policies/list.ts index 91310ef965..3212358811 100644 --- a/packages/cli/src/commands/_generated/alerting/policies/list.ts +++ b/packages/cli/src/commands/_generated/alerting/policies/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/alerting/policies/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/alerting.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 alerting policies list\n\nGet a list of all Notification policies." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List Notification policies", - builder, + usage: + "$0 alerting policies list\n\nGet a list of all Notification policies.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "alerting policies list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/policies/test.ts b/packages/cli/src/commands/_generated/alerting/policies/test.ts index e8421a9d3c..7c3bedf4dd 100644 --- a/packages/cli/src/commands/_generated/alerting/policies/test.ts +++ b/packages/cli/src/commands/_generated/alerting/policies/test.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/alerting/policies/test.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * test command * @generated from apis/overlays/alerting.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,60 +18,66 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 alerting policies test \n\nSend a test notification for a policy to verify delivery mechanisms are working as expected." - ) - .positional("policy-id", { - type: "string", - description: "The unique identifier of a notification policy", - demandOption: true, - }) - .option("severity", { - type: "number", - description: +const command = apiCommand({ + command: "test ", + describe: "Test a Notification policy", + usage: + "$0 alerting policies test \n\nSend a test notification for a policy to verify delivery mechanisms are working as expected.", + flags: { + severity: { + kind: "parsed", + brief: "Severity level for the test alert. Defaults to INFO (1) if omitted.", - }) - .option("source", { - type: "string", - description: "Source identifier for the test alert.", - }) - .option("state-correlation-id", { - type: "string", - description: + optional: true, + parse: Number, + }, + source: { + kind: "parsed", + brief: "Source identifier for the test alert.", + optional: true, + parse: String, + }, + "state-correlation-id": { + kind: "parsed", + brief: "Correlation ID for stateful test alerts. Required when state_event is set.", - }) - .option("state-event", { - type: "number", - description: + optional: true, + parse: String, + }, + "state-event": { + kind: "parsed", + brief: "State event type for stateful test alerts. Use with state_correlation_id.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: + }, + body: { + kind: "parsed", + brief: "Optional configuration for the test notification. When omitted, a default INFO-severity test alert is sent.", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "test ", - describe: "Test a Notification policy", - builder, + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "policy-id", + brief: "The unique identifier of a notification policy", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "alerting policies test", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -148,6 +153,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/policies/update.ts b/packages/cli/src/commands/_generated/alerting/policies/update.ts index eb3bce6357..271111b9a4 100644 --- a/packages/cli/src/commands/_generated/alerting/policies/update.ts +++ b/packages/cli/src/commands/_generated/alerting/policies/update.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/alerting/policies/update.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/alerting.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,25 +18,24 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 alerting policies update \n\nUpdate a Notification policy." - ) - .positional("policy-id", { - type: "string", - description: "The unique identifier of a notification policy", - demandOption: true, - }) - .option("alert-interval", { - type: "string", - description: +const command = apiCommand({ + command: "update ", + describe: "Update a Notification policy", + usage: + "$0 alerting policies update \n\nUpdate a Notification policy.", + flags: { + "alert-interval": { + kind: "parsed", + brief: "Optional specification of how often to re-alert from the same incident, not support on all alert types.", - }) - .option("alert-type", { - type: "string", - description: + optional: true, + parse: String, + }, + "alert-type": { + kind: "parsed", + brief: "Refers to which event will trigger a Notification dispatch. You can use the endpoint to get available alert types which then will give you a list of possible values. This enum lists every alert type, not the ones a given account can create, since some types depend on entitlements or account type. To get the alert types an account can create, call `GET /accounts/{account_id}/alerting/v3/available_alerts`.", + optional: true, choices: [ "abuse_report_alert", "access_custom_certificate_expiration_type", @@ -131,297 +129,406 @@ function builder(yargs: Argv) { "workers_observability_real_time_issue", "zone_aop_custom_certificate_expiration_type", ], - }) - .coerce("alert-type", (value) => - resolveFileToken(value, "alert-type", "text") - ) - .option("description", { - type: "string", - description: "Optional description for the Notification policy.", - }) - .option("enabled", { - type: "boolean", - description: "Whether or not the Notification policy is enabled.", - }) - .option("filters-actions", { - type: "string", - array: true, - description: "Usage depends on specific alert type", - }) - .option("filters-affected-asns", { - type: "string", - array: true, - description: "Used for configuring radar_notification", - }) - .option("filters-affected-components", { - type: "string", - array: true, - description: "Used for configuring incident_alert", - }) - .option("filters-affected-locations", { - type: "string", - array: true, - description: "Used for configuring radar_notification", - }) - .option("filters-airport-code", { - type: "string", - array: true, - description: "Used for configuring maintenance_event_notification", - }) - .option("filters-alert-trigger-preferences", { - type: "string", - array: true, - description: "Usage depends on specific alert type", - }) - .option("filters-alert-trigger-preferences-value", { - type: "string", - array: true, - description: "Usage depends on specific alert type", - }) - .option("filters-check-id", { - type: "string", - array: true, - description: + parse: String, + coerce: (value: string) => resolveFileToken(value, "alert-type", "text"), + }, + description: { + kind: "parsed", + brief: "Optional description for the Notification policy.", + optional: true, + parse: String, + }, + enabled: { + kind: "boolean", + brief: "Whether or not the Notification policy is enabled.", + optional: true, + }, + "filters-actions": { + kind: "parsed", + brief: "Usage depends on specific alert type", + variadic: true, + optional: true, + parse: String, + }, + "filters-affected-asns": { + kind: "parsed", + brief: "Used for configuring radar_notification", + variadic: true, + optional: true, + parse: String, + }, + "filters-affected-components": { + kind: "parsed", + brief: "Used for configuring incident_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-affected-locations": { + kind: "parsed", + brief: "Used for configuring radar_notification", + variadic: true, + optional: true, + parse: String, + }, + "filters-airport-code": { + kind: "parsed", + brief: "Used for configuring maintenance_event_notification", + variadic: true, + optional: true, + parse: String, + }, + "filters-alert-trigger-preferences": { + kind: "parsed", + brief: "Usage depends on specific alert type", + variadic: true, + optional: true, + parse: String, + }, + "filters-alert-trigger-preferences-value": { + kind: "parsed", + brief: "Usage depends on specific alert type", + variadic: true, + optional: true, + parse: String, + }, + "filters-check-id": { + kind: "parsed", + brief: "Used for configuring magic_endpoint_healthcheck_alert. Takes one or more health check IDs, each a UUID. That alert type requires check_id together with alert_trigger_preferences set to slo, a numeric alert_trigger_preferences_value, and selectors set to failures.", - }) - .option("filters-enabled", { - type: "string", - array: true, - description: "Used for configuring load_balancing_pool_enablement_alert", - }) - .option("filters-environment", { - type: "string", - array: true, - description: "Used for configuring pages_event_alert", - }) - .option("filters-event", { - type: "string", - array: true, - description: "Used for configuring pages_event_alert", - }) - .option("filters-event-source", { - type: "string", - array: true, - description: "Used for configuring load_balancing_health_alert", - }) - .option("filters-event-type", { - type: "string", - array: true, - description: "Usage depends on specific alert type", - }) - .option("filters-group-by", { - type: "string", - array: true, - description: "Usage depends on specific alert type", - }) - .option("filters-health-check-id", { - type: "string", - array: true, - description: "Used for configuring health_check_status_notification", - }) - .option("filters-incident-impact", { - type: "string", - array: true, - description: "Used for configuring incident_alert", - }) - .option("filters-input-id", { - type: "string", - array: true, - description: "Used for configuring stream_live_notifications", - }) - .option("filters-insight-class", { - type: "string", - array: true, - description: "Used for configuring security_insights_alert", - }) - .option("filters-limit", { - type: "string", - array: true, - description: "Used for configuring billing_usage_alert", - }) - .option("filters-logo-tag", { - type: "string", - array: true, - description: "Used for configuring logo_match_alert", - }) - .option("filters-megabits-per-second", { - type: "string", - array: true, - description: "Used for configuring advanced_ddos_attack_l4_alert", - }) - .option("filters-new-health", { - type: "string", - array: true, - description: "Used for configuring load_balancing_health_alert", - }) - .option("filters-new-status", { - type: "string", - array: true, - description: "Used for configuring tunnel_health_event", - }) - .option("filters-packets-per-second", { - type: "string", - array: true, - description: "Used for configuring advanced_ddos_attack_l4_alert", - }) - .option("filters-pool-id", { - type: "string", - array: true, - description: "Usage depends on specific alert type", - }) - .option("filters-pop-names", { - type: "string", - array: true, - description: "Usage depends on specific alert type", - }) - .option("filters-product", { - type: "string", - array: true, - description: "Used for configuring billing_usage_alert", - }) - .option("filters-project-id", { - type: "string", - array: true, - description: "Used for configuring pages_event_alert", - }) - .option("filters-protocol", { - type: "string", - array: true, - description: "Used for configuring advanced_ddos_attack_l4_alert", - }) - .option("filters-query-id", { - type: "string", - array: true, - description: + variadic: true, + optional: true, + parse: String, + }, + "filters-enabled": { + kind: "parsed", + brief: "Used for configuring load_balancing_pool_enablement_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-environment": { + kind: "parsed", + brief: "Used for configuring pages_event_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-event": { + kind: "parsed", + brief: "Used for configuring pages_event_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-event-source": { + kind: "parsed", + brief: "Used for configuring load_balancing_health_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-event-type": { + kind: "parsed", + brief: "Usage depends on specific alert type", + variadic: true, + optional: true, + parse: String, + }, + "filters-group-by": { + kind: "parsed", + brief: "Usage depends on specific alert type", + variadic: true, + optional: true, + parse: String, + }, + "filters-health-check-id": { + kind: "parsed", + brief: "Used for configuring health_check_status_notification", + variadic: true, + optional: true, + parse: String, + }, + "filters-incident-impact": { + kind: "parsed", + brief: "Used for configuring incident_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-input-id": { + kind: "parsed", + brief: "Used for configuring stream_live_notifications", + variadic: true, + optional: true, + parse: String, + }, + "filters-insight-class": { + kind: "parsed", + brief: "Used for configuring security_insights_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-limit": { + kind: "parsed", + brief: "Used for configuring billing_usage_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-logo-tag": { + kind: "parsed", + brief: "Used for configuring logo_match_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-megabits-per-second": { + kind: "parsed", + brief: "Used for configuring advanced_ddos_attack_l4_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-new-health": { + kind: "parsed", + brief: "Used for configuring load_balancing_health_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-new-status": { + kind: "parsed", + brief: "Used for configuring tunnel_health_event", + variadic: true, + optional: true, + parse: String, + }, + "filters-packets-per-second": { + kind: "parsed", + brief: "Used for configuring advanced_ddos_attack_l4_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-pool-id": { + kind: "parsed", + brief: "Usage depends on specific alert type", + variadic: true, + optional: true, + parse: String, + }, + "filters-pop-names": { + kind: "parsed", + brief: "Usage depends on specific alert type", + variadic: true, + optional: true, + parse: String, + }, + "filters-product": { + kind: "parsed", + brief: "Used for configuring billing_usage_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-project-id": { + kind: "parsed", + brief: "Used for configuring pages_event_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-protocol": { + kind: "parsed", + brief: "Used for configuring advanced_ddos_attack_l4_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-query-id": { + kind: "parsed", + brief: "Used for configuring stakeout_saved_query_daily_digest_alert and stakeout_saved_query_immediate_alert, which require it. Takes exactly one value, the saved query ID.", - }) - .option("filters-query-tag", { - type: "string", - array: true, - description: "Usage depends on specific alert type", - }) - .option("filters-requests-per-second", { - type: "string", - array: true, - description: "Used for configuring advanced_ddos_attack_l7_alert", - }) - .option("filters-selectors", { - type: "string", - array: true, - description: "Usage depends on specific alert type", - }) - .option("filters-services", { - type: "string", - array: true, - description: "Used for configuring clickhouse_alert_fw_ent_anomaly", - }) - .option("filters-slo", { - type: "string", - array: true, - description: "Usage depends on specific alert type", - }) - .option("filters-status", { - type: "string", - array: true, - description: "Used for configuring health_check_status_notification", - }) - .option("filters-target-hostname", { - type: "string", - array: true, - description: "Used for configuring advanced_ddos_attack_l7_alert", - }) - .option("filters-target-ip", { - type: "string", - array: true, - description: "Used for configuring advanced_ddos_attack_l4_alert", - }) - .option("filters-target-zone-name", { - type: "string", - array: true, - description: "Used for configuring advanced_ddos_attack_l7_alert", - }) - .option("filters-token-id", { - type: "string", - array: true, - description: + variadic: true, + optional: true, + parse: String, + }, + "filters-query-tag": { + kind: "parsed", + brief: "Usage depends on specific alert type", + variadic: true, + optional: true, + parse: String, + }, + "filters-requests-per-second": { + kind: "parsed", + brief: "Used for configuring advanced_ddos_attack_l7_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-selectors": { + kind: "parsed", + brief: "Usage depends on specific alert type", + variadic: true, + optional: true, + parse: String, + }, + "filters-services": { + kind: "parsed", + brief: "Used for configuring clickhouse_alert_fw_ent_anomaly", + variadic: true, + optional: true, + parse: String, + }, + "filters-slo": { + kind: "parsed", + brief: "Usage depends on specific alert type", + variadic: true, + optional: true, + parse: String, + }, + "filters-status": { + kind: "parsed", + brief: "Used for configuring health_check_status_notification", + variadic: true, + optional: true, + parse: String, + }, + "filters-target-hostname": { + kind: "parsed", + brief: "Used for configuring advanced_ddos_attack_l7_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-target-ip": { + kind: "parsed", + brief: "Used for configuring advanced_ddos_attack_l4_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-target-zone-name": { + kind: "parsed", + brief: "Used for configuring advanced_ddos_attack_l7_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-token-id": { + kind: "parsed", + brief: "Access service token IDs to include for expiring_service_token_alert. Omit this property to include all current and future service tokens.", - }) - .option("filters-total-spend-dollars", { - type: "string", - array: true, - description: + variadic: true, + optional: true, + parse: String, + }, + "filters-total-spend-dollars": { + kind: "parsed", + brief: "Used for configuring billing_budget_alert. Takes exactly one value, the budget threshold in US dollars, as a string greater than zero.", - }) - .option("filters-traffic-exclusions", { - type: "string", - array: true, - description: "Used for configuring traffic_anomalies_alert", - }) - .option("filters-tunnel-id", { - type: "string", - array: true, - description: "Used for configuring tunnel_health_event", - }) - .option("filters-tunnel-name", { - type: "string", - array: true, - description: "Usage depends on specific alert type", - }) - .option("filters-type", { - type: "string", - array: true, - description: "Usage depends on specific alert type", - }) - .option("filters-where", { - type: "string", - array: true, - description: "Usage depends on specific alert type", - }) - .option("filters-zones", { - type: "string", - array: true, - description: "Usage depends on specific alert type", - }) - .option("mechanisms-email", { - type: "string", - description: + variadic: true, + optional: true, + parse: String, + }, + "filters-traffic-exclusions": { + kind: "parsed", + brief: "Used for configuring traffic_anomalies_alert", + variadic: true, + optional: true, + parse: String, + }, + "filters-tunnel-id": { + kind: "parsed", + brief: "Used for configuring tunnel_health_event", + variadic: true, + optional: true, + parse: String, + }, + "filters-tunnel-name": { + kind: "parsed", + brief: "Usage depends on specific alert type", + variadic: true, + optional: true, + parse: String, + }, + "filters-type": { + kind: "parsed", + brief: "Usage depends on specific alert type", + variadic: true, + optional: true, + parse: String, + }, + "filters-where": { + kind: "parsed", + brief: "Usage depends on specific alert type", + variadic: true, + optional: true, + parse: String, + }, + "filters-zones": { + kind: "parsed", + brief: "Usage depends on specific alert type", + variadic: true, + optional: true, + parse: String, + }, + "mechanisms-email": { + kind: "parsed", + brief: 'The mechanisms.email field. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"id"?: string}]. ? marks optional keys.', - }) - .option("mechanisms-pagerduty", { - type: "string", - description: + optional: true, + parse: String, + }, + "mechanisms-pagerduty": { + kind: "parsed", + brief: 'The mechanisms.pagerduty field. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"id"?: string}]. ? marks optional keys.', - }) - .option("mechanisms-webhooks", { - type: "string", - description: + optional: true, + parse: String, + }, + "mechanisms-webhooks": { + kind: "parsed", + brief: 'The mechanisms.webhooks field. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"id"?: string}]. ? marks optional keys.', - }) - .option("name", { type: "string", description: "Name of the policy." }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + name: { + kind: "parsed", + brief: "Name of the policy.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "update ", - describe: "Update a Notification policy", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "policy-id", + brief: "The unique identifier of a notification policy", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "alerting policies update", classification: { safeFlags: ["alert-type", "enabled", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -637,6 +744,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/silences/create.ts b/packages/cli/src/commands/_generated/alerting/silences/create.ts index 3700ce04b1..53f2daf9b7 100644 --- a/packages/cli/src/commands/_generated/alerting/silences/create.ts +++ b/packages/cli/src/commands/_generated/alerting/silences/create.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/alerting/silences/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/alerting.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,35 +17,31 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 alerting silences create\n\nCreates a new silence for an account." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create", describe: "Create Silences", - builder, + usage: "$0 alerting silences create\n\nCreates a new silence for an account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "alerting silences create", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -83,6 +78,6 @@ const command: CommandModule = { } } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/silences/delete.ts b/packages/cli/src/commands/_generated/alerting/silences/delete.ts index 25df67f3cc..8fb90b7bb7 100644 --- a/packages/cli/src/commands/_generated/alerting/silences/delete.ts +++ b/packages/cli/src/commands/_generated/alerting/silences/delete.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/alerting/silences/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/alerting.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,35 +17,25 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 alerting silences delete \n\nDeletes an existing silence for an account." - ) - .positional("silence-id", { - type: "string", - description: "Silence ID", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete Silence", + usage: + "$0 alerting silences delete \n\nDeletes an existing silence for an account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete Silence", - builder, + }, + }, + operands: [{ placeholder: "silence-id", brief: "Silence ID", parse: String }], handler: async (argv): Promise => runWithTelemetry( { @@ -54,7 +43,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -91,6 +80,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/silences/get.ts b/packages/cli/src/commands/_generated/alerting/silences/get.ts index c5cd1ecfef..1b05c4402c 100644 --- a/packages/cli/src/commands/_generated/alerting/silences/get.ts +++ b/packages/cli/src/commands/_generated/alerting/silences/get.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/alerting/silences/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/alerting.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 alerting silences get \n\nGets a specific silence for an account." - ) - .positional("silence-id", { - type: "string", - description: "Silence ID", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get Silence", - builder, + usage: + "$0 alerting silences get \n\nGets a specific silence for an account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [{ placeholder: "silence-id", brief: "Silence ID", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "alerting silences get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -74,6 +63,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/silences/index.ts b/packages/cli/src/commands/_generated/alerting/silences/index.ts index 9d1be5e117..8099856057 100644 --- a/packages/cli/src/commands/_generated/alerting/silences/index.ts +++ b/packages/cli/src/commands/_generated/alerting/silences/index.ts @@ -3,28 +3,23 @@ import $delete from "./delete.js"; import $get from "./get.js"; import $list from "./list.js"; import $update from "./update.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * silences command group * @generated from apis/overlays/alerting.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "silences", describe: "Operations for silences", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($get) - .command($list) - .command($update) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + get: $get, + list: $list, + update: $update, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/silences/list.ts b/packages/cli/src/commands/_generated/alerting/silences/list.ts index 35332e1a17..5a3ba7b0ee 100644 --- a/packages/cli/src/commands/_generated/alerting/silences/list.ts +++ b/packages/cli/src/commands/_generated/alerting/silences/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/alerting/silences/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/alerting.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,25 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 alerting silences list\n\nGets a list of silences for an account." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List Silences", - builder, + usage: "$0 alerting silences list\n\nGets a list of silences for an account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "alerting silences list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +59,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/alerting/silences/update.ts b/packages/cli/src/commands/_generated/alerting/silences/update.ts index 21bea454ae..f7f32acb49 100644 --- a/packages/cli/src/commands/_generated/alerting/silences/update.ts +++ b/packages/cli/src/commands/_generated/alerting/silences/update.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/alerting/silences/update.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/alerting.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,35 +17,32 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 alerting silences update\n\nUpdates existing silences for an account." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "update", describe: "Update Silences", - builder, + usage: + "$0 alerting silences update\n\nUpdates existing silences for an account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "alerting silences update", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -83,6 +79,6 @@ const command: CommandModule = { } } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/analytics-engine/index.ts b/packages/cli/src/commands/_generated/analytics-engine/index.ts index 4623e17e63..44a1ac2246 100644 --- a/packages/cli/src/commands/_generated/analytics-engine/index.ts +++ b/packages/cli/src/commands/_generated/analytics-engine/index.ts @@ -1,20 +1,17 @@ import $sql from "./sql/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * analytics-engine command * @generated from apis/overlays/analytics-engine.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "analytics-engine", describe: "analytics-engine", - builder: (yargs) => { - return yargs.command($sql).demandCommand(1, "Please specify a subcommand"); + routes: { + sql: $sql, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/analytics-engine/sql/index.ts b/packages/cli/src/commands/_generated/analytics-engine/sql/index.ts index 5e3f42e3e1..84db02c781 100644 --- a/packages/cli/src/commands/_generated/analytics-engine/sql/index.ts +++ b/packages/cli/src/commands/_generated/analytics-engine/sql/index.ts @@ -1,22 +1,17 @@ import $query from "./query.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * sql command group * @generated from apis/overlays/analytics-engine.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "sql", describe: "Operations for sql", - builder: (yargs) => { - return yargs - .command($query) - .demandCommand(1, "Please specify a subcommand"); + routes: { + query: $query, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/analytics-engine/sql/query.ts b/packages/cli/src/commands/_generated/analytics-engine/sql/query.ts index dee1c84ec8..d993e07f54 100644 --- a/packages/cli/src/commands/_generated/analytics-engine/sql/query.ts +++ b/packages/cli/src/commands/_generated/analytics-engine/sql/query.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * query command * @generated from apis/overlays/analytics-engine.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,39 +17,38 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 analytics-engine sql query\n\nExecutes a SQL query against Workers Analytics Engine data. Pass the SQL query in the request body as plain text. The response uses newline-delimited JSON (NDJSON) by default, or a single JSON object when the query includes a FORMAT JSON clause. Prefer this method for longer queries that may exceed URL length limits." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Plain-text request body (without JSON quotes)", - }) - .option("file", { - type: "string", - description: "Path to a file to upload as the request body", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "query", describe: "Execute an Analytics Engine SQL query via request body", - builder, + usage: + "$0 analytics-engine sql query\n\nExecutes a SQL query against Workers Analytics Engine data. Pass the SQL query in the request body as plain text. The response uses newline-delimited JSON (NDJSON) by default, or a single JSON object when the query includes a FORMAT JSON clause. Prefer this method for longer queries that may exceed URL length limits.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Plain-text request body (without JSON quotes)", + optional: true, + parse: String, + }, + file: { + kind: "parsed", + brief: "Path to a file to upload as the request body", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "analytics-engine sql query", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -108,6 +106,6 @@ const command: CommandModule = { } } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/analytics/index.ts b/packages/cli/src/commands/_generated/analytics/index.ts index 51653028e9..82252d2a9a 100644 --- a/packages/cli/src/commands/_generated/analytics/index.ts +++ b/packages/cli/src/commands/_generated/analytics/index.ts @@ -1,25 +1,20 @@ import $latency from "./latency/index.js"; import $query from "./query/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * analytics command * @generated from apis/overlays/analytics.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "analytics", describe: "Zone-level traffic analytics — dashboard summaries, per-colo breakdowns, and Argo latency metrics", - builder: (yargs) => { - return yargs - .command($latency) - .command($query) - .demandCommand(1, "Please specify a subcommand"); + routes: { + latency: $latency, + query: $query, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/analytics/latency/colos/get.ts b/packages/cli/src/commands/_generated/analytics/latency/colos/get.ts index 4ff0d4ac06..944c0d95cf 100644 --- a/packages/cli/src/commands/_generated/analytics/latency/colos/get.ts +++ b/packages/cli/src/commands/_generated/analytics/latency/colos/get.ts @@ -1,42 +1,36 @@ import operation from "../../../_operations/analytics/latency/colos/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/analytics.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 analytics latency colos get\n\nRetrieves Argo Smart Routing analytics broken down by geographic points of presence (PoPs). Shows latency improvements and routing efficiency per location." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get", describe: "Argo Analytics for a zone at different PoPs", - builder, + usage: + "$0 analytics latency colos get\n\nRetrieves Argo Smart Routing analytics broken down by geographic points of presence (PoPs). Shows latency improvements and routing efficiency per location.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "analytics latency colos get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -64,6 +58,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/analytics/latency/colos/index.ts b/packages/cli/src/commands/_generated/analytics/latency/colos/index.ts index 9df844fc63..11d1f5f04d 100644 --- a/packages/cli/src/commands/_generated/analytics/latency/colos/index.ts +++ b/packages/cli/src/commands/_generated/analytics/latency/colos/index.ts @@ -1,20 +1,17 @@ import $get from "./get.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * colos command group * @generated from apis/overlays/analytics.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "colos", describe: "Operations for latency.colos", - builder: (yargs) => { - return yargs.command($get).demandCommand(1, "Please specify a subcommand"); + routes: { + get: $get, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/analytics/latency/get.ts b/packages/cli/src/commands/_generated/analytics/latency/get.ts index 911e617f02..fa19a90403 100644 --- a/packages/cli/src/commands/_generated/analytics/latency/get.ts +++ b/packages/cli/src/commands/_generated/analytics/latency/get.ts @@ -1,43 +1,37 @@ import operation from "../../_operations/analytics/latency/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/analytics.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 analytics latency get\n\nRetrieves aggregate Argo Smart Routing analytics for a zone, including latency improvements, bandwidth savings, and routing statistics." - ) - .option("bins", { type: "string", description: "Bins" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get", describe: "Argo Analytics for a zone", - builder, + usage: + "$0 analytics latency get\n\nRetrieves aggregate Argo Smart Routing analytics for a zone, including latency improvements, bandwidth savings, and routing statistics.", + flags: { + bins: { kind: "parsed", brief: "Bins", optional: true, parse: String }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "analytics latency get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -69,6 +63,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/analytics/latency/index.ts b/packages/cli/src/commands/_generated/analytics/latency/index.ts index e0fe69fffa..bec4bac4c7 100644 --- a/packages/cli/src/commands/_generated/analytics/latency/index.ts +++ b/packages/cli/src/commands/_generated/analytics/latency/index.ts @@ -1,25 +1,20 @@ import $colos from "./colos/index.js"; import $get from "./get.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * latency command group * @generated from apis/overlays/analytics.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "latency", describe: "Argo Smart Routing latency analytics showing time-to-first-byte improvements", - builder: (yargs) => { - return yargs - .command($get) - .command($colos) - .demandCommand(1, "Please specify a subcommand"); + routes: { + get: $get, + colos: $colos, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/analytics/query/data-security/content-findings/index.ts b/packages/cli/src/commands/_generated/analytics/query/data-security/content-findings/index.ts index 9596681691..167ac1caf6 100644 --- a/packages/cli/src/commands/_generated/analytics/query/data-security/content-findings/index.ts +++ b/packages/cli/src/commands/_generated/analytics/query/data-security/content-findings/index.ts @@ -1,20 +1,17 @@ import $topn from "./top-n.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * content-findings command group * @generated from apis/overlays/analytics.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "content-findings", describe: "Operations for query.data-security.content-findings", - builder: (yargs) => { - return yargs.command($topn).demandCommand(1, "Please specify a subcommand"); + routes: { + "top-n": $topn, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/analytics/query/data-security/content-findings/top-n.ts b/packages/cli/src/commands/_generated/analytics/query/data-security/content-findings/top-n.ts index 4d5787eb05..9e53fdb574 100644 --- a/packages/cli/src/commands/_generated/analytics/query/data-security/content-findings/top-n.ts +++ b/packages/cli/src/commands/_generated/analytics/query/data-security/content-findings/top-n.ts @@ -1,11 +1,10 @@ import operation from "../../../../_operations/analytics/query/data-security/content-findings/top-n.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * top-n command * @generated from apis/overlays/analytics.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,52 +19,57 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 analytics query data-security content-findings top-n\n\nReturns the top N integrations ranked by total content findings." - ) - .option("filters", { - type: "string", - description: - 'Filters to apply. `findingType = content` is applied automatically for CASB data. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"name": string, "op": string, "values": [(string | boolean | number)]}].', - }) - .option("from", { - type: "string", - description: "Start of the query time range (inclusive). RFC3339.", - }) - .option("limit", { - type: "number", - description: "Maximum number of integrations to return.", - }) - .option("to", { - type: "string", - description: "End of the query time range (exclusive). RFC3339.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Returns the top N integrations for content findings.", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "top-n", describe: "Top integrations by content findings", - builder, + usage: + "$0 analytics query data-security content-findings top-n\n\nReturns the top N integrations ranked by total content findings.", + flags: { + filters: { + kind: "parsed", + brief: + 'Filters to apply. `findingType = content` is applied automatically for CASB data. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"name": string, "op": string, "values": [(string | boolean | number)]}].', + optional: true, + parse: String, + }, + from: { + kind: "parsed", + brief: "Start of the query time range (inclusive). RFC3339.", + optional: true, + parse: String, + }, + limit: { + kind: "parsed", + brief: "Maximum number of integrations to return.", + optional: true, + parse: Number, + }, + to: { + kind: "parsed", + brief: "End of the query time range (exclusive). RFC3339.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Returns the top N integrations for content findings.", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "analytics query data-security content-findings top-n", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -157,6 +161,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/analytics/query/data-security/findings/index.ts b/packages/cli/src/commands/_generated/analytics/query/data-security/findings/index.ts index a3cfa0bae6..f7c27644bd 100644 --- a/packages/cli/src/commands/_generated/analytics/query/data-security/findings/index.ts +++ b/packages/cli/src/commands/_generated/analytics/query/data-security/findings/index.ts @@ -1,24 +1,19 @@ import $summary from "./summary.js"; import $timeseries from "./timeseries.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * findings command group * @generated from apis/overlays/analytics.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "findings", describe: "Operations for query.data-security.findings", - builder: (yargs) => { - return yargs - .command($summary) - .command($timeseries) - .demandCommand(1, "Please specify a subcommand"); + routes: { + summary: $summary, + timeseries: $timeseries, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/analytics/query/data-security/findings/summary.ts b/packages/cli/src/commands/_generated/analytics/query/data-security/findings/summary.ts index 5ddc9be597..17ed41183e 100644 --- a/packages/cli/src/commands/_generated/analytics/query/data-security/findings/summary.ts +++ b/packages/cli/src/commands/_generated/analytics/query/data-security/findings/summary.ts @@ -1,11 +1,10 @@ import operation from "../../../../_operations/analytics/query/data-security/findings/summary.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * summary command * @generated from apis/overlays/analytics.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,48 +19,51 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 analytics query data-security findings summary\n\nReturns aggregate current-period and previous-period totals for CASB findings." - ) - .option("filters", { - type: "string", - description: - 'Filters to apply. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"name": string, "op": string, "values": [(string | boolean | number)]}].', - }) - .option("from", { - type: "string", - description: "Start of the query time range (inclusive). RFC3339.", - }) - .option("to", { - type: "string", - description: "End of the query time range (exclusive). RFC3339.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Query for aggregate findings summary.", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "summary", describe: "Data security findings summary", - builder, + usage: + "$0 analytics query data-security findings summary\n\nReturns aggregate current-period and previous-period totals for CASB findings.", + flags: { + filters: { + kind: "parsed", + brief: + 'Filters to apply. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"name": string, "op": string, "values": [(string | boolean | number)]}].', + optional: true, + parse: String, + }, + from: { + kind: "parsed", + brief: "Start of the query time range (inclusive). RFC3339.", + optional: true, + parse: String, + }, + to: { + kind: "parsed", + brief: "End of the query time range (exclusive). RFC3339.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Query for aggregate findings summary.", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "analytics query data-security findings summary", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -146,6 +148,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/analytics/query/data-security/findings/timeseries.ts b/packages/cli/src/commands/_generated/analytics/query/data-security/findings/timeseries.ts index 4622fe765b..9b6ab40ad1 100644 --- a/packages/cli/src/commands/_generated/analytics/query/data-security/findings/timeseries.ts +++ b/packages/cli/src/commands/_generated/analytics/query/data-security/findings/timeseries.ts @@ -1,11 +1,10 @@ import operation from "../../../../_operations/analytics/query/data-security/findings/timeseries.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * timeseries command * @generated from apis/overlays/analytics.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,48 +19,51 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 analytics query data-security findings timeseries\n\nReturns merged time-bucketed CASB findings." - ) - .option("filters", { - type: "string", - description: - 'Filters to apply. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"name": string, "op": string, "values": [(string | boolean | number)]}].', - }) - .option("from", { - type: "string", - description: "Start of the query time range (inclusive). RFC3339.", - }) - .option("to", { - type: "string", - description: "End of the query time range (exclusive). RFC3339.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Query for findings timeseries.", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "timeseries", describe: "Data security findings timeseries", - builder, + usage: + "$0 analytics query data-security findings timeseries\n\nReturns merged time-bucketed CASB findings.", + flags: { + filters: { + kind: "parsed", + brief: + 'Filters to apply. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"name": string, "op": string, "values": [(string | boolean | number)]}].', + optional: true, + parse: String, + }, + from: { + kind: "parsed", + brief: "Start of the query time range (inclusive). RFC3339.", + optional: true, + parse: String, + }, + to: { + kind: "parsed", + brief: "End of the query time range (exclusive). RFC3339.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Query for findings timeseries.", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "analytics query data-security findings timeseries", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -146,6 +148,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/analytics/query/data-security/index.ts b/packages/cli/src/commands/_generated/analytics/query/data-security/index.ts index 81261be035..a9d563d499 100644 --- a/packages/cli/src/commands/_generated/analytics/query/data-security/index.ts +++ b/packages/cli/src/commands/_generated/analytics/query/data-security/index.ts @@ -1,24 +1,19 @@ import $contentfindings from "./content-findings/index.js"; import $findings from "./findings/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * data-security command group * @generated from apis/overlays/analytics.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "data-security", describe: "Operations for query.data-security", - builder: (yargs) => { - return yargs - .command($contentfindings) - .command($findings) - .demandCommand(1, "Please specify a subcommand"); + routes: { + "content-findings": $contentfindings, + findings: $findings, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/analytics/query/index.ts b/packages/cli/src/commands/_generated/analytics/query/index.ts index c18be2343d..987e5462d0 100644 --- a/packages/cli/src/commands/_generated/analytics/query/index.ts +++ b/packages/cli/src/commands/_generated/analytics/query/index.ts @@ -2,27 +2,22 @@ import $datasecurity from "./data-security/index.js"; import $summary from "./summary.js"; import $timeseries from "./timeseries.js"; import $topn from "./top-n.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * query command group * @generated from apis/overlays/analytics.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "query", describe: "Operations for query", - builder: (yargs) => { - return yargs - .command($summary) - .command($timeseries) - .command($topn) - .command($datasecurity) - .demandCommand(1, "Please specify a subcommand"); + routes: { + summary: $summary, + timeseries: $timeseries, + "top-n": $topn, + "data-security": $datasecurity, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/analytics/query/summary.ts b/packages/cli/src/commands/_generated/analytics/query/summary.ts index 57b9c338a3..6844b291fc 100644 --- a/packages/cli/src/commands/_generated/analytics/query/summary.ts +++ b/packages/cli/src/commands/_generated/analytics/query/summary.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/analytics/query/summary.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * summary command * @generated from apis/overlays/analytics.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,68 +19,76 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 analytics query summary \n\nReturns aggregate summary stats for a dataset. Includes current-period and previous-period totals for trend comparison." - ) - .positional("dataset", { - type: "string", - description: - "Dataset name to query. Examples: \`access-logins\`, \`gateway-http\`, \`gateway-dns\`, \`gateway-http\`, \`shadow-it\`.", - demandOption: true, - }) - .option("filters", { - type: "string", - description: +const command = apiCommand({ + command: "summary ", + describe: "Query analytics summary", + usage: + "$0 analytics query summary \n\nReturns aggregate summary stats for a dataset. Includes current-period and previous-period totals for trend comparison.", + flags: { + filters: { + kind: "parsed", + brief: 'Filters to apply before aggregating results. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"name": string, "op": string, "values": [(string | boolean | number)]}].', - }) - .option("from", { - type: "string", - description: + optional: true, + parse: String, + }, + from: { + kind: "parsed", + brief: "The start of the query time range (inclusive). RFC3339 format with timezone is required (e.g. `2024-11-05T00:00:00Z`).", - }) - .option("group-by", { - type: "string", - array: true, - description: + optional: true, + parse: String, + }, + "group-by": { + kind: "parsed", + brief: "Specifies the column names to group results by. Requires valid columns for the target dataset.", - }) - .option("stats", { - type: "string", - array: true, - description: + variadic: true, + optional: true, + parse: String, + }, + stats: { + kind: "parsed", + brief: "Specifies the stat names to include in results. Requires valid stats for the target dataset (e.g. `attemptsTotal`, `bytesTotal`).", - }) - .option("to", { - type: "string", - description: + variadic: true, + optional: true, + parse: String, + }, + to: { + kind: "parsed", + brief: "Specifies the end of the query time range (exclusive). Requires RFC3339 format with timezone.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "summary ", - describe: "Query analytics summary", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "dataset", + brief: + "Dataset name to query. Examples: \`access-logins\`, \`gateway-http\`, \`gateway-dns\`, \`gateway-http\`, \`shadow-it\`.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "analytics query summary", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -188,6 +195,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/analytics/query/timeseries.ts b/packages/cli/src/commands/_generated/analytics/query/timeseries.ts index 4ffd432973..5973b14759 100644 --- a/packages/cli/src/commands/_generated/analytics/query/timeseries.ts +++ b/packages/cli/src/commands/_generated/analytics/query/timeseries.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/analytics/query/timeseries.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * timeseries command * @generated from apis/overlays/analytics.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,73 +19,83 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 analytics query timeseries \n\nReturns time-bucketed analytics data for a dataset. Includes time slots, each containing the requested stats, group-by dimensions, and resolution-controlled bucket size (e.g. `hour`, `day`)." - ) - .positional("dataset", { - type: "string", - description: - "Dataset name to query. Examples: \`access-logins\`, \`gateway-http\`, \`gateway-dns\`, \`gateway-http\`, \`shadow-it\`.", - demandOption: true, - }) - .option("filters", { - type: "string", - description: +const command = apiCommand({ + command: "timeseries ", + describe: "Query analytics timeseries", + usage: + "$0 analytics query timeseries \n\nReturns time-bucketed analytics data for a dataset. Includes time slots, each containing the requested stats, group-by dimensions, and resolution-controlled bucket size (e.g. `hour`, `day`).", + flags: { + filters: { + kind: "parsed", + brief: 'Filters to apply before aggregating results. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"name": string, "op": string, "values": [(string | boolean | number)]}].', - }) - .option("from", { - type: "string", - description: + optional: true, + parse: String, + }, + from: { + kind: "parsed", + brief: "The start of the query time range (inclusive). RFC3339 format with timezone is required (e.g. `2024-11-05T00:00:00Z`).", - }) - .option("group-by", { - type: "string", - array: true, - description: + optional: true, + parse: String, + }, + "group-by": { + kind: "parsed", + brief: "Specifies the column names to group results by. Requires valid columns for the target dataset.", - }) - .option("stats", { - type: "string", - array: true, - description: + variadic: true, + optional: true, + parse: String, + }, + stats: { + kind: "parsed", + brief: "Specifies the stat names to include in results. Requires valid stats for the target dataset (e.g. `attemptsTotal`, `bytesTotal`).", - }) - .option("to", { - type: "string", - description: + variadic: true, + optional: true, + parse: String, + }, + to: { + kind: "parsed", + brief: "Specifies the end of the query time range (exclusive). Requires RFC3339 format with timezone.", - }) - .option("resolution", { - type: "string", - description: + optional: true, + parse: String, + }, + resolution: { + kind: "parsed", + brief: "Time bucket size for grouping results. Controls the granularity of the returned time slots.\n", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "timeseries ", - describe: "Query analytics timeseries", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "dataset", + brief: + "Dataset name to query. Examples: \`access-logins\`, \`gateway-http\`, \`gateway-dns\`, \`gateway-http\`, \`shadow-it\`.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "analytics query timeseries", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -209,6 +218,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/analytics/query/top-n.ts b/packages/cli/src/commands/_generated/analytics/query/top-n.ts index 4885c15e23..9e21fe5af3 100644 --- a/packages/cli/src/commands/_generated/analytics/query/top-n.ts +++ b/packages/cli/src/commands/_generated/analytics/query/top-n.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/analytics/query/top-n.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * top-n command * @generated from apis/overlays/analytics.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,77 +19,89 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 analytics query top-n \n\nReturns the top N results for a dataset by a specified stat. Includes an array of result rows, each containing the requested stats and group-by dimensions." - ) - .positional("dataset", { - type: "string", - description: - "Dataset name to query. Examples: \`access-logins\`, \`gateway-http\`, \`gateway-dns\`, \`gateway-http\`, \`shadow-it\`.", - demandOption: true, - }) - .option("filters", { - type: "string", - description: +const command = apiCommand({ + command: "top-n ", + describe: "Query analytics top-N", + usage: + "$0 analytics query top-n \n\nReturns the top N results for a dataset by a specified stat. Includes an array of result rows, each containing the requested stats and group-by dimensions.", + flags: { + filters: { + kind: "parsed", + brief: 'Filters to apply before aggregating results. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"name": string, "op": string, "values": [(string | boolean | number)]}].', - }) - .option("from", { - type: "string", - description: + optional: true, + parse: String, + }, + from: { + kind: "parsed", + brief: "The start of the query time range (inclusive). RFC3339 format with timezone is required (e.g. `2024-11-05T00:00:00Z`).", - }) - .option("group-by", { - type: "string", - array: true, - description: + optional: true, + parse: String, + }, + "group-by": { + kind: "parsed", + brief: "Specifies the column names to group results by. Requires valid columns for the target dataset.", - }) - .option("stats", { - type: "string", - array: true, - description: + variadic: true, + optional: true, + parse: String, + }, + stats: { + kind: "parsed", + brief: "Specifies the stat names to include in results. Requires valid stats for the target dataset (e.g. `attemptsTotal`, `bytesTotal`).", - }) - .option("to", { - type: "string", - description: + variadic: true, + optional: true, + parse: String, + }, + to: { + kind: "parsed", + brief: "Specifies the end of the query time range (exclusive). Requires RFC3339 format with timezone.", - }) - .option("limit", { - type: "number", - description: "Maximum number of results to return.", - }) - .option("order-by", { - type: "string", - description: + optional: true, + parse: String, + }, + limit: { + kind: "parsed", + brief: "Maximum number of results to return.", + optional: true, + parse: Number, + }, + "order-by": { + kind: "parsed", + brief: "Specifies the stat name for sorting results in descending order. Requires a valid stat for the target dataset.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "top-n ", - describe: "Query analytics top-N", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "dataset", + brief: + "Dataset name to query. Examples: \`access-logins\`, \`gateway-http\`, \`gateway-dns\`, \`gateway-http\`, \`shadow-it\`.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "analytics query top-n", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -220,6 +231,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/index.ts b/packages/cli/src/commands/_generated/api-security/index.ts index e6a62e11a4..a546ab73b2 100644 --- a/packages/cli/src/commands/_generated/api-security/index.ts +++ b/packages/cli/src/commands/_generated/api-security/index.ts @@ -2,27 +2,22 @@ import $schemavalidation from "./schema-validation/index.js"; import $sessionidentifiers from "./session-identifiers/index.js"; import $tokenvalidation from "./token-validation/index.js"; import $vulnerabilityscanner from "./vulnerability-scanner/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * api-security command * @generated from apis/overlays/api-security.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "api-security", describe: "api-security", - builder: (yargs) => { - return yargs - .command($schemavalidation) - .command($sessionidentifiers) - .command($tokenvalidation) - .command($vulnerabilityscanner) - .demandCommand(1, "Please specify a subcommand"); + routes: { + "schema-validation": $schemavalidation, + "session-identifiers": $sessionidentifiers, + "token-validation": $tokenvalidation, + "vulnerability-scanner": $vulnerabilityscanner, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/schema-validation/index.ts b/packages/cli/src/commands/_generated/api-security/schema-validation/index.ts index d7cdabefa0..2a13b45bbe 100644 --- a/packages/cli/src/commands/_generated/api-security/schema-validation/index.ts +++ b/packages/cli/src/commands/_generated/api-security/schema-validation/index.ts @@ -1,24 +1,19 @@ import $schemas from "./schemas/index.js"; import $settings from "./settings/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * schema-validation command group * @generated from apis/overlays/api-security.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "schema-validation", describe: "Operations for schema-validation", - builder: (yargs) => { - return yargs - .command($schemas) - .command($settings) - .demandCommand(1, "Please specify a subcommand"); + routes: { + schemas: $schemas, + settings: $settings, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/create.ts b/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/create.ts index 7953f212c2..2ad55ff670 100644 --- a/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/create.ts +++ b/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/create.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/api-security/schema-validation/schemas/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { compactBody, parseBody } from "#lib/body-parser.js"; import { formatDryRun } from "#lib/dry-run.js"; @@ -18,54 +17,57 @@ import { } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security schema-validation schemas create\n\nUploads an OpenAPI schema that defines expected request formats for API operations." - ) - .option("kind", { - type: "string", - description: "The kind of the schema", - choices: ["openapi_v3"], - }) - .coerce("kind", (value) => resolveFileToken(value, "kind", "text")) - .option("name", { - type: "string", - description: "A human-readable name for the schema", - }) - .option("source", { - type: "string", - description: - "The raw schema, e.g., the OpenAPI schema, either as JSON or YAML", - }) - .option("validation-enabled", { - type: "boolean", - description: "An indicator if this schema is enabled", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create", describe: "Upload a schema", - builder, + usage: + "$0 api-security schema-validation schemas create\n\nUploads an OpenAPI schema that defines expected request formats for API operations.", + flags: { + kind: { + kind: "parsed", + brief: "The kind of the schema", + optional: true, + choices: ["openapi_v3"], + parse: String, + coerce: (value: string) => resolveFileToken(value, "kind", "text"), + }, + name: { + kind: "parsed", + brief: "A human-readable name for the schema", + optional: true, + parse: String, + }, + source: { + kind: "parsed", + brief: "The raw schema, e.g., the OpenAPI schema, either as JSON or YAML", + optional: true, + parse: String, + }, + "validation-enabled": { + kind: "boolean", + brief: "An indicator if this schema is enabled", + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "api-security schema-validation schemas create", classification: { safeFlags: ["kind", "validation-enabled", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -166,6 +168,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/delete.ts b/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/delete.ts index 3b92c81f82..fd2f3af8e5 100644 --- a/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/delete.ts +++ b/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/delete.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/api-security/schema-validation/schemas/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; @@ -13,35 +12,31 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security schema-validation schemas delete \n\nPermanently removes an uploaded OpenAPI schema from API Security. Operations using this schema will lose their validation rules." - ) - .positional("schema-id", { - type: "string", - description: "The unique identifier of the schema", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete a schema", + usage: + "$0 api-security schema-validation schemas delete \n\nPermanently removes an uploaded OpenAPI schema from API Security. Operations using this schema will lose their validation rules.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete a schema", - builder, + }, + }, + operands: [ + { + placeholder: "schema-id", + brief: "The unique identifier of the schema", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -49,7 +44,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -90,6 +85,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/get.ts b/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/get.ts index 682827168c..20b66ac775 100644 --- a/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/get.ts +++ b/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/get.ts @@ -1,52 +1,48 @@ import operation from "../../../_operations/api-security/schema-validation/schemas/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security schema-validation schemas get \n\nGets the contents and metadata of a specific OpenAPI schema uploaded to API Security." - ) - .positional("schema-id", { - type: "string", - description: "The unique identifier of the schema", - demandOption: true, - }) - .option("omit-source", { - type: "boolean", - description: - "Omit the source-files of schemas and only retrieve their meta-data.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get details of a schema", - builder, + usage: + "$0 api-security schema-validation schemas get \n\nGets the contents and metadata of a specific OpenAPI schema uploaded to API Security.", + flags: { + "omit-source": { + kind: "boolean", + brief: + "Omit the source-files of schemas and only retrieve their meta-data.", + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "schema-id", + brief: "The unique identifier of the schema", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "api-security schema-validation schemas get", classification: { safeFlags: ["omit-source", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -83,6 +79,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/hosts/index.ts b/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/hosts/index.ts index 47935aa5de..d790f62e6c 100644 --- a/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/hosts/index.ts +++ b/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/hosts/index.ts @@ -1,20 +1,17 @@ import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * hosts command group * @generated from apis/overlays/api-security.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "hosts", describe: "Operations for schema-validation.schemas.hosts", - builder: (yargs) => { - return yargs.command($list).demandCommand(1, "Please specify a subcommand"); + routes: { + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/hosts/list.ts b/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/hosts/list.ts index 013ed8d38f..26dd153303 100644 --- a/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/hosts/list.ts +++ b/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/hosts/list.ts @@ -1,50 +1,48 @@ import operation from "../../../../_operations/api-security/schema-validation/schemas/hosts/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security schema-validation schemas hosts list\n\nLists all unique hosts found in uploaded OpenAPI schemas for the zone." - ) - .option("page", { - type: "number", - description: "Page number of paginated results.", - }) - .option("per-page", { - type: "number", - description: "Maximum number of results per page.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List hosts covered by uploaded schemas", - builder, + usage: + "$0 api-security schema-validation schemas hosts list\n\nLists all unique hosts found in uploaded OpenAPI schemas for the zone.", + flags: { + page: { + kind: "parsed", + brief: "Page number of paginated results.", + optional: true, + parse: Number, + }, + "per-page": { + kind: "parsed", + brief: "Maximum number of results per page.", + optional: true, + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "api-security schema-validation schemas hosts list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -77,6 +75,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/index.ts b/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/index.ts index 2d61778488..d85ae19d44 100644 --- a/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/index.ts +++ b/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/index.ts @@ -5,30 +5,25 @@ import $hosts from "./hosts/index.js"; import $list from "./list.js"; import $operations from "./operations/index.js"; import $setvalidation from "./set-validation.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * schemas command group * @generated from apis/overlays/api-security.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "schemas", describe: "Operations for schema-validation.schemas", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($get) - .command($list) - .command($setvalidation) - .command($hosts) - .command($operations) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + get: $get, + list: $list, + "set-validation": $setvalidation, + hosts: $hosts, + operations: $operations, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/list.ts b/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/list.ts index 9fdc4a26ea..253c04f11f 100644 --- a/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/list.ts +++ b/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/list.ts @@ -1,59 +1,59 @@ import operation from "../../../_operations/api-security/schema-validation/schemas/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security schema-validation schemas list\n\nLists all OpenAPI schemas uploaded to API Security." - ) - .option("page", { - type: "number", - description: "Page number of paginated results.", - }) - .option("per-page", { - type: "number", - description: "Maximum number of results per page.", - }) - .option("omit-source", { - type: "boolean", - description: - "Omit the source-files of schemas and only retrieve their meta-data.", - }) - .option("validation-enabled", { - type: "boolean", - description: "Filter for enabled schemas", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List all uploaded schemas", - builder, + usage: + "$0 api-security schema-validation schemas list\n\nLists all OpenAPI schemas uploaded to API Security.", + flags: { + page: { + kind: "parsed", + brief: "Page number of paginated results.", + optional: true, + parse: Number, + }, + "per-page": { + kind: "parsed", + brief: "Maximum number of results per page.", + optional: true, + parse: Number, + }, + "omit-source": { + kind: "boolean", + brief: + "Omit the source-files of schemas and only retrieve their meta-data.", + optional: true, + }, + "validation-enabled": { + kind: "boolean", + brief: "Filter for enabled schemas", + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "api-security schema-validation schemas list", classification: { safeFlags: ["omit-source", "validation-enabled", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -88,6 +88,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/operations/index.ts b/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/operations/index.ts index 1c896de70b..4c6cf8d09e 100644 --- a/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/operations/index.ts +++ b/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/operations/index.ts @@ -1,20 +1,17 @@ import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * operations command group * @generated from apis/overlays/api-security.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "operations", describe: "Operations for schema-validation.schemas.operations", - builder: (yargs) => { - return yargs.command($list).demandCommand(1, "Please specify a subcommand"); + routes: { + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/operations/list.ts b/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/operations/list.ts index e56ed7acfe..53b15ab99d 100644 --- a/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/operations/list.ts +++ b/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/operations/list.ts @@ -1,91 +1,96 @@ import operation from "../../../../_operations/api-security/schema-validation/schemas/operations/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security schema-validation schemas operations list\n\nRetrieves all operations from the schema. Operations that already exist in API Shield Endpoint Management will be returned as full operations." - ) - .option("schema-id", { - type: "string", - description: "The unique identifier of the schema", - demandOption: true, - }) - .option("feature", { - type: "string", - array: true, - description: +const command = apiCommand({ + command: "list", + describe: "Retrieve all operations from the schema", + usage: + "$0 api-security schema-validation schemas operations list\n\nRetrieves all operations from the schema. Operations that already exist in API Shield Endpoint Management will be returned as full operations.", + flags: { + "schema-id": { + kind: "parsed", + brief: "The unique identifier of the schema", + parse: String, + }, + feature: { + kind: "parsed", + brief: "Add feature(s) to the results. The feature name that is given here corresponds to the resulting feature object. Have a look at the top-level object description for more details on the specific meaning.", + variadic: true, + optional: true, choices: [ "thresholds", "parameter_schemas", "schema_info", "confidence_intervals", ], - }) - .coerce("feature", (values: string[]) => - values.flatMap((value) => value.split(",")) - ) - .option("host", { - type: "string", - array: true, - description: "Filter results to only include the specified hosts.", - }) - .option("method", { - type: "string", - array: true, - description: "Filter results to only include the specified HTTP methods.", - }) - .option("endpoint", { - type: "string", - description: + parse: String, + coerce: (values: string[]) => values.flatMap((value) => value.split(",")), + }, + host: { + kind: "parsed", + brief: "Filter results to only include the specified hosts.", + variadic: true, + optional: true, + parse: String, + }, + method: { + kind: "parsed", + brief: "Filter results to only include the specified HTTP methods.", + variadic: true, + optional: true, + parse: String, + }, + endpoint: { + kind: "parsed", + brief: "Filter results to only include endpoints containing this pattern.", - }) - .option("page", { - type: "number", - description: "Page number of paginated results.", - }) - .option("per-page", { - type: "number", - description: "Maximum number of results per page.", - }) - .option("operation-status", { - type: "string", - description: + optional: true, + parse: String, + }, + page: { + kind: "parsed", + brief: "Page number of paginated results.", + optional: true, + parse: Number, + }, + "per-page": { + kind: "parsed", + brief: "Maximum number of results per page.", + optional: true, + parse: Number, + }, + "operation-status": { + kind: "enum", + brief: "Filter results by whether operations exist in Web Asset Management or not. `new` will just return operations from the schema that do not exist otherwise. `existing` will just return operations from the schema that already exist.", - choices: ["new", "existing"], - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + values: ["new", "existing"], + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "list", - describe: "Retrieve all operations from the schema", - builder, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "api-security schema-validation schemas operations list", classification: { safeFlags: ["operation-status", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -129,6 +134,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/set-validation.ts b/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/set-validation.ts index b3963c5c81..0e2c9f68e7 100644 --- a/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/set-validation.ts +++ b/packages/cli/src/commands/_generated/api-security/schema-validation/schemas/set-validation.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/api-security/schema-validation/schemas/set-validation.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * set-validation command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { compactBody, parseBody } from "#lib/body-parser.js"; import { formatDryRun } from "#lib/dry-run.js"; @@ -13,44 +12,43 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security schema-validation schemas set-validation \n\nEnables or disables validation for an uploaded OpenAPI schema without changing the schema document." - ) - .positional("schema-id", { - type: "string", - description: "The unique identifier of the schema", - demandOption: true, - }) - .option("validation-enabled", { - type: "boolean", - description: "Flag whether schema is enabled for validation.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "set-validation ", describe: "Set schema validation state", - builder, + usage: + "$0 api-security schema-validation schemas set-validation \n\nEnables or disables validation for an uploaded OpenAPI schema without changing the schema document.", + flags: { + "validation-enabled": { + kind: "boolean", + brief: "Flag whether schema is enabled for validation.", + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "schema-id", + brief: "The unique identifier of the schema", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "api-security schema-validation schemas set-validation", classification: { safeFlags: ["validation-enabled", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -108,6 +106,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/schema-validation/settings/edit.ts b/packages/cli/src/commands/_generated/api-security/schema-validation/settings/edit.ts index 75871ece07..d38e70e012 100644 --- a/packages/cli/src/commands/_generated/api-security/schema-validation/settings/edit.ts +++ b/packages/cli/src/commands/_generated/api-security/schema-validation/settings/edit.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/api-security/schema-validation/settings/edit.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * edit command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { compactBody, parseBody } from "#lib/body-parser.js"; import { formatDryRun } from "#lib/dry-run.js"; @@ -14,46 +13,49 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security schema-validation settings edit\n\nPartially updates global schema validation settings for a zone using PATCH semantics." - ) - .option("validation-default-mitigation-action", { - type: "string", - description: +const command = apiCommand({ + command: "edit", + describe: "Edit global schema validation settings", + usage: + "$0 api-security schema-validation settings edit\n\nPartially updates global schema validation settings for a zone using PATCH semantics.", + flags: { + "validation-default-mitigation-action": { + kind: "parsed", + brief: 'The default mitigation action used\nMitigation actions are as follows:\n\n - `"log"` - log request when request does not conform to schema\n - `"block"` - deny access to the site when request does not conform to schema\n - `"none"` - skip running schema validation\n', + optional: true, choices: ["none", "log", "block"], - }) - .coerce("validation-default-mitigation-action", (value) => - resolveFileToken(value, "validation-default-mitigation-action", "text") - ) - .option("validation-override-mitigation-action", { - type: "string", - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "validation-default-mitigation-action", "text"), + }, + "validation-override-mitigation-action": { + kind: "parsed", + brief: 'When set, this overrides both zone level and operation level mitigation actions.\n\n - `"none"` - skip running schema validation entirely for the request\n - `null` - clears any existing override\n', + optional: true, choices: ["none"], - }) - .coerce("validation-override-mitigation-action", (value) => - resolveFileToken(value, "validation-override-mitigation-action", "text") - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + parse: String, + coerce: (value: string) => + resolveFileToken( + value, + "validation-override-mitigation-action", + "text" + ), + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "edit", - describe: "Edit global schema validation settings", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { @@ -64,7 +66,7 @@ const command: CommandModule = { "validation-override-mitigation-action", "dry-run", ], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -119,6 +121,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/schema-validation/settings/get.ts b/packages/cli/src/commands/_generated/api-security/schema-validation/settings/get.ts index 3186233b62..08e1571d12 100644 --- a/packages/cli/src/commands/_generated/api-security/schema-validation/settings/get.ts +++ b/packages/cli/src/commands/_generated/api-security/schema-validation/settings/get.ts @@ -1,42 +1,36 @@ import operation from "../../../_operations/api-security/schema-validation/settings/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security schema-validation settings get\n\nRetrieves the current global schema validation settings for a zone." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get", describe: "Get global schema validation settings", - builder, + usage: + "$0 api-security schema-validation settings get\n\nRetrieves the current global schema validation settings for a zone.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "api-security schema-validation settings get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -64,6 +58,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/schema-validation/settings/index.ts b/packages/cli/src/commands/_generated/api-security/schema-validation/settings/index.ts index 8c8ee5e1b3..b188c7f73e 100644 --- a/packages/cli/src/commands/_generated/api-security/schema-validation/settings/index.ts +++ b/packages/cli/src/commands/_generated/api-security/schema-validation/settings/index.ts @@ -2,27 +2,22 @@ import $edit from "./edit.js"; import $get from "./get.js"; import $operations from "./operations/index.js"; import $update from "./update.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * settings command group * @generated from apis/overlays/api-security.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "settings", describe: "Operations for schema-validation.settings", - builder: (yargs) => { - return yargs - .command($edit) - .command($get) - .command($update) - .command($operations) - .demandCommand(1, "Please specify a subcommand"); + routes: { + edit: $edit, + get: $get, + update: $update, + operations: $operations, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/schema-validation/settings/operations/bulk-edit.ts b/packages/cli/src/commands/_generated/api-security/schema-validation/settings/operations/bulk-edit.ts index dbb0a8a962..8bb959f4ac 100644 --- a/packages/cli/src/commands/_generated/api-security/schema-validation/settings/operations/bulk-edit.ts +++ b/packages/cli/src/commands/_generated/api-security/schema-validation/settings/operations/bulk-edit.ts @@ -1,11 +1,10 @@ import operation from "../../../../_operations/api-security/schema-validation/settings/operations/bulk-edit.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * bulk-edit command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId, requestApi } from "#lib/auth.js"; import { parseBody } from "#lib/body-parser.js"; import { formatDryRun } from "#lib/dry-run.js"; @@ -13,35 +12,32 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security schema-validation settings operations bulk-edit\n\nUpdates schema validation settings for multiple API operations in a single request. Efficient for applying consistent validation rules across endpoints." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "bulk-edit", describe: "Bulk edit per-operation schema validation settings", - builder, + usage: + "$0 api-security schema-validation settings operations bulk-edit\n\nUpdates schema validation settings for multiple API operations in a single request. Efficient for applying consistent validation rules across endpoints.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "api-security schema-validation settings operations bulk-edit", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -86,6 +82,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/schema-validation/settings/operations/delete.ts b/packages/cli/src/commands/_generated/api-security/schema-validation/settings/operations/delete.ts index a36b34e337..98501cc967 100644 --- a/packages/cli/src/commands/_generated/api-security/schema-validation/settings/operations/delete.ts +++ b/packages/cli/src/commands/_generated/api-security/schema-validation/settings/operations/delete.ts @@ -1,11 +1,10 @@ import operation from "../../../../_operations/api-security/schema-validation/settings/operations/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; @@ -13,35 +12,31 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security schema-validation settings operations delete \n\nRemoves custom schema validation settings for a specific API operation, reverting to zone-level defaults." - ) - .positional("operation-id", { - type: "string", - description: "Identifier for the operation", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete per-operation schema validation setting", + usage: + "$0 api-security schema-validation settings operations delete \n\nRemoves custom schema validation settings for a specific API operation, reverting to zone-level defaults.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete per-operation schema validation setting", - builder, + }, + }, + operands: [ + { + placeholder: "operation-id", + brief: "Identifier for the operation", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -49,7 +44,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -91,6 +86,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/schema-validation/settings/operations/get.ts b/packages/cli/src/commands/_generated/api-security/schema-validation/settings/operations/get.ts index 14b4d8d910..1e3609eaea 100644 --- a/packages/cli/src/commands/_generated/api-security/schema-validation/settings/operations/get.ts +++ b/packages/cli/src/commands/_generated/api-security/schema-validation/settings/operations/get.ts @@ -1,47 +1,42 @@ import operation from "../../../../_operations/api-security/schema-validation/settings/operations/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security schema-validation settings operations get \n\nRetrieves the schema validation settings configured for a specific API operation." - ) - .positional("operation-id", { - type: "string", - description: "Identifier for the operation", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get per-operation schema validation setting", - builder, + usage: + "$0 api-security schema-validation settings operations get \n\nRetrieves the schema validation settings configured for a specific API operation.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "operation-id", + brief: "Identifier for the operation", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "api-security schema-validation settings operations get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -74,6 +69,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/schema-validation/settings/operations/index.ts b/packages/cli/src/commands/_generated/api-security/schema-validation/settings/operations/index.ts index 9d7dbcfc26..bac8e1b3d4 100644 --- a/packages/cli/src/commands/_generated/api-security/schema-validation/settings/operations/index.ts +++ b/packages/cli/src/commands/_generated/api-security/schema-validation/settings/operations/index.ts @@ -3,28 +3,23 @@ import $delete from "./delete.js"; import $get from "./get.js"; import $list from "./list.js"; import $update from "./update.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * operations command group * @generated from apis/overlays/api-security.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "operations", describe: "Operations for schema-validation.settings.operations", - builder: (yargs) => { - return yargs - .command($bulkedit) - .command($delete) - .command($get) - .command($list) - .command($update) - .demandCommand(1, "Please specify a subcommand"); + routes: { + "bulk-edit": $bulkedit, + delete: $delete, + get: $get, + list: $list, + update: $update, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/schema-validation/settings/operations/list.ts b/packages/cli/src/commands/_generated/api-security/schema-validation/settings/operations/list.ts index cfb861e177..29059e4102 100644 --- a/packages/cli/src/commands/_generated/api-security/schema-validation/settings/operations/list.ts +++ b/packages/cli/src/commands/_generated/api-security/schema-validation/settings/operations/list.ts @@ -1,50 +1,48 @@ import operation from "../../../../_operations/api-security/schema-validation/settings/operations/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security schema-validation settings operations list\n\nLists per-operation schema validation settings configured for the zone." - ) - .option("page", { - type: "number", - description: "Page number of paginated results.", - }) - .option("per-page", { - type: "number", - description: "Maximum number of results per page.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List per-operation schema validation settings", - builder, + usage: + "$0 api-security schema-validation settings operations list\n\nLists per-operation schema validation settings configured for the zone.", + flags: { + page: { + kind: "parsed", + brief: "Page number of paginated results.", + optional: true, + parse: Number, + }, + "per-page": { + kind: "parsed", + brief: "Maximum number of results per page.", + optional: true, + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "api-security schema-validation settings operations list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -78,6 +76,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/schema-validation/settings/operations/update.ts b/packages/cli/src/commands/_generated/api-security/schema-validation/settings/operations/update.ts index 300aa74fd0..fd17e3d93f 100644 --- a/packages/cli/src/commands/_generated/api-security/schema-validation/settings/operations/update.ts +++ b/packages/cli/src/commands/_generated/api-security/schema-validation/settings/operations/update.ts @@ -1,11 +1,10 @@ import operation from "../../../../_operations/api-security/schema-validation/settings/operations/update.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { compactBody, parseBody } from "#lib/body-parser.js"; import { formatDryRun } from "#lib/dry-run.js"; @@ -15,49 +14,48 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredEnumField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security schema-validation settings operations update \n\nFully updates schema validation settings for a specific API operation." - ) - .positional("operation-id", { - type: "string", - description: "Identifier for the operation", - demandOption: true, - }) - .option("mitigation-action", { - type: "string", - description: +const command = apiCommand({ + command: "update ", + describe: "Update per-operation schema validation setting", + usage: + "$0 api-security schema-validation settings operations update \n\nFully updates schema validation settings for a specific API operation.", + flags: { + "mitigation-action": { + kind: "parsed", + brief: 'When set, this applies a mitigation action to this operation\n\n - `"log"` - log request when request does not conform to schema for this operation\n - `"block"` - deny access to the site when request does not conform to schema for this operation\n - `"none"` - will skip mitigation for this operation\n - `null` - clears any mitigation action\n', + optional: true, choices: ["log", "block", "none"], - }) - .coerce("mitigation-action", (value) => - resolveFileToken(value, "mitigation-action", "text") - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "mitigation-action", "text"), + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "update ", - describe: "Update per-operation schema validation setting", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "operation-id", + brief: "Identifier for the operation", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "api-security schema-validation settings operations update", classification: { safeFlags: ["mitigation-action", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -129,6 +127,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/schema-validation/settings/update.ts b/packages/cli/src/commands/_generated/api-security/schema-validation/settings/update.ts index 202a20db49..a9495ed174 100644 --- a/packages/cli/src/commands/_generated/api-security/schema-validation/settings/update.ts +++ b/packages/cli/src/commands/_generated/api-security/schema-validation/settings/update.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/api-security/schema-validation/settings/update.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { compactBody, parseBody } from "#lib/body-parser.js"; import { formatDryRun } from "#lib/dry-run.js"; @@ -15,46 +14,49 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredEnumField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security schema-validation settings update\n\nFully updates global schema validation settings for a zone, replacing existing configuration." - ) - .option("validation-default-mitigation-action", { - type: "string", - description: +const command = apiCommand({ + command: "update", + describe: "Update global schema validation settings", + usage: + "$0 api-security schema-validation settings update\n\nFully updates global schema validation settings for a zone, replacing existing configuration.", + flags: { + "validation-default-mitigation-action": { + kind: "parsed", + brief: 'The default mitigation action used\nMitigation actions are as follows:\n\n - `"log"` - log request when request does not conform to schema\n - `"block"` - deny access to the site when request does not conform to schema\n - `"none"` - skip running schema validation\n', + optional: true, choices: ["none", "log", "block"], - }) - .coerce("validation-default-mitigation-action", (value) => - resolveFileToken(value, "validation-default-mitigation-action", "text") - ) - .option("validation-override-mitigation-action", { - type: "string", - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "validation-default-mitigation-action", "text"), + }, + "validation-override-mitigation-action": { + kind: "parsed", + brief: 'When set, this overrides both zone level and operation level mitigation actions.\n\n - `"none"` - skip running schema validation entirely for the request\n - `null` - clears any existing override\n', + optional: true, choices: ["none"], - }) - .coerce("validation-override-mitigation-action", (value) => - resolveFileToken(value, "validation-override-mitigation-action", "text") - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + parse: String, + coerce: (value: string) => + resolveFileToken( + value, + "validation-override-mitigation-action", + "text" + ), + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "update", - describe: "Update global schema validation settings", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { @@ -65,7 +67,7 @@ const command: CommandModule = { "validation-override-mitigation-action", "dry-run", ], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -134,6 +136,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/session-identifiers/get.ts b/packages/cli/src/commands/_generated/api-security/session-identifiers/get.ts index 6248849bef..43409bc02d 100644 --- a/packages/cli/src/commands/_generated/api-security/session-identifiers/get.ts +++ b/packages/cli/src/commands/_generated/api-security/session-identifiers/get.ts @@ -1,47 +1,42 @@ import operation from "../../_operations/api-security/session-identifiers/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security session-identifiers get\n\nReturns the authentication identifier characteristics configured for the zone. Header, cookie, or JWT claim values identify distinct API sessions." - ) - .option("normalize", { - type: "boolean", - description: - "Ensures that the configuration is written or retrieved in normalized fashion", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get", describe: "Get session identifier settings", - builder, + usage: + "$0 api-security session-identifiers get\n\nReturns the authentication identifier characteristics configured for the zone. Header, cookie, or JWT claim values identify distinct API sessions.", + flags: { + normalize: { + kind: "boolean", + brief: + "Ensures that the configuration is written or retrieved in normalized fashion", + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "api-security session-identifiers get", classification: { safeFlags: ["normalize", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -73,6 +68,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/session-identifiers/index.ts b/packages/cli/src/commands/_generated/api-security/session-identifiers/index.ts index a93b886224..a27aee1e6a 100644 --- a/packages/cli/src/commands/_generated/api-security/session-identifiers/index.ts +++ b/packages/cli/src/commands/_generated/api-security/session-identifiers/index.ts @@ -1,24 +1,19 @@ import $get from "./get.js"; import $update from "./update.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * session-identifiers command group * @generated from apis/overlays/api-security.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "session-identifiers", describe: "Operations for session-identifiers", - builder: (yargs) => { - return yargs - .command($get) - .command($update) - .demandCommand(1, "Please specify a subcommand"); + routes: { + get: $get, + update: $update, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/session-identifiers/update.ts b/packages/cli/src/commands/_generated/api-security/session-identifiers/update.ts index 99a9eebe56..fa8c151875 100644 --- a/packages/cli/src/commands/_generated/api-security/session-identifiers/update.ts +++ b/packages/cli/src/commands/_generated/api-security/session-identifiers/update.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/api-security/session-identifiers/update.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { compactBody, parseBody, parseObjectArray } from "#lib/body-parser.js"; import { formatDryRun } from "#lib/dry-run.js"; @@ -13,45 +12,45 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security session-identifiers update\n\nReplaces the zone's authentication identifier characteristics used to identify distinct API sessions." - ) - .option("normalize", { - type: "boolean", - description: +const command = apiCommand({ + command: "update", + describe: "Update session identifier settings", + usage: + "$0 api-security session-identifiers update\n\nReplaces the zone's authentication identifier characteristics used to identify distinct API sessions.", + flags: { + normalize: { + kind: "boolean", + brief: "Ensures that the configuration is written or retrieved in normalized fashion", - }) - .option("auth-id-characteristics", { - type: "string", - description: + optional: true, + }, + "auth-id-characteristics": { + kind: "parsed", + brief: 'The auth_id_characteristics field. Provide as a JSON array of objects or @path/to/file.json. Shape: [({"name": string, "type": "header" | "cookie"} | {"name": string, "type": "jwt"})].', - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "update", - describe: "Update session identifier settings", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "api-security session-identifiers update", classification: { safeFlags: ["normalize", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -139,6 +138,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/token-validation/configurations/create.ts b/packages/cli/src/commands/_generated/api-security/token-validation/configurations/create.ts index f9a394d18d..3e63fe1e70 100644 --- a/packages/cli/src/commands/_generated/api-security/token-validation/configurations/create.ts +++ b/packages/cli/src/commands/_generated/api-security/token-validation/configurations/create.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/api-security/token-validation/configurations/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { compactBody, parseBody, parseObjectArray } from "#lib/body-parser.js"; import { formatDryRun } from "#lib/dry-run.js"; @@ -18,53 +17,59 @@ import { } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security token-validation configurations create\n\nCreates a JWT validation configuration for the zone." - ) - .option("credentials-keys", { - type: "string", - description: +const command = apiCommand({ + command: "create", + describe: "Create a token validation configuration", + usage: + "$0 api-security token-validation configurations create\n\nCreates a JWT validation configuration for the zone.", + flags: { + "credentials-keys": { + kind: "parsed", + brief: 'The credentials.keys field. Provide as a JSON array of objects or @path/to/file.json. Shape: [(({"kid": string} & {"alg": "RS256" | "RS384" | "RS512" | ...more, "e": string, "kty": "RSA", "n": string}) | ({"kid": string} & {"kty": "EC", "x": string, "y": string} & {"alg": "ES256", "crv": "P-256"}) | ...more)].', - }) - .option("description", { - type: "string", - description: "The description field", - }) - .option("title", { type: "string", description: "The title field" }) - .option("token-type", { - type: "string", - description: "The token_type field", + optional: true, + parse: String, + }, + description: { + kind: "parsed", + brief: "The description field", + optional: true, + parse: String, + }, + title: { + kind: "parsed", + brief: "The title field", + optional: true, + parse: String, + }, + "token-type": { + kind: "parsed", + brief: "The token_type field", + optional: true, choices: ["JWT"], - }) - .coerce("token-type", (value) => - resolveFileToken(value, "token-type", "text") - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + parse: String, + coerce: (value: string) => resolveFileToken(value, "token-type", "text"), + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "create", - describe: "Create a token validation configuration", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "api-security token-validation configurations create", classification: { safeFlags: ["token-type", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -175,6 +180,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/token-validation/configurations/credentials/edit.ts b/packages/cli/src/commands/_generated/api-security/token-validation/configurations/credentials/edit.ts index 5f97a7a0d4..d01a90e9d8 100644 --- a/packages/cli/src/commands/_generated/api-security/token-validation/configurations/credentials/edit.ts +++ b/packages/cli/src/commands/_generated/api-security/token-validation/configurations/credentials/edit.ts @@ -1,11 +1,10 @@ import operation from "../../../../_operations/api-security/token-validation/configurations/credentials/edit.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * edit command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { compactBody, parseBody, parseObjectArray } from "#lib/body-parser.js"; import { formatDryRun } from "#lib/dry-run.js"; @@ -13,47 +12,47 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security token-validation configurations credentials edit \n\nUpdates the configuration's complete key set while allowing omitted fields on existing keys to retain stored values. Omitted key identities are removed." - ) - .positional("config-id", { - type: "string", - description: "Token Configuration ID", - demandOption: true, - }) - .option("keys", { - type: "string", - description: - 'The keys field. Provide as a JSON array of objects or @path/to/file.json. Shape: [(({"kid": string} & {"alg": "RS256" | "RS384" | "RS512" | ...more, "e": string, "kty": "RSA", "n": string}) | ({"kid": string} & {"kty": "EC", "x": string, "y": string} & {"alg": "ES256", "crv": "P-256"}) | ...more)].', - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: - "Request payload for PATCH credentials. Provided keys define the complete stored key set, and stored keys omitted from payload are removed. For each provided key identity (\`{alg,kid}\`), payload fields overwrite the stored key before validation and omitted fields inherit from the stored key. Key identities must be unique.", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "edit ", describe: "Edit token validation credentials", - builder, + usage: + "$0 api-security token-validation configurations credentials edit \n\nUpdates the configuration's complete key set while allowing omitted fields on existing keys to retain stored values. Omitted key identities are removed.", + flags: { + keys: { + kind: "parsed", + brief: + 'The keys field. Provide as a JSON array of objects or @path/to/file.json. Shape: [(({"kid": string} & {"alg": "RS256" | "RS384" | "RS512" | ...more, "e": string, "kty": "RSA", "n": string}) | ({"kid": string} & {"kty": "EC", "x": string, "y": string} & {"alg": "ES256", "crv": "P-256"}) | ...more)].', + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: + "Request payload for PATCH credentials. Provided keys define the complete stored key set, and stored keys omitted from payload are removed. For each provided key identity (`{alg,kid}`), payload fields overwrite the stored key before validation and omitted fields inherit from the stored key. Key identities must be unique.", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "config-id", + brief: "Token Configuration ID", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "api-security token-validation configurations credentials edit", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -123,6 +122,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/token-validation/configurations/credentials/index.ts b/packages/cli/src/commands/_generated/api-security/token-validation/configurations/credentials/index.ts index b0069aa80c..e7e6c84a0f 100644 --- a/packages/cli/src/commands/_generated/api-security/token-validation/configurations/credentials/index.ts +++ b/packages/cli/src/commands/_generated/api-security/token-validation/configurations/credentials/index.ts @@ -1,24 +1,19 @@ import $edit from "./edit.js"; import $update from "./update.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * credentials command group * @generated from apis/overlays/api-security.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "credentials", describe: "Operations for token-validation.configurations.credentials", - builder: (yargs) => { - return yargs - .command($edit) - .command($update) - .demandCommand(1, "Please specify a subcommand"); + routes: { + edit: $edit, + update: $update, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/token-validation/configurations/credentials/update.ts b/packages/cli/src/commands/_generated/api-security/token-validation/configurations/credentials/update.ts index 8a6284f2b5..faa9f40531 100644 --- a/packages/cli/src/commands/_generated/api-security/token-validation/configurations/credentials/update.ts +++ b/packages/cli/src/commands/_generated/api-security/token-validation/configurations/credentials/update.ts @@ -1,11 +1,10 @@ import operation from "../../../../_operations/api-security/token-validation/configurations/credentials/update.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { compactBody, parseBody, parseObjectArray } from "#lib/body-parser.js"; import { formatDryRun } from "#lib/dry-run.js"; @@ -13,47 +12,47 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security token-validation configurations credentials update \n\nReplaces the configuration's complete key set. Symmetric keys must include their key material." - ) - .positional("config-id", { - type: "string", - description: "Token Configuration ID", - demandOption: true, - }) - .option("keys", { - type: "string", - description: - 'The keys field. Provide as a JSON array of objects or @path/to/file.json. Shape: [(({"kid": string} & {"alg": "RS256" | "RS384" | "RS512" | ...more, "e": string, "kty": "RSA", "n": string}) | ({"kid": string} & {"kty": "EC", "x": string, "y": string} & {"alg": "ES256", "crv": "P-256"}) | ...more)].', - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: - "Request payload for create and PUT credentials operations. Provided keys define the complete stored key set. Key identities (\`{alg,kid}\`) must be unique.", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "update ", describe: "Replace token validation credentials", - builder, + usage: + "$0 api-security token-validation configurations credentials update \n\nReplaces the configuration's complete key set. Symmetric keys must include their key material.", + flags: { + keys: { + kind: "parsed", + brief: + 'The keys field. Provide as a JSON array of objects or @path/to/file.json. Shape: [(({"kid": string} & {"alg": "RS256" | "RS384" | "RS512" | ...more, "e": string, "kty": "RSA", "n": string}) | ({"kid": string} & {"kty": "EC", "x": string, "y": string} & {"alg": "ES256", "crv": "P-256"}) | ...more)].', + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: + "Request payload for create and PUT credentials operations. Provided keys define the complete stored key set. Key identities (`{alg,kid}`) must be unique.", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "config-id", + brief: "Token Configuration ID", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "api-security token-validation configurations credentials update", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -123,6 +122,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/token-validation/configurations/delete.ts b/packages/cli/src/commands/_generated/api-security/token-validation/configurations/delete.ts index 0290584eec..dee6b6c835 100644 --- a/packages/cli/src/commands/_generated/api-security/token-validation/configurations/delete.ts +++ b/packages/cli/src/commands/_generated/api-security/token-validation/configurations/delete.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/api-security/token-validation/configurations/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; @@ -13,35 +12,31 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security token-validation configurations delete \n\nDeletes a JWT validation configuration from the zone." - ) - .positional("config-id", { - type: "string", - description: "Token Configuration ID", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete a token validation configuration", + usage: + "$0 api-security token-validation configurations delete \n\nDeletes a JWT validation configuration from the zone.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete a token validation configuration", - builder, + }, + }, + operands: [ + { + placeholder: "config-id", + brief: "Token Configuration ID", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -49,7 +44,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -90,6 +85,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/token-validation/configurations/edit.ts b/packages/cli/src/commands/_generated/api-security/token-validation/configurations/edit.ts index 4181fcca27..90b3d746da 100644 --- a/packages/cli/src/commands/_generated/api-security/token-validation/configurations/edit.ts +++ b/packages/cli/src/commands/_generated/api-security/token-validation/configurations/edit.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/api-security/token-validation/configurations/edit.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * edit command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { compactBody, parseBody } from "#lib/body-parser.js"; import { formatDryRun } from "#lib/dry-run.js"; @@ -14,45 +13,50 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security token-validation configurations edit \n\nUpdates only the supplied fields on a JWT validation configuration." - ) - .positional("config-id", { - type: "string", - description: "Token Configuration ID", - demandOption: true, - }) - .option("description", { - type: "string", - description: "The description field", - }) - .option("title", { type: "string", description: "The title field" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "edit ", describe: "Edit a token validation configuration", - builder, + usage: + "$0 api-security token-validation configurations edit \n\nUpdates only the supplied fields on a JWT validation configuration.", + flags: { + description: { + kind: "parsed", + brief: "The description field", + optional: true, + parse: String, + }, + title: { + kind: "parsed", + brief: "The title field", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "config-id", + brief: "Token Configuration ID", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "api-security token-validation configurations edit", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -128,6 +132,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/token-validation/configurations/get.ts b/packages/cli/src/commands/_generated/api-security/token-validation/configurations/get.ts index 21b25648e3..eddc30aa54 100644 --- a/packages/cli/src/commands/_generated/api-security/token-validation/configurations/get.ts +++ b/packages/cli/src/commands/_generated/api-security/token-validation/configurations/get.ts @@ -1,47 +1,42 @@ import operation from "../../../_operations/api-security/token-validation/configurations/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security token-validation configurations get \n\nReturns a JWT validation configuration by ID." - ) - .positional("config-id", { - type: "string", - description: "Token Configuration ID", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get a token validation configuration", - builder, + usage: + "$0 api-security token-validation configurations get \n\nReturns a JWT validation configuration by ID.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "config-id", + brief: "Token Configuration ID", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "api-security token-validation configurations get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -73,6 +68,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/token-validation/configurations/index.ts b/packages/cli/src/commands/_generated/api-security/token-validation/configurations/index.ts index 1cb74de98c..72f2f3115b 100644 --- a/packages/cli/src/commands/_generated/api-security/token-validation/configurations/index.ts +++ b/packages/cli/src/commands/_generated/api-security/token-validation/configurations/index.ts @@ -4,29 +4,24 @@ import $delete from "./delete.js"; import $edit from "./edit.js"; import $get from "./get.js"; import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * configurations command group * @generated from apis/overlays/api-security.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "configurations", describe: "Operations for token-validation.configurations", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($edit) - .command($get) - .command($list) - .command($credentials) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + edit: $edit, + get: $get, + list: $list, + credentials: $credentials, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/token-validation/configurations/list.ts b/packages/cli/src/commands/_generated/api-security/token-validation/configurations/list.ts index e4d5193b6c..fa41e720ec 100644 --- a/packages/cli/src/commands/_generated/api-security/token-validation/configurations/list.ts +++ b/packages/cli/src/commands/_generated/api-security/token-validation/configurations/list.ts @@ -1,50 +1,48 @@ import operation from "../../../_operations/api-security/token-validation/configurations/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security token-validation configurations list\n\nLists the JWT validation configurations defined for the zone." - ) - .option("page", { - type: "number", - description: "Page number of paginated results.", - }) - .option("per-page", { - type: "number", - description: "Maximum number of results per page.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List token validation configurations", - builder, + usage: + "$0 api-security token-validation configurations list\n\nLists the JWT validation configurations defined for the zone.", + flags: { + page: { + kind: "parsed", + brief: "Page number of paginated results.", + optional: true, + parse: Number, + }, + "per-page": { + kind: "parsed", + brief: "Maximum number of results per page.", + optional: true, + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "api-security token-validation configurations list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -77,6 +75,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/token-validation/index.ts b/packages/cli/src/commands/_generated/api-security/token-validation/index.ts index e4c18c264f..a6d8b883ac 100644 --- a/packages/cli/src/commands/_generated/api-security/token-validation/index.ts +++ b/packages/cli/src/commands/_generated/api-security/token-validation/index.ts @@ -1,24 +1,19 @@ import $configurations from "./configurations/index.js"; import $rules from "./rules/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * token-validation command group * @generated from apis/overlays/api-security.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "token-validation", describe: "Operations for token-validation", - builder: (yargs) => { - return yargs - .command($configurations) - .command($rules) - .demandCommand(1, "Please specify a subcommand"); + routes: { + configurations: $configurations, + rules: $rules, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/token-validation/rules/bulk-create.ts b/packages/cli/src/commands/_generated/api-security/token-validation/rules/bulk-create.ts index 3094dc076b..d373128e17 100644 --- a/packages/cli/src/commands/_generated/api-security/token-validation/rules/bulk-create.ts +++ b/packages/cli/src/commands/_generated/api-security/token-validation/rules/bulk-create.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/api-security/token-validation/rules/bulk-create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * bulk-create command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { parseBody } from "#lib/body-parser.js"; import { formatDryRun } from "#lib/dry-run.js"; @@ -13,35 +12,32 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security token-validation rules bulk-create\n\nCreates multiple token validation rules for the zone in one request." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "bulk-create", describe: "Create token validation rules", - builder, + usage: + "$0 api-security token-validation rules bulk-create\n\nCreates multiple token validation rules for the zone in one request.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "api-security token-validation rules bulk-create", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -81,6 +77,6 @@ const command: CommandModule = { } } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/token-validation/rules/bulk-edit.ts b/packages/cli/src/commands/_generated/api-security/token-validation/rules/bulk-edit.ts index bab0e1942d..bb51ef9e87 100644 --- a/packages/cli/src/commands/_generated/api-security/token-validation/rules/bulk-edit.ts +++ b/packages/cli/src/commands/_generated/api-security/token-validation/rules/bulk-edit.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/api-security/token-validation/rules/bulk-edit.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * bulk-edit command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { parseBody } from "#lib/body-parser.js"; import { formatDryRun } from "#lib/dry-run.js"; @@ -13,35 +12,32 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security token-validation rules bulk-edit\n\nUpdates and reorders multiple token validation rules in one request, then returns the updated rules." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "bulk-edit", describe: "Edit token validation rules", - builder, + usage: + "$0 api-security token-validation rules bulk-edit\n\nUpdates and reorders multiple token validation rules in one request, then returns the updated rules.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "api-security token-validation rules bulk-edit", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -81,6 +77,6 @@ const command: CommandModule = { } } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/token-validation/rules/create.ts b/packages/cli/src/commands/_generated/api-security/token-validation/rules/create.ts index 45f890b4be..4e5add8d2d 100644 --- a/packages/cli/src/commands/_generated/api-security/token-validation/rules/create.ts +++ b/packages/cli/src/commands/_generated/api-security/token-validation/rules/create.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/api-security/token-validation/rules/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { compactBody, parseBody, parseObjectArray } from "#lib/body-parser.js"; import { formatDryRun } from "#lib/dry-run.js"; @@ -18,70 +17,80 @@ import { } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security token-validation rules create\n\nCreates a token validation rule for the zone." - ) - .option("action", { - type: "string", - description: +const command = apiCommand({ + command: "create", + describe: "Create a token validation rule", + usage: + "$0 api-security token-validation rules create\n\nCreates a token validation rule for the zone.", + flags: { + action: { + kind: "parsed", + brief: "Action to take on requests that match operations included in `selector` and fail `expression`.", + optional: true, choices: ["log", "block"], - }) - .coerce("action", (value) => resolveFileToken(value, "action", "text")) - .option("description", { - type: "string", - description: + parse: String, + coerce: (value: string) => resolveFileToken(value, "action", "text"), + }, + description: { + kind: "parsed", + brief: "A human-readable description that gives more details than `title`.", - }) - .option("enabled", { - type: "boolean", - description: "Toggle rule on or off.", - }) - .option("expression", { - type: "string", - description: + optional: true, + parse: String, + }, + enabled: { + kind: "boolean", + brief: "Toggle rule on or off.", + optional: true, + }, + expression: { + kind: "parsed", + brief: "Rule expression. Requests that fail to match this expression will be subject to `action`.\n\nFor details on expressions, see the [Cloudflare Docs](https://developers.cloudflare.com/api-shield/security/jwt-validation/).\n", - }) - .option("selector-exclude", { - type: "string", - description: + optional: true, + parse: String, + }, + "selector-exclude": { + kind: "parsed", + brief: 'Ignore operations that were otherwise included by `include`. Provide as a JSON array of objects, null, or @path/to/file.json. Shape: [{"operation_ids"?: [string]}]. ? marks optional keys.', - }) - .option("selector-include", { - type: "string", - description: + optional: true, + parse: String, + }, + "selector-include": { + kind: "parsed", + brief: 'Select all matching operations. Provide as a JSON array of objects, null, or @path/to/file.json. Shape: [{"host"?: [string]}]. ? marks optional keys.', - }) - .option("title", { - type: "string", - description: "A human-readable name for the rule.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + title: { + kind: "parsed", + brief: "A human-readable name for the rule.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "create", - describe: "Create a token validation rule", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "api-security token-validation rules create", classification: { safeFlags: ["action", "enabled", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -222,6 +231,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/token-validation/rules/delete.ts b/packages/cli/src/commands/_generated/api-security/token-validation/rules/delete.ts index 942fc40884..4d8f018393 100644 --- a/packages/cli/src/commands/_generated/api-security/token-validation/rules/delete.ts +++ b/packages/cli/src/commands/_generated/api-security/token-validation/rules/delete.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/api-security/token-validation/rules/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; @@ -13,35 +12,31 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security token-validation rules delete \n\nDeletes a token validation rule from the zone." - ) - .positional("rule-id", { - type: "string", - description: "Token Validation Rule ID", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete a token validation rule", + usage: + "$0 api-security token-validation rules delete \n\nDeletes a token validation rule from the zone.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete a token validation rule", - builder, + }, + }, + operands: [ + { + placeholder: "rule-id", + brief: "Token Validation Rule ID", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -49,7 +44,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -87,6 +82,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/token-validation/rules/edit.ts b/packages/cli/src/commands/_generated/api-security/token-validation/rules/edit.ts index f03f0d3a36..e0add88ea2 100644 --- a/packages/cli/src/commands/_generated/api-security/token-validation/rules/edit.ts +++ b/packages/cli/src/commands/_generated/api-security/token-validation/rules/edit.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/api-security/token-validation/rules/edit.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * edit command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { compactBody, parseBody, parseObjectArray } from "#lib/body-parser.js"; import { formatDryRun } from "#lib/dry-run.js"; @@ -14,90 +13,109 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security token-validation rules edit \n\nUpdates only the supplied fields on a token validation rule." - ) - .positional("rule-id", { - type: "string", - description: "Token Validation Rule ID", - demandOption: true, - }) - .option("action", { - type: "string", - description: +const command = apiCommand({ + command: "edit ", + describe: "Edit a token validation rule", + usage: + "$0 api-security token-validation rules edit \n\nUpdates only the supplied fields on a token validation rule.", + flags: { + action: { + kind: "parsed", + brief: "Action to take on requests that match operations included in `selector` and fail `expression`.", + optional: true, choices: ["log", "block"], - }) - .coerce("action", (value) => resolveFileToken(value, "action", "text")) - .option("description", { - type: "string", - description: + parse: String, + coerce: (value: string) => resolveFileToken(value, "action", "text"), + }, + description: { + kind: "parsed", + brief: "A human-readable description that gives more details than `title`.", - }) - .option("enabled", { - type: "boolean", - description: "Toggle rule on or off.", - }) - .option("expression", { - type: "string", - description: + optional: true, + parse: String, + }, + enabled: { + kind: "boolean", + brief: "Toggle rule on or off.", + optional: true, + }, + expression: { + kind: "parsed", + brief: "Rule expression. Requests that fail to match this expression will be subject to `action`.\n\nFor details on expressions, see the [Cloudflare Docs](https://developers.cloudflare.com/api-shield/security/jwt-validation/).\n", - }) - .option("selector-exclude", { - type: "string", - description: + optional: true, + parse: String, + }, + "selector-exclude": { + kind: "parsed", + brief: 'Ignore operations that were otherwise included by `include`. Provide as a JSON array of objects, null, or @path/to/file.json. Shape: [{"operation_ids"?: [string]}]. ? marks optional keys.', - }) - .option("selector-include", { - type: "string", - description: + optional: true, + parse: String, + }, + "selector-include": { + kind: "parsed", + brief: 'Select all matching operations. Provide as a JSON array of objects, null, or @path/to/file.json. Shape: [{"host"?: [string]}]. ? marks optional keys.', - }) - .option("title", { - type: "string", - description: "A human-readable name for the rule.", - }) - .option("position-index", { - type: "number", - description: "Move rule to this position", - }) - .option("position-before", { - type: "string", - description: "Move rule to before rule with this ID.", - }) - .option("position-after", { - type: "string", - description: "Move rule to after rule with this ID.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + title: { + kind: "parsed", + brief: "A human-readable name for the rule.", + optional: true, + parse: String, + }, + "position-index": { + kind: "parsed", + brief: "Move rule to this position", + optional: true, + parse: Number, + }, + "position-before": { + kind: "parsed", + brief: "Move rule to before rule with this ID.", + optional: true, + parse: String, + }, + "position-after": { + kind: "parsed", + brief: "Move rule to after rule with this ID.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }) - .conflicts("position-index", ["position-before", "position-after"]) - .conflicts("position-before", ["position-index", "position-after"]) - .conflicts("position-after", ["position-index", "position-before"]); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "edit ", - describe: "Edit a token validation rule", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "rule-id", + brief: "Token Validation Rule ID", + parse: String, + }, + ], + rules(rules) { + rules.conflicts("position-index", ["position-before", "position-after"]); + rules.conflicts("position-before", ["position-index", "position-after"]); + rules.conflicts("position-after", ["position-index", "position-before"]); + }, handler: async (argv): Promise => runWithTelemetry( { command: "api-security token-validation rules edit", classification: { safeFlags: ["action", "enabled", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -237,6 +255,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/token-validation/rules/get.ts b/packages/cli/src/commands/_generated/api-security/token-validation/rules/get.ts index 845d14896b..f5a36efa95 100644 --- a/packages/cli/src/commands/_generated/api-security/token-validation/rules/get.ts +++ b/packages/cli/src/commands/_generated/api-security/token-validation/rules/get.ts @@ -1,47 +1,42 @@ import operation from "../../../_operations/api-security/token-validation/rules/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security token-validation rules get \n\nReturns a token validation rule by ID." - ) - .positional("rule-id", { - type: "string", - description: "Token Validation Rule ID", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get a token validation rule", - builder, + usage: + "$0 api-security token-validation rules get \n\nReturns a token validation rule by ID.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "rule-id", + brief: "Token Validation Rule ID", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "api-security token-validation rules get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -70,6 +65,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/token-validation/rules/index.ts b/packages/cli/src/commands/_generated/api-security/token-validation/rules/index.ts index ac8c36b345..198aaab4b8 100644 --- a/packages/cli/src/commands/_generated/api-security/token-validation/rules/index.ts +++ b/packages/cli/src/commands/_generated/api-security/token-validation/rules/index.ts @@ -5,30 +5,25 @@ import $delete from "./delete.js"; import $edit from "./edit.js"; import $get from "./get.js"; import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * rules command group * @generated from apis/overlays/api-security.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "rules", describe: "Operations for token-validation.rules", - builder: (yargs) => { - return yargs - .command($bulkcreate) - .command($bulkedit) - .command($create) - .command($delete) - .command($edit) - .command($get) - .command($list) - .demandCommand(1, "Please specify a subcommand"); + routes: { + "bulk-create": $bulkcreate, + "bulk-edit": $bulkedit, + create: $create, + delete: $delete, + edit: $edit, + get: $get, + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/token-validation/rules/list.ts b/packages/cli/src/commands/_generated/api-security/token-validation/rules/list.ts index c2d9ad2cfd..38ffeb5525 100644 --- a/packages/cli/src/commands/_generated/api-security/token-validation/rules/list.ts +++ b/packages/cli/src/commands/_generated/api-security/token-validation/rules/list.ts @@ -1,81 +1,91 @@ import operation from "../../../_operations/api-security/token-validation/rules/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security token-validation rules list\n\nLists token validation rules for the zone, with filters for configuration, action, state, ID, and host." - ) - .option("per-page", { - type: "number", - description: "Maximum number of results per page.", - }) - .option("page", { - type: "number", - description: "Page number of paginated results.", - }) - .option("token-configuration", { - type: "string", - array: true, - description: "Select rules using any of these token configurations.", - }) - .option("action", { - type: "string", - description: - "Action to take on requests that match operations included in `selector` and fail `expression`.", - choices: ["log", "block"], - }) - .option("enabled", { - type: "boolean", - description: "Toggle rule on or off.", - }) - .option("id", { - type: "string", - description: "Select rules with these IDs.", - }) - .option("rule-id", { - type: "string", - description: "Select rules with these IDs.", - }) - .option("host", { - type: "string", - description: "Select rules with this host in `include`.", - }) - .option("hostname", { - type: "string", - description: "Select rules with this host in `include`.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List token validation rules", - builder, + usage: + "$0 api-security token-validation rules list\n\nLists token validation rules for the zone, with filters for configuration, action, state, ID, and host.", + flags: { + "per-page": { + kind: "parsed", + brief: "Maximum number of results per page.", + optional: true, + parse: Number, + }, + page: { + kind: "parsed", + brief: "Page number of paginated results.", + optional: true, + parse: Number, + }, + "token-configuration": { + kind: "parsed", + brief: "Select rules using any of these token configurations.", + variadic: true, + optional: true, + parse: String, + }, + action: { + kind: "enum", + brief: + "Action to take on requests that match operations included in `selector` and fail `expression`.", + values: ["log", "block"], + optional: true, + }, + enabled: { + kind: "boolean", + brief: "Toggle rule on or off.", + optional: true, + }, + id: { + kind: "parsed", + brief: "Select rules with these IDs.", + optional: true, + parse: String, + }, + "rule-id": { + kind: "parsed", + brief: "Select rules with these IDs.", + optional: true, + parse: String, + }, + host: { + kind: "parsed", + brief: "Select rules with this host in `include`.", + optional: true, + parse: String, + }, + hostname: { + kind: "parsed", + brief: "Select rules with this host in `include`.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "api-security token-validation rules list", classification: { safeFlags: ["action", "enabled", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -115,6 +125,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/create.ts b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/create.ts index 1bada2bb78..a5536ec834 100644 --- a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/create.ts +++ b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/create.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/api-security/vulnerability-scanner/credential-sets/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,36 +19,38 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security vulnerability-scanner credential-sets create\n\nCreates a new credential set." - ) - .option("name", { type: "string", description: "Human-readable name." }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create", describe: "Create credential set", - builder, + usage: + "$0 api-security vulnerability-scanner credential-sets create\n\nCreates a new credential set.", + flags: { + name: { + kind: "parsed", + brief: "Human-readable name.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "api-security vulnerability-scanner credential-sets create", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -116,6 +117,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/credentials/create.ts b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/credentials/create.ts index 556f0e788b..25e7a8d6cc 100644 --- a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/credentials/create.ts +++ b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/credentials/create.ts @@ -1,11 +1,10 @@ import operation from "../../../../_operations/api-security/vulnerability-scanner/credential-sets/credentials/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -23,50 +22,58 @@ import { } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security vulnerability-scanner credential-sets credentials create \n\nCreates a new credential within a credential set." - ) - .positional("credential-set-id", { - type: "string", - description: "Credential set identifier.", - demandOption: true, - }) - .option("location", { - type: "string", - description: "Where the credential is attached in outgoing requests.", +const command = apiCommand({ + command: "create ", + describe: "Create credential", + usage: + "$0 api-security vulnerability-scanner credential-sets credentials create \n\nCreates a new credential within a credential set.", + flags: { + location: { + kind: "parsed", + brief: "Where the credential is attached in outgoing requests.", + optional: true, choices: ["header", "cookie"], - }) - .coerce("location", (value) => resolveFileToken(value, "location", "text")) - .option("location-name", { - type: "string", - description: - "Name of the header or cookie where the credential is attached.\n", - }) - .option("name", { type: "string", description: "Human-readable name." }) - .option("value", { - type: "string", - description: + parse: String, + coerce: (value: string) => resolveFileToken(value, "location", "text"), + }, + "location-name": { + kind: "parsed", + brief: "Name of the header or cookie where the credential is attached.\n", + optional: true, + parse: String, + }, + name: { + kind: "parsed", + brief: "Human-readable name.", + optional: true, + parse: String, + }, + value: { + kind: "parsed", + brief: "The credential value (e.g. API key, session token). Write-only.\nNever returned in responses.\n", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "create ", - describe: "Create credential", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "credential-set-id", + brief: "Credential set identifier.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -74,7 +81,7 @@ const command: CommandModule = { "api-security vulnerability-scanner credential-sets credentials create", classification: { safeFlags: ["location", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -194,6 +201,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/credentials/delete.ts b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/credentials/delete.ts index 10dc449905..adfe14087f 100644 --- a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/credentials/delete.ts +++ b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/credentials/delete.ts @@ -1,11 +1,10 @@ import operation from "../../../../_operations/api-security/vulnerability-scanner/credential-sets/credentials/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,40 +17,36 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security vulnerability-scanner credential-sets credentials delete \n\nDeletes a credential." - ) - .positional("credential-id", { - type: "string", - description: "Credential identifier.", - demandOption: true, - }) - .option("credential-set-id", { - type: "string", - description: "Credential set identifier.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete credential", + usage: + "$0 api-security vulnerability-scanner credential-sets credentials delete \n\nDeletes a credential.", + flags: { + "credential-set-id": { + kind: "parsed", + brief: "Credential set identifier.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete credential", - builder, + }, + }, + operands: [ + { + placeholder: "credential-id", + brief: "Credential identifier.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -60,7 +55,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -102,6 +97,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/credentials/edit.ts b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/credentials/edit.ts index 8dba60da1a..c45737d4c8 100644 --- a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/credentials/edit.ts +++ b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/credentials/edit.ts @@ -1,11 +1,10 @@ import operation from "../../../../_operations/api-security/vulnerability-scanner/credential-sets/credentials/edit.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * edit command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,56 +18,63 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security vulnerability-scanner credential-sets credentials edit \n\nUpdates a credential with only the provided fields; omitted fields remain unchanged." - ) - .positional("credential-id", { - type: "string", - description: "Credential identifier.", - demandOption: true, - }) - .option("credential-set-id", { - type: "string", - description: "Credential set identifier.", - demandOption: true, - }) - .option("location", { - type: "string", - description: "Where the credential is attached in outgoing requests.", +const command = apiCommand({ + command: "edit ", + describe: "Edit credential", + usage: + "$0 api-security vulnerability-scanner credential-sets credentials edit \n\nUpdates a credential with only the provided fields; omitted fields remain unchanged.", + flags: { + "credential-set-id": { + kind: "parsed", + brief: "Credential set identifier.", + parse: String, + }, + location: { + kind: "parsed", + brief: "Where the credential is attached in outgoing requests.", + optional: true, choices: ["header", "cookie"], - }) - .coerce("location", (value) => resolveFileToken(value, "location", "text")) - .option("location-name", { - type: "string", - description: - "Name of the header or cookie where the credential is attached.\n", - }) - .option("name", { type: "string", description: "Human-readable name." }) - .option("value", { - type: "string", - description: - "The credential value. Write-only. Never returned in responses.\n", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + parse: String, + coerce: (value: string) => resolveFileToken(value, "location", "text"), + }, + "location-name": { + kind: "parsed", + brief: "Name of the header or cookie where the credential is attached.\n", + optional: true, + parse: String, + }, + name: { + kind: "parsed", + brief: "Human-readable name.", + optional: true, + parse: String, + }, + value: { + kind: "parsed", + brief: "The credential value. Write-only. Never returned in responses.\n", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: + }, + body: { + kind: "parsed", + brief: "Applies a partial update. Only the provided fields change; omitted fields remain unchanged.", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "edit ", - describe: "Edit credential", - builder, + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "credential-id", + brief: "Credential identifier.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -76,7 +82,7 @@ const command: CommandModule = { "api-security vulnerability-scanner credential-sets credentials edit", classification: { safeFlags: ["location", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -167,6 +173,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/credentials/get.ts b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/credentials/get.ts index 1ce8c0db7a..d004d316c3 100644 --- a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/credentials/get.ts +++ b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/credentials/get.ts @@ -1,11 +1,10 @@ import operation from "../../../../_operations/api-security/vulnerability-scanner/credential-sets/credentials/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,42 +16,38 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security vulnerability-scanner credential-sets credentials get \n\nReturns a single credential by ID." - ) - .positional("credential-id", { - type: "string", - description: "Credential identifier.", - demandOption: true, - }) - .option("credential-set-id", { - type: "string", - description: "Credential set identifier.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get credential", - builder, + usage: + "$0 api-security vulnerability-scanner credential-sets credentials get \n\nReturns a single credential by ID.", + flags: { + "credential-set-id": { + kind: "parsed", + brief: "Credential set identifier.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "credential-id", + brief: "Credential identifier.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "api-security vulnerability-scanner credential-sets credentials get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -85,6 +80,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/credentials/index.ts b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/credentials/index.ts index 3b0a63f40d..c28a68abd5 100644 --- a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/credentials/index.ts +++ b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/credentials/index.ts @@ -4,29 +4,24 @@ import $edit from "./edit.js"; import $get from "./get.js"; import $list from "./list.js"; import $update from "./update.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * credentials command group * @generated from apis/overlays/api-security.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "credentials", describe: "Operations for vulnerability-scanner.credential-sets.credentials", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($edit) - .command($get) - .command($list) - .command($update) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + edit: $edit, + get: $get, + list: $list, + update: $update, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/credentials/list.ts b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/credentials/list.ts index 7b10ad8b3d..ecee281fc8 100644 --- a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/credentials/list.ts +++ b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/credentials/list.ts @@ -1,11 +1,10 @@ import operation from "../../../../_operations/api-security/vulnerability-scanner/credential-sets/credentials/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,45 +16,44 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security vulnerability-scanner credential-sets credentials list\n\nReturns all credentials within a credential set." - ) - .option("credential-set-id", { - type: "string", - description: "Credential set identifier.", - demandOption: true, - }) - .option("page", { - type: "number", - description: "Page number of paginated results.", - }) - .option("per-page", { - type: "number", - description: "Number of results per page.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List credentials", - builder, + usage: + "$0 api-security vulnerability-scanner credential-sets credentials list\n\nReturns all credentials within a credential set.", + flags: { + "credential-set-id": { + kind: "parsed", + brief: "Credential set identifier.", + parse: String, + }, + page: { + kind: "parsed", + brief: "Page number of paginated results.", + optional: true, + parse: Number, + }, + "per-page": { + kind: "parsed", + brief: "Number of results per page.", + optional: true, + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "api-security vulnerability-scanner credential-sets credentials list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -92,6 +90,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/credentials/update.ts b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/credentials/update.ts index 2a9ea2551b..2ec91c2b7c 100644 --- a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/credentials/update.ts +++ b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/credentials/update.ts @@ -1,11 +1,10 @@ import operation from "../../../../_operations/api-security/vulnerability-scanner/credential-sets/credentials/update.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -23,55 +22,62 @@ import { } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security vulnerability-scanner credential-sets credentials update \n\nReplaces a credential. All fields must be provided." - ) - .positional("credential-id", { - type: "string", - description: "Credential identifier.", - demandOption: true, - }) - .option("credential-set-id", { - type: "string", - description: "Credential set identifier.", - demandOption: true, - }) - .option("location", { - type: "string", - description: "Where the credential is attached in outgoing requests.", - choices: ["header", "cookie"], - }) - .coerce("location", (value) => resolveFileToken(value, "location", "text")) - .option("location-name", { - type: "string", - description: - "Name of the header or cookie where the credential is attached.\n", - }) - .option("name", { type: "string", description: "Human-readable name." }) - .option("value", { - type: "string", - description: - "The credential value. Write-only. Never returned in responses.\n", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Full replacement. Provide all fields.", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "update ", describe: "Update credential", - builder, + usage: + "$0 api-security vulnerability-scanner credential-sets credentials update \n\nReplaces a credential. All fields must be provided.", + flags: { + "credential-set-id": { + kind: "parsed", + brief: "Credential set identifier.", + parse: String, + }, + location: { + kind: "parsed", + brief: "Where the credential is attached in outgoing requests.", + optional: true, + choices: ["header", "cookie"], + parse: String, + coerce: (value: string) => resolveFileToken(value, "location", "text"), + }, + "location-name": { + kind: "parsed", + brief: "Name of the header or cookie where the credential is attached.\n", + optional: true, + parse: String, + }, + name: { + kind: "parsed", + brief: "Human-readable name.", + optional: true, + parse: String, + }, + value: { + kind: "parsed", + brief: "The credential value. Write-only. Never returned in responses.\n", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Full replacement. Provide all fields.", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "credential-id", + brief: "Credential identifier.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -79,7 +85,7 @@ const command: CommandModule = { "api-security vulnerability-scanner credential-sets credentials update", classification: { safeFlags: ["location", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -202,6 +208,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/delete.ts b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/delete.ts index d063547523..33b2595736 100644 --- a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/delete.ts +++ b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/delete.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/api-security/vulnerability-scanner/credential-sets/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,35 +17,31 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security vulnerability-scanner credential-sets delete \n\nDeletes a credential set and all of its credentials." - ) - .positional("credential-set-id", { - type: "string", - description: "Credential set identifier.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete credential set", + usage: + "$0 api-security vulnerability-scanner credential-sets delete \n\nDeletes a credential set and all of its credentials.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete credential set", - builder, + }, + }, + operands: [ + { + placeholder: "credential-set-id", + brief: "Credential set identifier.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -54,7 +49,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -94,6 +89,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/edit.ts b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/edit.ts index 280735ba3f..b412478408 100644 --- a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/edit.ts +++ b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/edit.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/api-security/vulnerability-scanner/credential-sets/edit.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * edit command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,42 +18,45 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security vulnerability-scanner credential-sets edit \n\nUpdates a credential set with only the provided fields; omitted fields remain unchanged." - ) - .positional("credential-set-id", { - type: "string", - description: "Credential set identifier.", - demandOption: true, - }) - .option("name", { type: "string", description: "Human-readable name." }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: - "Applies a partial update. Only the provided fields change; omitted fields remain unchanged.", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "edit ", describe: "Edit credential set", - builder, + usage: + "$0 api-security vulnerability-scanner credential-sets edit \n\nUpdates a credential set with only the provided fields; omitted fields remain unchanged.", + flags: { + name: { + kind: "parsed", + brief: "Human-readable name.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: + "Applies a partial update. Only the provided fields change; omitted fields remain unchanged.", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "credential-set-id", + brief: "Credential set identifier.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "api-security vulnerability-scanner credential-sets edit", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -119,6 +121,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/get.ts b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/get.ts index d9f97b3e47..34a3103ea7 100644 --- a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/get.ts +++ b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/get.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/api-security/vulnerability-scanner/credential-sets/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,32 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security vulnerability-scanner credential-sets get \n\nReturns a single credential set by ID." - ) - .positional("credential-set-id", { - type: "string", - description: "Credential set identifier.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get credential set", - builder, + usage: + "$0 api-security vulnerability-scanner credential-sets get \n\nReturns a single credential set by ID.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "credential-set-id", + brief: "Credential set identifier.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "api-security vulnerability-scanner credential-sets get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -77,6 +72,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/index.ts b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/index.ts index f41a2f2e55..ab2e62f506 100644 --- a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/index.ts +++ b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/index.ts @@ -5,30 +5,25 @@ import $edit from "./edit.js"; import $get from "./get.js"; import $list from "./list.js"; import $update from "./update.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * credential-sets command group * @generated from apis/overlays/api-security.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "credential-sets", describe: "Operations for vulnerability-scanner.credential-sets", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($edit) - .command($get) - .command($list) - .command($update) - .command($credentials) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + edit: $edit, + get: $get, + list: $list, + update: $update, + credentials: $credentials, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/list.ts b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/list.ts index f68e00c5f3..49d25ce3ac 100644 --- a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/list.ts +++ b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/list.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/api-security/vulnerability-scanner/credential-sets/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,39 +16,38 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security vulnerability-scanner credential-sets list\n\nReturns all credential sets for the account." - ) - .option("page", { - type: "number", - description: "Page number of paginated results.", - }) - .option("per-page", { - type: "number", - description: "Number of results per page.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List credential sets", - builder, + usage: + "$0 api-security vulnerability-scanner credential-sets list\n\nReturns all credential sets for the account.", + flags: { + page: { + kind: "parsed", + brief: "Page number of paginated results.", + optional: true, + parse: Number, + }, + "per-page": { + kind: "parsed", + brief: "Number of results per page.", + optional: true, + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "api-security vulnerability-scanner credential-sets list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -80,6 +78,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/update.ts b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/update.ts index aea402dc5e..28812ee371 100644 --- a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/update.ts +++ b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/credential-sets/update.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/api-security/vulnerability-scanner/credential-sets/update.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,41 +19,44 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security vulnerability-scanner credential-sets update \n\nReplaces a credential set. All fields must be provided." - ) - .positional("credential-set-id", { - type: "string", - description: "Credential set identifier.", - demandOption: true, - }) - .option("name", { type: "string", description: "Human-readable name." }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Full replacement. Provide all fields.", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "update ", describe: "Update credential set", - builder, + usage: + "$0 api-security vulnerability-scanner credential-sets update \n\nReplaces a credential set. All fields must be provided.", + flags: { + name: { + kind: "parsed", + brief: "Human-readable name.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Full replacement. Provide all fields.", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "credential-set-id", + brief: "Credential set identifier.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "api-security vulnerability-scanner credential-sets update", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -131,6 +133,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/index.ts b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/index.ts index e642a2d3fc..44c2ef8b7d 100644 --- a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/index.ts +++ b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/index.ts @@ -1,26 +1,21 @@ import $credentialsets from "./credential-sets/index.js"; import $scans from "./scans/index.js"; import $targetenvironments from "./target-environments/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * vulnerability-scanner command group * @generated from apis/overlays/api-security.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "vulnerability-scanner", describe: "Operations for vulnerability-scanner", - builder: (yargs) => { - return yargs - .command($credentialsets) - .command($scans) - .command($targetenvironments) - .demandCommand(1, "Please specify a subcommand"); + routes: { + "credential-sets": $credentialsets, + scans: $scans, + "target-environments": $targetenvironments, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/scans/create.ts b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/scans/create.ts index ac98f9cbf7..44fe9cdbdc 100644 --- a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/scans/create.ts +++ b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/scans/create.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/api-security/vulnerability-scanner/scans/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -23,61 +22,66 @@ import { } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security vulnerability-scanner scans create\n\nCreates and starts a new vulnerability scan. The response may include non-fatal warnings in the `messages` array." - ) - .option("credential-sets-attacker", { - type: "string", - description: "Credential set ID for the attacker.", - }) - .option("credential-sets-owner", { - type: "string", - description: "Credential set ID for the resource owner.", - }) - .option("open-api", { - type: "string", - description: +const command = apiCommand({ + command: "create", + describe: "Create scan", + usage: + "$0 api-security vulnerability-scanner scans create\n\nCreates and starts a new vulnerability scan. The response may include non-fatal warnings in the `messages` array.", + flags: { + "credential-sets-attacker": { + kind: "parsed", + brief: "Credential set ID for the attacker.", + optional: true, + parse: String, + }, + "credential-sets-owner": { + kind: "parsed", + brief: "Credential set ID for the resource owner.", + optional: true, + parse: String, + }, + "open-api": { + kind: "parsed", + brief: "OpenAPI schema definition for the API under test. The scanner\nuses this to discover endpoints and construct requests.\n", - }) - .option("scan-type", { - type: "string", - description: "The scan_type field", + optional: true, + parse: String, + }, + "scan-type": { + kind: "parsed", + brief: "The scan_type field", + optional: true, choices: ["bola"], - }) - .coerce("scan-type", (value) => - resolveFileToken(value, "scan-type", "text") - ) - .option("target-environment-id", { - type: "string", - description: "The target environment to scan.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + parse: String, + coerce: (value: string) => resolveFileToken(value, "scan-type", "text"), + }, + "target-environment-id": { + kind: "parsed", + brief: "The target environment to scan.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: - "Create a new vulnerability scan. The \`scan_type\` discriminator selects the scan variant and its required context fields. ", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "create", - describe: "Create scan", - builder, + }, + body: { + kind: "parsed", + brief: + "Create a new vulnerability scan. The `scan_type` discriminator selects the scan variant and its required context fields. ", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "api-security vulnerability-scanner scans create", classification: { safeFlags: ["scan-type", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -204,6 +208,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/scans/delete.ts b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/scans/delete.ts index 40a47e649f..ac5980203c 100644 --- a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/scans/delete.ts +++ b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/scans/delete.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/api-security/vulnerability-scanner/scans/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,35 +17,27 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security vulnerability-scanner scans delete \n\nDeletes a scan and all associated data. Only scans in a terminal state (`finished`, `failed`) may be deleted. Attempting to delete a scan that is still being created or executed (`created`, `scheduled`, `planning`, `running`) returns `400`." - ) - .positional("scan-id", { - type: "string", - description: "Scan identifier.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete scan", + usage: + "$0 api-security vulnerability-scanner scans delete \n\nDeletes a scan and all associated data. Only scans in a terminal state (`finished`, `failed`) may be deleted. Attempting to delete a scan that is still being created or executed (`created`, `scheduled`, `planning`, `running`) returns `400`.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete scan", - builder, + }, + }, + operands: [ + { placeholder: "scan-id", brief: "Scan identifier.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -54,7 +45,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -91,6 +82,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/scans/get.ts b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/scans/get.ts index 08953a5dc8..218add5322 100644 --- a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/scans/get.ts +++ b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/scans/get.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/api-security/vulnerability-scanner/scans/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,28 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security vulnerability-scanner scans get \n\nReturns a single scan by ID." - ) - .positional("scan-id", { - type: "string", - description: "Scan identifier.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get scan", - builder, + usage: + "$0 api-security vulnerability-scanner scans get \n\nReturns a single scan by ID.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { placeholder: "scan-id", brief: "Scan identifier.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "api-security vulnerability-scanner scans get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -74,6 +65,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/scans/index.ts b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/scans/index.ts index 72e2a5ad11..d23dfcc455 100644 --- a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/scans/index.ts +++ b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/scans/index.ts @@ -2,27 +2,22 @@ import $create from "./create.js"; import $delete from "./delete.js"; import $get from "./get.js"; import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * scans command group * @generated from apis/overlays/api-security.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "scans", describe: "Operations for vulnerability-scanner.scans", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($get) - .command($list) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + get: $get, + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/scans/list.ts b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/scans/list.ts index 067efc3dbe..6a8ad5cde0 100644 --- a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/scans/list.ts +++ b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/scans/list.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/api-security/vulnerability-scanner/scans/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,39 +16,38 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security vulnerability-scanner scans list\n\nReturns all scans for the account." - ) - .option("page", { - type: "number", - description: "Page number of paginated results.", - }) - .option("per-page", { - type: "number", - description: "Number of results per page.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List scans", - builder, + usage: + "$0 api-security vulnerability-scanner scans list\n\nReturns all scans for the account.", + flags: { + page: { + kind: "parsed", + brief: "Page number of paginated results.", + optional: true, + parse: Number, + }, + "per-page": { + kind: "parsed", + brief: "Number of results per page.", + optional: true, + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "api-security vulnerability-scanner scans list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -79,6 +77,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/target-environments/create.ts b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/target-environments/create.ts index e6cfc220a4..8f5c45e96a 100644 --- a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/target-environments/create.ts +++ b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/target-environments/create.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/api-security/vulnerability-scanner/target-environments/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -23,46 +22,51 @@ import { } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security vulnerability-scanner target-environments create\n\nCreates a new target environment for the account." - ) - .option("description", { - type: "string", - description: "Optional description.", - }) - .option("name", { type: "string", description: "Human-readable name." }) - .option("target-type", { - type: "string", - description: "The target.type field", - choices: ["zone"], - }) - .coerce("target-type", (value) => - resolveFileToken(value, "target-type", "text") - ) - .option("target-zone-tag", { - type: "string", - description: - "Cloudflare zone tag. The zone must belong to the account.\n", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create", describe: "Create target environment", - builder, + usage: + "$0 api-security vulnerability-scanner target-environments create\n\nCreates a new target environment for the account.", + flags: { + description: { + kind: "parsed", + brief: "Optional description.", + optional: true, + parse: String, + }, + name: { + kind: "parsed", + brief: "Human-readable name.", + optional: true, + parse: String, + }, + "target-type": { + kind: "parsed", + brief: "The target.type field", + optional: true, + choices: ["zone"], + parse: String, + coerce: (value: string) => resolveFileToken(value, "target-type", "text"), + }, + "target-zone-tag": { + kind: "parsed", + brief: "Cloudflare zone tag. The zone must belong to the account.\n", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { @@ -70,7 +74,7 @@ const command: CommandModule = { "api-security vulnerability-scanner target-environments create", classification: { safeFlags: ["target-type", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -176,6 +180,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/target-environments/delete.ts b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/target-environments/delete.ts index 49989d1e9f..38a3ccecfe 100644 --- a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/target-environments/delete.ts +++ b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/target-environments/delete.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/api-security/vulnerability-scanner/target-environments/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,35 +17,31 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security vulnerability-scanner target-environments delete \n\nRemoves a target environment." - ) - .positional("target-environment-id", { - type: "string", - description: "Target environment identifier.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete target environment", + usage: + "$0 api-security vulnerability-scanner target-environments delete \n\nRemoves a target environment.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete target environment", - builder, + }, + }, + operands: [ + { + placeholder: "target-environment-id", + brief: "Target environment identifier.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -55,7 +50,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -97,6 +92,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/target-environments/edit.ts b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/target-environments/edit.ts index 67a90363f6..7697526a95 100644 --- a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/target-environments/edit.ts +++ b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/target-environments/edit.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/api-security/vulnerability-scanner/target-environments/edit.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * edit command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,46 +18,61 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security vulnerability-scanner target-environments edit \n\nUpdates a target environment with only the provided fields; omitted fields remain unchanged." - ) - .positional("target-environment-id", { - type: "string", - description: "Target environment identifier.", - demandOption: true, - }) - .option("description", { - type: "string", - description: +const command = apiCommand({ + command: "edit ", + describe: "Edit target environment", + usage: + "$0 api-security vulnerability-scanner target-environments edit \n\nUpdates a target environment with only the provided fields; omitted fields remain unchanged.", + flags: { + description: { + kind: "parsed", + brief: "Optional description. Omit to leave unchanged, set to `null`\nto clear, or provide a string to update.\n", - }) - .option("name", { type: "string", description: "Human-readable name." }) - .option("target-type", { - type: "string", - description: "The target.type field", + optional: true, + parse: String, + }, + name: { + kind: "parsed", + brief: "Human-readable name.", + optional: true, + parse: String, + }, + "target-type": { + kind: "parsed", + brief: "The target.type field", + optional: true, choices: ["zone"], - }) - .coerce("target-type", (value) => - resolveFileToken(value, "target-type", "text") - ) - .option("target-zone-tag", { - type: "string", - description: - "Cloudflare zone tag. The zone must belong to the account.\n", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + parse: String, + coerce: (value: string) => resolveFileToken(value, "target-type", "text"), + }, + "target-zone-tag": { + kind: "parsed", + brief: "Cloudflare zone tag. The zone must belong to the account.\n", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: - 'Applies a partial update. Only the provided fields change; omitted fields remain unchanged. The \`description\` field supports three states: - **omitted**: leave unchanged - **\`null\`**: clear the description - **\`"value"\`**: set to the given string ', - }) - .check((argv) => { + }, + body: { + kind: "parsed", + brief: + 'Applies a partial update. Only the provided fields change; omitted fields remain unchanged. The `description` field supports three states: - **omitted**: leave unchanged - **`null`**: clear the description - **`"value"`**: set to the given string ', + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "target-environment-id", + brief: "Target environment identifier.", + parse: String, + }, + ], + rules(rules) { + rules.check((argv) => { const groupSet = ["target-type", "target-zone-tag"].some( (k) => argv[k] !== undefined ); @@ -74,21 +88,14 @@ function builder(yargs: Argv) { } return true; }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "edit ", - describe: "Edit target environment", - builder, + }, handler: async (argv): Promise => runWithTelemetry( { command: "api-security vulnerability-scanner target-environments edit", classification: { safeFlags: ["target-type", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -181,6 +188,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/target-environments/get.ts b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/target-environments/get.ts index e2a020f1de..540fa375b1 100644 --- a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/target-environments/get.ts +++ b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/target-environments/get.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/api-security/vulnerability-scanner/target-environments/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,32 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security vulnerability-scanner target-environments get \n\nReturns a single target environment by ID." - ) - .positional("target-environment-id", { - type: "string", - description: "Target environment identifier.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get target environment", - builder, + usage: + "$0 api-security vulnerability-scanner target-environments get \n\nReturns a single target environment by ID.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "target-environment-id", + brief: "Target environment identifier.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "api-security vulnerability-scanner target-environments get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -79,6 +74,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/target-environments/index.ts b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/target-environments/index.ts index c87051a9aa..62f3bd1d5b 100644 --- a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/target-environments/index.ts +++ b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/target-environments/index.ts @@ -4,29 +4,24 @@ import $edit from "./edit.js"; import $get from "./get.js"; import $list from "./list.js"; import $update from "./update.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * target-environments command group * @generated from apis/overlays/api-security.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "target-environments", describe: "Operations for vulnerability-scanner.target-environments", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($edit) - .command($get) - .command($list) - .command($update) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + edit: $edit, + get: $get, + list: $list, + update: $update, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/target-environments/list.ts b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/target-environments/list.ts index 63b302763c..50e99751e6 100644 --- a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/target-environments/list.ts +++ b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/target-environments/list.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/api-security/vulnerability-scanner/target-environments/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,39 +16,38 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security vulnerability-scanner target-environments list\n\nReturns all target environments for the account." - ) - .option("page", { - type: "number", - description: "Page number of paginated results.", - }) - .option("per-page", { - type: "number", - description: "Number of results per page.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List target environments", - builder, + usage: + "$0 api-security vulnerability-scanner target-environments list\n\nReturns all target environments for the account.", + flags: { + page: { + kind: "parsed", + brief: "Page number of paginated results.", + optional: true, + parse: Number, + }, + "per-page": { + kind: "parsed", + brief: "Number of results per page.", + optional: true, + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "api-security vulnerability-scanner target-environments list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -80,6 +78,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/target-environments/update.ts b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/target-environments/update.ts index b7bb70575e..8ca2b24a60 100644 --- a/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/target-environments/update.ts +++ b/packages/cli/src/commands/_generated/api-security/vulnerability-scanner/target-environments/update.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/api-security/vulnerability-scanner/target-environments/update.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/api-security.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -23,51 +22,57 @@ import { } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 api-security vulnerability-scanner target-environments update \n\nReplaces a target environment. All fields must be provided." - ) - .positional("target-environment-id", { - type: "string", - description: "Target environment identifier.", - demandOption: true, - }) - .option("description", { - type: "string", - description: "Optional description.", - }) - .option("name", { type: "string", description: "Human-readable name." }) - .option("target-type", { - type: "string", - description: "The target.type field", - choices: ["zone"], - }) - .coerce("target-type", (value) => - resolveFileToken(value, "target-type", "text") - ) - .option("target-zone-tag", { - type: "string", - description: - "Cloudflare zone tag. The zone must belong to the account.\n", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Full replacement.", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "update ", describe: "Update target environment", - builder, + usage: + "$0 api-security vulnerability-scanner target-environments update \n\nReplaces a target environment. All fields must be provided.", + flags: { + description: { + kind: "parsed", + brief: "Optional description.", + optional: true, + parse: String, + }, + name: { + kind: "parsed", + brief: "Human-readable name.", + optional: true, + parse: String, + }, + "target-type": { + kind: "parsed", + brief: "The target.type field", + optional: true, + choices: ["zone"], + parse: String, + coerce: (value: string) => resolveFileToken(value, "target-type", "text"), + }, + "target-zone-tag": { + kind: "parsed", + brief: "Cloudflare zone tag. The zone must belong to the account.\n", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Full replacement.", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "target-environment-id", + brief: "Target environment identifier.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -75,7 +80,7 @@ const command: CommandModule = { "api-security vulnerability-scanner target-environments update", classification: { safeFlags: ["target-type", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -193,6 +198,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/argo/index.ts b/packages/cli/src/commands/_generated/argo/index.ts index 5e43eda985..c4ff84d8db 100644 --- a/packages/cli/src/commands/_generated/argo/index.ts +++ b/packages/cli/src/commands/_generated/argo/index.ts @@ -1,25 +1,20 @@ import $smartrouting from "./smart-routing/index.js"; import $tieredcaching from "./tiered-caching/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * argo command * @generated from apis/overlays/argo.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "argo", describe: "Network optimization features that speed up and improve reliability of traffic to your origins", - builder: (yargs) => { - return yargs - .command($smartrouting) - .command($tieredcaching) - .demandCommand(1, "Please specify a subcommand"); + routes: { + "smart-routing": $smartrouting, + "tiered-caching": $tieredcaching, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/argo/smart-routing/count-zones-enabled-for-account.ts b/packages/cli/src/commands/_generated/argo/smart-routing/count-zones-enabled-for-account.ts index 994a991f8a..cb1bd48daa 100644 --- a/packages/cli/src/commands/_generated/argo/smart-routing/count-zones-enabled-for-account.ts +++ b/packages/cli/src/commands/_generated/argo/smart-routing/count-zones-enabled-for-account.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/argo/smart-routing/count-zones-enabled-for-account.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * count-zones-enabled-for-account command * @generated from apis/overlays/argo.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 argo smart-routing count-zones-enabled-for-account\n\nReturns the number of zones that have Argo Smart Routing enabled for the specified account." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "count-zones-enabled-for-account", describe: "Get count of zones with Argo Smart Routing enabled for account", - builder, + usage: + "$0 argo smart-routing count-zones-enabled-for-account\n\nReturns the number of zones that have Argo Smart Routing enabled for the specified account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "argo smart-routing count-zones-enabled-for-account", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/argo/smart-routing/count-zones-enabled-for-user.ts b/packages/cli/src/commands/_generated/argo/smart-routing/count-zones-enabled-for-user.ts index da3e0aa88b..633bb59258 100644 --- a/packages/cli/src/commands/_generated/argo/smart-routing/count-zones-enabled-for-user.ts +++ b/packages/cli/src/commands/_generated/argo/smart-routing/count-zones-enabled-for-user.ts @@ -1,42 +1,36 @@ import operation from "../../_operations/argo/smart-routing/count-zones-enabled-for-user.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * count-zones-enabled-for-user command * @generated from apis/overlays/argo.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 argo smart-routing count-zones-enabled-for-user\n\nReturns the number of zones that have Argo Smart Routing enabled for the authenticated user." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "count-zones-enabled-for-user", describe: "Get count of zones with Argo Smart Routing enabled for user", - builder, + usage: + "$0 argo smart-routing count-zones-enabled-for-user\n\nReturns the number of zones that have Argo Smart Routing enabled for the authenticated user.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "argo smart-routing count-zones-enabled-for-user", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -58,6 +52,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/argo/smart-routing/edit.ts b/packages/cli/src/commands/_generated/argo/smart-routing/edit.ts index 0ba4b385c4..494d6d3599 100644 --- a/packages/cli/src/commands/_generated/argo/smart-routing/edit.ts +++ b/packages/cli/src/commands/_generated/argo/smart-routing/edit.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/argo/smart-routing/edit.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * edit command * @generated from apis/overlays/argo.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { compactBody, parseBody } from "#lib/body-parser.js"; import { formatDryRun } from "#lib/dry-run.js"; @@ -15,41 +14,40 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredEnumField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 argo smart-routing edit\n\nConfigures the value of the Argo Smart Routing enablement setting." - ) - .option("value", { - type: "string", - description: "Specifies the enablement value of Argo Smart Routing.", - choices: ["on", "off"], - }) - .coerce("value", (value) => resolveFileToken(value, "value", "text")) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Configures the enablement of Argo Smart Routing.", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "edit", describe: "Patch Argo Smart Routing setting", - builder, + usage: + "$0 argo smart-routing edit\n\nConfigures the value of the Argo Smart Routing enablement setting.", + flags: { + value: { + kind: "parsed", + brief: "Specifies the enablement value of Argo Smart Routing.", + optional: true, + choices: ["on", "off"], + parse: String, + coerce: (value: string) => resolveFileToken(value, "value", "text"), + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Configures the enablement of Argo Smart Routing.", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "argo smart-routing edit", classification: { safeFlags: ["value", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -111,6 +109,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/argo/smart-routing/get.ts b/packages/cli/src/commands/_generated/argo/smart-routing/get.ts index 05ac3f55e1..da13b59d46 100644 --- a/packages/cli/src/commands/_generated/argo/smart-routing/get.ts +++ b/packages/cli/src/commands/_generated/argo/smart-routing/get.ts @@ -1,42 +1,36 @@ import operation from "../../_operations/argo/smart-routing/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/argo.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 argo smart-routing get\n\nRetrieves the value of Argo Smart Routing enablement setting." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get", describe: "Get Argo Smart Routing setting", - builder, + usage: + "$0 argo smart-routing get\n\nRetrieves the value of Argo Smart Routing enablement setting.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "argo smart-routing get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -64,6 +58,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/argo/smart-routing/index.ts b/packages/cli/src/commands/_generated/argo/smart-routing/index.ts index 4cfa56f71d..948d10c793 100644 --- a/packages/cli/src/commands/_generated/argo/smart-routing/index.ts +++ b/packages/cli/src/commands/_generated/argo/smart-routing/index.ts @@ -2,28 +2,23 @@ import $countzonesenabledforaccount from "./count-zones-enabled-for-account.js"; import $countzonesenabledforuser from "./count-zones-enabled-for-user.js"; import $edit from "./edit.js"; import $get from "./get.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * smart-routing command group * @generated from apis/overlays/argo.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "smart-routing", describe: "Route traffic through the fastest network paths to your origin using real-time latency data", - builder: (yargs) => { - return yargs - .command($countzonesenabledforaccount) - .command($countzonesenabledforuser) - .command($edit) - .command($get) - .demandCommand(1, "Please specify a subcommand"); + routes: { + "count-zones-enabled-for-account": $countzonesenabledforaccount, + "count-zones-enabled-for-user": $countzonesenabledforuser, + edit: $edit, + get: $get, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/argo/tiered-caching/edit.ts b/packages/cli/src/commands/_generated/argo/tiered-caching/edit.ts index 9f042fb71d..535bf9a45e 100644 --- a/packages/cli/src/commands/_generated/argo/tiered-caching/edit.ts +++ b/packages/cli/src/commands/_generated/argo/tiered-caching/edit.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/argo/tiered-caching/edit.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * edit command * @generated from apis/overlays/argo.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { compactBody, parseBody } from "#lib/body-parser.js"; import { formatDryRun } from "#lib/dry-run.js"; @@ -15,41 +14,40 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredEnumField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 argo tiered-caching edit\n\nEnables or disables Tiered Cache for a zone. Tiered Cache reduces origin traffic by serving lower-tier cache misses from upper-tier data centers before requesting content from your origin." - ) - .option("value", { - type: "string", - description: "Enables or disables Tiered Cache.", - choices: ["on", "off"], - }) - .coerce("value", (value) => resolveFileToken(value, "value", "text")) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Updates whether Tiered Cache is enabled for a zone.", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "edit", describe: "Update Tiered Cache", - builder, + usage: + "$0 argo tiered-caching edit\n\nEnables or disables Tiered Cache for a zone. Tiered Cache reduces origin traffic by serving lower-tier cache misses from upper-tier data centers before requesting content from your origin.", + flags: { + value: { + kind: "parsed", + brief: "Enables or disables Tiered Cache.", + optional: true, + choices: ["on", "off"], + parse: String, + coerce: (value: string) => resolveFileToken(value, "value", "text"), + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Updates whether Tiered Cache is enabled for a zone.", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "argo tiered-caching edit", classification: { safeFlags: ["value", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -111,6 +109,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/argo/tiered-caching/get.ts b/packages/cli/src/commands/_generated/argo/tiered-caching/get.ts index 24736a9fad..08f3c54cf8 100644 --- a/packages/cli/src/commands/_generated/argo/tiered-caching/get.ts +++ b/packages/cli/src/commands/_generated/argo/tiered-caching/get.ts @@ -1,42 +1,36 @@ import operation from "../../_operations/argo/tiered-caching/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/argo.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 argo tiered-caching get\n\nRetrieves whether Tiered Cache is enabled for a zone. Tiered Cache reduces origin traffic by serving lower-tier cache misses from upper-tier data centers before requesting content from your origin." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get", describe: "Get Tiered Cache", - builder, + usage: + "$0 argo tiered-caching get\n\nRetrieves whether Tiered Cache is enabled for a zone. Tiered Cache reduces origin traffic by serving lower-tier cache misses from upper-tier data centers before requesting content from your origin.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "argo tiered-caching get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -64,6 +58,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/argo/tiered-caching/index.ts b/packages/cli/src/commands/_generated/argo/tiered-caching/index.ts index 81ea69c553..ec95fa1756 100644 --- a/packages/cli/src/commands/_generated/argo/tiered-caching/index.ts +++ b/packages/cli/src/commands/_generated/argo/tiered-caching/index.ts @@ -1,25 +1,20 @@ import $edit from "./edit.js"; import $get from "./get.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * tiered-caching command group * @generated from apis/overlays/argo.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "tiered-caching", describe: "Reduce origin load by having upper-tier data centers serve cache misses before reaching your origin", - builder: (yargs) => { - return yargs - .command($edit) - .command($get) - .demandCommand(1, "Please specify a subcommand"); + routes: { + edit: $edit, + get: $get, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/artifacts/index.ts b/packages/cli/src/commands/_generated/artifacts/index.ts index 37717fa80a..3ae072fefc 100644 --- a/packages/cli/src/commands/_generated/artifacts/index.ts +++ b/packages/cli/src/commands/_generated/artifacts/index.ts @@ -1,22 +1,17 @@ import $namespaces from "./namespaces/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * artifacts command * @generated from apis/overlays/artifacts.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "artifacts", describe: "artifacts", - builder: (yargs) => { - return yargs - .command($namespaces) - .demandCommand(1, "Please specify a subcommand"); + routes: { + namespaces: $namespaces, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/artifacts/namespaces/create.ts b/packages/cli/src/commands/_generated/artifacts/namespaces/create.ts index e80bdb1ca8..dc3ad2d45f 100644 --- a/packages/cli/src/commands/_generated/artifacts/namespaces/create.ts +++ b/packages/cli/src/commands/_generated/artifacts/namespaces/create.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/artifacts/namespaces/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/artifacts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,45 +19,47 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 artifacts namespaces create\n\nCreates an empty Artifacts namespace for an account." - ) - .option("jurisdiction", { - type: "string", - description: "The jurisdiction field", - choices: ["unrestricted", "us", "eu", "fedramp"], - default: "unrestricted", - }) - .coerce("jurisdiction", (value) => - resolveFileToken(value, "jurisdiction", "text") - ) - .option("namespace", { type: "string", description: "The namespace field" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create", describe: "Create a namespace", - builder, + usage: + "$0 artifacts namespaces create\n\nCreates an empty Artifacts namespace for an account.", + flags: { + jurisdiction: { + kind: "parsed", + brief: "The jurisdiction field", + default: "unrestricted", + choices: ["unrestricted", "us", "eu", "fedramp"], + parse: String, + coerce: (value: string) => + resolveFileToken(value, "jurisdiction", "text"), + }, + namespace: { + kind: "parsed", + brief: "The namespace field", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "artifacts namespaces create", classification: { safeFlags: ["jurisdiction", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -126,6 +127,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/artifacts/namespaces/delete.ts b/packages/cli/src/commands/_generated/artifacts/namespaces/delete.ts index f6ade70a65..c6dc135f47 100644 --- a/packages/cli/src/commands/_generated/artifacts/namespaces/delete.ts +++ b/packages/cli/src/commands/_generated/artifacts/namespaces/delete.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/artifacts/namespaces/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/artifacts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,35 +17,31 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 artifacts namespaces delete \n\nDeletes an empty Artifacts namespace." - ) - .positional("namespace", { - type: "string", - description: "Artifacts namespace name.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete a namespace", + usage: + "$0 artifacts namespaces delete \n\nDeletes an empty Artifacts namespace.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete a namespace", - builder, + }, + }, + operands: [ + { + placeholder: "namespace", + brief: "Artifacts namespace name.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -54,7 +49,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -86,6 +81,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/artifacts/namespaces/get.ts b/packages/cli/src/commands/_generated/artifacts/namespaces/get.ts index 3f13fbc8a6..f4d14636cd 100644 --- a/packages/cli/src/commands/_generated/artifacts/namespaces/get.ts +++ b/packages/cli/src/commands/_generated/artifacts/namespaces/get.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/artifacts/namespaces/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/artifacts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,32 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 artifacts namespaces get \n\nReturns an Artifacts namespace summary." - ) - .positional("namespace", { - type: "string", - description: "Artifacts namespace name.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get a namespace", - builder, + usage: + "$0 artifacts namespaces get \n\nReturns an Artifacts namespace summary.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "namespace", + brief: "Artifacts namespace name.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "artifacts namespaces get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -74,6 +69,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/artifacts/namespaces/index.ts b/packages/cli/src/commands/_generated/artifacts/namespaces/index.ts index cc93003950..c37ee0b0f3 100644 --- a/packages/cli/src/commands/_generated/artifacts/namespaces/index.ts +++ b/packages/cli/src/commands/_generated/artifacts/namespaces/index.ts @@ -4,29 +4,24 @@ import $get from "./get.js"; import $list from "./list.js"; import $repos from "./repos/index.js"; import $tokens from "./tokens/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * namespaces command group * @generated from apis/overlays/artifacts.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "namespaces", describe: "Operations for namespaces", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($get) - .command($list) - .command($repos) - .command($tokens) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + get: $get, + list: $list, + repos: $repos, + tokens: $tokens, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/artifacts/namespaces/list.ts b/packages/cli/src/commands/_generated/artifacts/namespaces/list.ts index cd1c1dbbda..5713c52f83 100644 --- a/packages/cli/src/commands/_generated/artifacts/namespaces/list.ts +++ b/packages/cli/src/commands/_generated/artifacts/namespaces/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/artifacts/namespaces/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/artifacts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,33 +16,28 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 artifacts namespaces list\n\nLists Artifacts namespaces for an account." - ) - .option("limit", { type: "number", description: "Limit" }) - .option("cursor", { type: "string", description: "Cursor" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List namespaces", - builder, + usage: + "$0 artifacts namespaces list\n\nLists Artifacts namespaces for an account.", + flags: { + limit: { kind: "parsed", brief: "Limit", optional: true, parse: Number }, + cursor: { kind: "parsed", brief: "Cursor", optional: true, parse: String }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "artifacts namespaces list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -73,6 +67,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/blobs/get.ts b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/blobs/get.ts index 97e0a4d8bc..0394d11092 100644 --- a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/blobs/get.ts +++ b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/blobs/get.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/artifacts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,52 +16,44 @@ import { withProgress } from "#lib/progress.js"; import { fetchRawBytes, writeRawOutput } from "#lib/raw-fetch.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 artifacts namespaces repos blobs get \n\nReturns raw bytes for an immutable Git blob object. Blob responses are cacheable forever by hash." - ) - .positional("hash", { - type: "string", - description: "40-character lowercase hexadecimal Git object hash.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Artifacts namespace name.", - demandOption: true, - }) - .option("name", { - type: "string", - description: "Repository name.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "get ", + describe: "Read a Git blob", + usage: + "$0 artifacts namespaces repos blobs get \n\nReturns raw bytes for an immutable Git blob object. Blob responses are cacheable forever by hash.", + flags: { + namespace: { + kind: "parsed", + brief: "Artifacts namespace name.", + parse: String, + }, + name: { kind: "parsed", brief: "Repository name.", parse: String }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("text", { - type: "boolean", - description: + }, + text: { + kind: "boolean", + brief: "Decode the response body as UTF-8 text instead of writing raw bytes", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "get ", - describe: "Read a Git blob", - builder, + }, + }, + operands: [ + { + placeholder: "hash", + brief: "40-character lowercase hexadecimal Git object hash.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "artifacts namespaces repos blobs get", classification: { safeFlags: ["dry-run", "text"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -101,6 +92,6 @@ const command: CommandModule = { return; } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/blobs/index.ts b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/blobs/index.ts index e2658f6bab..aa8ea15033 100644 --- a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/blobs/index.ts +++ b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/blobs/index.ts @@ -1,20 +1,17 @@ import $get from "./get.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * blobs command group * @generated from apis/overlays/artifacts.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "blobs", describe: "Operations for namespaces.repos.blobs", - builder: (yargs) => { - return yargs.command($get).demandCommand(1, "Please specify a subcommand"); + routes: { + get: $get, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/commits/get.ts b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/commits/get.ts index 68c8a0e9b6..07449b1b57 100644 --- a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/commits/get.ts +++ b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/commits/get.ts @@ -1,11 +1,10 @@ import operation from "../../../../_operations/artifacts/namespaces/repos/commits/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/artifacts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,46 +16,38 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 artifacts namespaces repos commits get \n\nReturns decoded metadata for an immutable Git commit object. Commit responses are cacheable forever by hash." - ) - .positional("hash", { - type: "string", - description: "40-character lowercase hexadecimal Git object hash.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Artifacts namespace name.", - demandOption: true, - }) - .option("name", { - type: "string", - description: "Repository name.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Read a Git commit", - builder, + usage: + "$0 artifacts namespaces repos commits get \n\nReturns decoded metadata for an immutable Git commit object. Commit responses are cacheable forever by hash.", + flags: { + namespace: { + kind: "parsed", + brief: "Artifacts namespace name.", + parse: String, + }, + name: { kind: "parsed", brief: "Repository name.", parse: String }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "hash", + brief: "40-character lowercase hexadecimal Git object hash.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "artifacts namespaces repos commits get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -90,6 +81,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/commits/index.ts b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/commits/index.ts index f46859da73..29ee1fb6be 100644 --- a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/commits/index.ts +++ b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/commits/index.ts @@ -1,20 +1,17 @@ import $get from "./get.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * commits command group * @generated from apis/overlays/artifacts.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "commits", describe: "Operations for namespaces.repos.commits", - builder: (yargs) => { - return yargs.command($get).demandCommand(1, "Please specify a subcommand"); + routes: { + get: $get, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/create.ts b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/create.ts index 20fef1d680..a3fdd76706 100644 --- a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/create.ts +++ b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/create.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/artifacts/namespaces/repos/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/artifacts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,54 +19,62 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 artifacts namespaces repos create \n\nCreates a Git-compatible Artifacts repository in a namespace." - ) - .positional("namespace", { - type: "string", - description: "Artifacts namespace name.", - demandOption: true, - }) - .option("default-branch", { - type: "string", - description: - "Git branch name. Must match /^[a-zA-Z0-9][a-zA-Z0-9._/-]*$/, must not contain '..', and must not end with '/' or '.'.", - }) - .option("description", { - type: "string", - description: "The description field", - }) - .option("name", { type: "string", description: "The name field" }) - .option("read-only", { - type: "boolean", - description: "The read_only field", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create ", describe: "Create a repository", - builder, + usage: + "$0 artifacts namespaces repos create \n\nCreates a Git-compatible Artifacts repository in a namespace.", + flags: { + "default-branch": { + kind: "parsed", + brief: + "Git branch name. Must match /^[a-zA-Z0-9][a-zA-Z0-9._/-]*$/, must not contain '..', and must not end with '/' or '.'.", + optional: true, + parse: String, + }, + description: { + kind: "parsed", + brief: "The description field", + optional: true, + parse: String, + }, + name: { + kind: "parsed", + brief: "The name field", + optional: true, + parse: String, + }, + "read-only": { + kind: "boolean", + brief: "The read_only field", + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "namespace", + brief: "Artifacts namespace name.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "artifacts namespaces repos create", classification: { safeFlags: ["read-only", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -163,6 +170,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/delete.ts b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/delete.ts index f3746a7e5e..eadb6c40db 100644 --- a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/delete.ts +++ b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/delete.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/artifacts/namespaces/repos/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/artifacts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,40 +17,30 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 artifacts namespaces repos delete \n\nDeletes a repository and schedules cleanup of its backing data." - ) - .positional("name", { - type: "string", - description: "Repository name.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Artifacts namespace name.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete a repository", + usage: + "$0 artifacts namespaces repos delete \n\nDeletes a repository and schedules cleanup of its backing data.", + flags: { + namespace: { + kind: "parsed", + brief: "Artifacts namespace name.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete a repository", - builder, + }, + }, + operands: [{ placeholder: "name", brief: "Repository name.", parse: String }], handler: async (argv): Promise => runWithTelemetry( { @@ -59,7 +48,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -95,6 +84,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/files/get.ts b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/files/get.ts index d79572c71e..40bda28972 100644 --- a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/files/get.ts +++ b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/files/get.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/artifacts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,57 +16,43 @@ import { withProgress } from "#lib/progress.js"; import { fetchRawBytes, writeRawOutput } from "#lib/raw-fetch.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 artifacts namespaces repos files get \n\nReturns raw bytes for a file resolved by ref and path." - ) - .positional("name", { - type: "string", - description: "Repository name.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Artifacts namespace name.", - demandOption: true, - }) - .option("ref", { - type: "string", - description: "Git ref, branch, tag, or commit hash.", - demandOption: true, - }) - .option("path", { - type: "string", - description: "File path.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "get ", + describe: "Read a file", + usage: + "$0 artifacts namespaces repos files get \n\nReturns raw bytes for a file resolved by ref and path.", + flags: { + namespace: { + kind: "parsed", + brief: "Artifacts namespace name.", + parse: String, + }, + ref: { + kind: "parsed", + brief: "Git ref, branch, tag, or commit hash.", + parse: String, + }, + path: { kind: "parsed", brief: "File path.", parse: String }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("text", { - type: "boolean", - description: + }, + text: { + kind: "boolean", + brief: "Decode the response body as UTF-8 text instead of writing raw bytes", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "get ", - describe: "Read a file", - builder, + }, + }, + operands: [{ placeholder: "name", brief: "Repository name.", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "artifacts namespaces repos files get", classification: { safeFlags: ["dry-run", "text"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -115,6 +100,6 @@ const command: CommandModule = { return; } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/files/index.ts b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/files/index.ts index 6b11bee285..41e1a6ecd0 100644 --- a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/files/index.ts +++ b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/files/index.ts @@ -1,20 +1,17 @@ import $get from "./get.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * files command group * @generated from apis/overlays/artifacts.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "files", describe: "Operations for namespaces.repos.files", - builder: (yargs) => { - return yargs.command($get).demandCommand(1, "Please specify a subcommand"); + routes: { + get: $get, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/fork.ts b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/fork.ts index 1f6044ed7e..e2f5d83e8c 100644 --- a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/fork.ts +++ b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/fork.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/artifacts/namespaces/repos/fork.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * fork command * @generated from apis/overlays/artifacts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,57 +18,53 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 artifacts namespaces repos fork \n\nForks a source repository into a new repository." - ) - .positional("name", { - type: "string", - description: "Repository name.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Artifacts namespace name.", - demandOption: true, - }) - .option("default-branch-only", { - type: "boolean", - description: "The default_branch_only field", - }) - .option("description", { - type: "string", - description: "The description field", - }) - .option("read-only", { - type: "boolean", - description: "The read_only field", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "fork ", describe: "Fork a repository", - builder, + usage: + "$0 artifacts namespaces repos fork \n\nForks a source repository into a new repository.", + flags: { + namespace: { + kind: "parsed", + brief: "Artifacts namespace name.", + parse: String, + }, + "default-branch-only": { + kind: "boolean", + brief: "The default_branch_only field", + optional: true, + }, + description: { + kind: "parsed", + brief: "The description field", + optional: true, + parse: String, + }, + "read-only": { + kind: "boolean", + brief: "The read_only field", + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [{ placeholder: "name", brief: "Repository name.", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "artifacts namespaces repos fork", classification: { safeFlags: ["default-branch-only", "read-only", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -140,6 +135,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/get.ts b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/get.ts index 48d0089d6d..2f359725bf 100644 --- a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/get.ts +++ b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/get.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/artifacts/namespaces/repos/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/artifacts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,41 +16,31 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 artifacts namespaces repos get \n\nReturns repository metadata." - ) - .positional("name", { - type: "string", - description: "Repository name.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Artifacts namespace name.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get a repository", - builder, + usage: + "$0 artifacts namespaces repos get \n\nReturns repository metadata.", + flags: { + namespace: { + kind: "parsed", + brief: "Artifacts namespace name.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [{ placeholder: "name", brief: "Repository name.", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "artifacts namespaces repos get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -83,6 +72,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/import.ts b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/import.ts index 537e321a82..adfdd3bd39 100644 --- a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/import.ts +++ b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/import.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/artifacts/namespaces/repos/import.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * import command * @generated from apis/overlays/artifacts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,56 +19,61 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 artifacts namespaces repos import \n\nImports an HTTPS Git repository into an Artifacts repository." - ) - .positional("name", { - type: "string", - description: "Repository name.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Artifacts namespace name.", - demandOption: true, - }) - .option("branch", { - type: "string", - description: - "Git branch name. Must match /^[a-zA-Z0-9][a-zA-Z0-9._/-]*$/, must not contain '..', and must not end with '/' or '.'.", - }) - .option("depth", { type: "number", description: "The depth field" }) - .option("read-only", { - type: "boolean", - description: "The read_only field", - }) - .option("url", { type: "string", description: "The url field" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "import ", describe: "Import a repository", - builder, + usage: + "$0 artifacts namespaces repos import \n\nImports an HTTPS Git repository into an Artifacts repository.", + flags: { + namespace: { + kind: "parsed", + brief: "Artifacts namespace name.", + parse: String, + }, + branch: { + kind: "parsed", + brief: + "Git branch name. Must match /^[a-zA-Z0-9][a-zA-Z0-9._/-]*$/, must not contain '..', and must not end with '/' or '.'.", + optional: true, + parse: String, + }, + depth: { + kind: "parsed", + brief: "The depth field", + optional: true, + parse: Number, + }, + "read-only": { + kind: "boolean", + brief: "The read_only field", + optional: true, + }, + url: { + kind: "parsed", + brief: "The url field", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [{ placeholder: "name", brief: "Repository name.", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "artifacts namespaces repos import", classification: { safeFlags: ["read-only", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -159,6 +163,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/index.ts b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/index.ts index 09b5066c13..91f759ed1b 100644 --- a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/index.ts +++ b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/index.ts @@ -11,36 +11,31 @@ import $logs from "./logs/index.js"; import $raw from "./raw/index.js"; import $tokens from "./tokens/index.js"; import $trees from "./trees/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * repos command group * @generated from apis/overlays/artifacts.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "repos", describe: "Operations for namespaces.repos", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($fork) - .command($get) - .command($import) - .command($list) - .command($blobs) - .command($commits) - .command($files) - .command($logs) - .command($raw) - .command($tokens) - .command($trees) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + fork: $fork, + get: $get, + import: $import, + list: $list, + blobs: $blobs, + commits: $commits, + files: $files, + logs: $logs, + raw: $raw, + tokens: $tokens, + trees: $trees, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/list.ts b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/list.ts index e799a93318..f7c4fa2140 100644 --- a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/list.ts +++ b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/list.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/artifacts/namespaces/repos/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/artifacts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,49 +16,46 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 artifacts namespaces repos list\n\nLists repositories in a namespace." - ) - .option("namespace", { - type: "string", - description: "Artifacts namespace name.", - demandOption: true, - }) - .option("limit", { type: "number", description: "Limit" }) - .option("cursor", { type: "string", description: "Cursor" }) - .option("search", { type: "string", description: "Search" }) - .option("sort", { - type: "string", - description: "Sort", - choices: ["created_at", "updated_at", "last_push_at", "name"], - }) - .option("direction", { - type: "string", - description: "Direction", - choices: ["asc", "desc"], - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List repositories", - builder, + usage: + "$0 artifacts namespaces repos list\n\nLists repositories in a namespace.", + flags: { + namespace: { + kind: "parsed", + brief: "Artifacts namespace name.", + parse: String, + }, + limit: { kind: "parsed", brief: "Limit", optional: true, parse: Number }, + cursor: { kind: "parsed", brief: "Cursor", optional: true, parse: String }, + search: { kind: "parsed", brief: "Search", optional: true, parse: String }, + sort: { + kind: "enum", + brief: "Sort", + values: ["created_at", "updated_at", "last_push_at", "name"], + optional: true, + }, + direction: { + kind: "enum", + brief: "Direction", + values: ["asc", "desc"], + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "artifacts namespaces repos list", classification: { safeFlags: ["sort", "direction", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -96,6 +92,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/logs/get.ts b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/logs/get.ts index 7fe2e3cf5b..bf1ed84819 100644 --- a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/logs/get.ts +++ b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/logs/get.ts @@ -1,11 +1,10 @@ import operation from "../../../../_operations/artifacts/namespaces/repos/logs/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/artifacts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,47 +16,39 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 artifacts namespaces repos logs get \n\nReturns commit metadata walking backwards from a ref, branch, tag, or HEAD." - ) - .positional("name", { - type: "string", - description: "Repository name.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Artifacts namespace name.", - demandOption: true, - }) - .option("ref", { - type: "string", - description: "Git ref, branch, tag, or commit hash. Defaults to HEAD.", - }) - .option("limit", { type: "number", description: "Limit" }) - .option("offset", { type: "number", description: "Offset" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Read commit history", - builder, + usage: + "$0 artifacts namespaces repos logs get \n\nReturns commit metadata walking backwards from a ref, branch, tag, or HEAD.", + flags: { + namespace: { + kind: "parsed", + brief: "Artifacts namespace name.", + parse: String, + }, + ref: { + kind: "parsed", + brief: "Git ref, branch, tag, or commit hash. Defaults to HEAD.", + optional: true, + parse: String, + }, + limit: { kind: "parsed", brief: "Limit", optional: true, parse: Number }, + offset: { kind: "parsed", brief: "Offset", optional: true, parse: Number }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [{ placeholder: "name", brief: "Repository name.", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "artifacts namespaces repos logs get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -96,6 +87,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/logs/index.ts b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/logs/index.ts index bbbe067e98..ba8e645359 100644 --- a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/logs/index.ts +++ b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/logs/index.ts @@ -1,20 +1,17 @@ import $get from "./get.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * logs command group * @generated from apis/overlays/artifacts.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "logs", describe: "Operations for namespaces.repos.logs", - builder: (yargs) => { - return yargs.command($get).demandCommand(1, "Please specify a subcommand"); + routes: { + get: $get, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/raw/get.ts b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/raw/get.ts index 57afe0a1d3..d691ec77cb 100644 --- a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/raw/get.ts +++ b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/raw/get.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/artifacts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,57 +16,49 @@ import { withProgress } from "#lib/progress.js"; import { fetchRawBytes, writeRawOutput } from "#lib/raw-fetch.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 artifacts namespaces repos raw get \n\nReturns file bytes resolved by ref and path, with a sniffed content type and browser-safe response headers." - ) - .positional("path", { - type: "string", - description: "File path. May contain slashes.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Artifacts namespace name.", - demandOption: true, - }) - .option("name", { - type: "string", - description: "Repository name.", - demandOption: true, - }) - .option("ref", { - type: "string", - description: "Git ref, branch, tag, or 40-character commit hash.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "get ", + describe: "Read a raw file with content type", + usage: + "$0 artifacts namespaces repos raw get \n\nReturns file bytes resolved by ref and path, with a sniffed content type and browser-safe response headers.", + flags: { + namespace: { + kind: "parsed", + brief: "Artifacts namespace name.", + parse: String, + }, + name: { kind: "parsed", brief: "Repository name.", parse: String }, + ref: { + kind: "parsed", + brief: "Git ref, branch, tag, or 40-character commit hash.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("text", { - type: "boolean", - description: + }, + text: { + kind: "boolean", + brief: "Decode the response body as UTF-8 text instead of writing raw bytes", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "get ", - describe: "Read a raw file with content type", - builder, + }, + }, + operands: [ + { + placeholder: "path", + brief: "File path. May contain slashes.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "artifacts namespaces repos raw get", classification: { safeFlags: ["dry-run", "text"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -107,6 +98,6 @@ const command: CommandModule = { return; } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/raw/index.ts b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/raw/index.ts index 7433785633..1c02906800 100644 --- a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/raw/index.ts +++ b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/raw/index.ts @@ -1,20 +1,17 @@ import $get from "./get.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * raw command group * @generated from apis/overlays/artifacts.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "raw", describe: "Operations for namespaces.repos.raw", - builder: (yargs) => { - return yargs.command($get).demandCommand(1, "Please specify a subcommand"); + routes: { + get: $get, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/tokens/index.ts b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/tokens/index.ts index 7b96d46d33..777668a436 100644 --- a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/tokens/index.ts +++ b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/tokens/index.ts @@ -1,20 +1,17 @@ import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * tokens command group * @generated from apis/overlays/artifacts.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "tokens", describe: "Operations for namespaces.repos.tokens", - builder: (yargs) => { - return yargs.command($list).demandCommand(1, "Please specify a subcommand"); + routes: { + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/tokens/list.ts b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/tokens/list.ts index 22dcf91e38..5bc5d8ae15 100644 --- a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/tokens/list.ts +++ b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/tokens/list.ts @@ -1,11 +1,10 @@ import operation from "../../../../_operations/artifacts/namespaces/repos/tokens/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/artifacts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,48 +16,45 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 artifacts namespaces repos tokens list\n\nLists tokens for a repository." - ) - .option("namespace", { - type: "string", - description: "Artifacts namespace name.", - demandOption: true, - }) - .option("name", { - type: "string", - description: "Repository name.", - demandOption: true, - }) - .option("state", { - type: "string", - description: "State", - choices: ["active", "expired", "revoked", "all"], - }) - .option("page", { type: "number", description: "Page" }) - .option("per-page", { type: "number", description: "Per page" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List repository tokens", - builder, + usage: + "$0 artifacts namespaces repos tokens list\n\nLists tokens for a repository.", + flags: { + namespace: { + kind: "parsed", + brief: "Artifacts namespace name.", + parse: String, + }, + name: { kind: "parsed", brief: "Repository name.", parse: String }, + state: { + kind: "enum", + brief: "State", + values: ["active", "expired", "revoked", "all"], + optional: true, + }, + page: { kind: "parsed", brief: "Page", optional: true, parse: Number }, + "per-page": { + kind: "parsed", + brief: "Per page", + optional: true, + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "artifacts namespaces repos tokens list", classification: { safeFlags: ["state", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -97,6 +93,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/trees/get.ts b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/trees/get.ts index 89beb5135d..5d78053122 100644 --- a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/trees/get.ts +++ b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/trees/get.ts @@ -1,11 +1,10 @@ import operation from "../../../../_operations/artifacts/namespaces/repos/trees/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/artifacts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,46 +16,38 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 artifacts namespaces repos trees get \n\nReturns decoded entries for an immutable Git tree object. A commit hash returns that commit's root tree; a blob or tag hash returns 422. Tree responses are cacheable forever by hash." - ) - .positional("hash", { - type: "string", - description: "40-character lowercase hexadecimal Git object hash.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Artifacts namespace name.", - demandOption: true, - }) - .option("name", { - type: "string", - description: "Repository name.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Read a Git tree", - builder, + usage: + "$0 artifacts namespaces repos trees get \n\nReturns decoded entries for an immutable Git tree object. A commit hash returns that commit's root tree; a blob or tag hash returns 422. Tree responses are cacheable forever by hash.", + flags: { + namespace: { + kind: "parsed", + brief: "Artifacts namespace name.", + parse: String, + }, + name: { kind: "parsed", brief: "Repository name.", parse: String }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "hash", + brief: "40-character lowercase hexadecimal Git object hash.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "artifacts namespaces repos trees get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -90,6 +81,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/trees/index.ts b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/trees/index.ts index 45a3f00e08..9278f174f1 100644 --- a/packages/cli/src/commands/_generated/artifacts/namespaces/repos/trees/index.ts +++ b/packages/cli/src/commands/_generated/artifacts/namespaces/repos/trees/index.ts @@ -1,20 +1,17 @@ import $get from "./get.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * trees command group * @generated from apis/overlays/artifacts.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "trees", describe: "Operations for namespaces.repos.trees", - builder: (yargs) => { - return yargs.command($get).demandCommand(1, "Please specify a subcommand"); + routes: { + get: $get, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/artifacts/namespaces/tokens/create.ts b/packages/cli/src/commands/_generated/artifacts/namespaces/tokens/create.ts index 0473b0d684..d2e0cba559 100644 --- a/packages/cli/src/commands/_generated/artifacts/namespaces/tokens/create.ts +++ b/packages/cli/src/commands/_generated/artifacts/namespaces/tokens/create.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/artifacts/namespaces/tokens/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/artifacts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,48 +19,58 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 artifacts namespaces tokens create \n\nCreates a scoped Git token for a repository." - ) - .positional("namespace", { - type: "string", - description: "Artifacts namespace name.", - demandOption: true, - }) - .option("repo", { type: "string", description: "The repo field" }) - .option("scope", { - type: "string", - description: "The scope field", - choices: ["read", "write"], - }) - .coerce("scope", (value) => resolveFileToken(value, "scope", "text")) - .option("ttl", { type: "number", description: "The ttl field" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create ", describe: "Create a repository token", - builder, + usage: + "$0 artifacts namespaces tokens create \n\nCreates a scoped Git token for a repository.", + flags: { + repo: { + kind: "parsed", + brief: "The repo field", + optional: true, + parse: String, + }, + scope: { + kind: "parsed", + brief: "The scope field", + optional: true, + choices: ["read", "write"], + parse: String, + coerce: (value: string) => resolveFileToken(value, "scope", "text"), + }, + ttl: { + kind: "parsed", + brief: "The ttl field", + optional: true, + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "namespace", + brief: "Artifacts namespace name.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "artifacts namespaces tokens create", classification: { safeFlags: ["scope", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -139,6 +148,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/artifacts/namespaces/tokens/index.ts b/packages/cli/src/commands/_generated/artifacts/namespaces/tokens/index.ts index 939e0fe892..8c0944e0d3 100644 --- a/packages/cli/src/commands/_generated/artifacts/namespaces/tokens/index.ts +++ b/packages/cli/src/commands/_generated/artifacts/namespaces/tokens/index.ts @@ -1,24 +1,19 @@ import $create from "./create.js"; import $revoke from "./revoke.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * tokens command group * @generated from apis/overlays/artifacts.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "tokens", describe: "Operations for namespaces.tokens", - builder: (yargs) => { - return yargs - .command($create) - .command($revoke) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + revoke: $revoke, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/artifacts/namespaces/tokens/revoke.ts b/packages/cli/src/commands/_generated/artifacts/namespaces/tokens/revoke.ts index 9851de6a3f..fea76076f2 100644 --- a/packages/cli/src/commands/_generated/artifacts/namespaces/tokens/revoke.ts +++ b/packages/cli/src/commands/_generated/artifacts/namespaces/tokens/revoke.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/artifacts/namespaces/tokens/revoke.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * revoke command * @generated from apis/overlays/artifacts.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,40 +17,36 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 artifacts namespaces tokens revoke \n\nRevokes an Artifacts repository token. Token IDs are resolved through an eventually consistent index, so revoking a token within about a second of creating it can return 404; retry after a short delay." - ) - .positional("id", { - type: "string", - description: "Token ID. Must match /^[0-9a-z]{16}$/.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Artifacts namespace name.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "revoke ", + describe: "Revoke a token", + usage: + "$0 artifacts namespaces tokens revoke \n\nRevokes an Artifacts repository token. Token IDs are resolved through an eventually consistent index, so revoking a token within about a second of creating it can return 404; retry after a short delay.", + flags: { + namespace: { + kind: "parsed", + brief: "Artifacts namespace name.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "revoke ", - describe: "Revoke a token", - builder, + }, + }, + operands: [ + { + placeholder: "id", + brief: "Token ID. Must match /^[0-9a-z]{16}$/.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -59,7 +54,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -95,6 +90,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/audit-logs/index.ts b/packages/cli/src/commands/_generated/audit-logs/index.ts index 3e1515900c..19826b2d80 100644 --- a/packages/cli/src/commands/_generated/audit-logs/index.ts +++ b/packages/cli/src/commands/_generated/audit-logs/index.ts @@ -1,20 +1,17 @@ import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * audit-logs command * @generated from apis/overlays/audit-logs.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "audit-logs", describe: "audit-logs", - builder: (yargs) => { - return yargs.command($list).demandCommand(1, "Please specify a subcommand"); + routes: { + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/audit-logs/list.ts b/packages/cli/src/commands/_generated/audit-logs/list.ts index 6872387af4..9ee1740cc5 100644 --- a/packages/cli/src/commands/_generated/audit-logs/list.ts +++ b/packages/cli/src/commands/_generated/audit-logs/list.ts @@ -1,11 +1,10 @@ import operation from "../_operations/audit-logs/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/audit-logs.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,77 +16,87 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 audit-logs list\n\nGets a list of audit logs for an account. Can be filtered by who made the change, on which zone, and the timeframe of the change." - ) - .option("id", { - type: "string", - description: "Finds a specific log by its ID.", - }) - .option("export", { - type: "boolean", - description: - "Indicates that this request is an export of logs in CSV format.", - }) - .option("action-type", { - type: "string", - description: "Filters by the action type.", - }) - .option("actor-ip", { - type: "string", - description: - "Filters by the IP address of the request that made the change by specific IP address or valid CIDR Range.", - }) - .option("actor-email", { - type: "string", - description: - "Filters by the email address of the actor that made the change.", - }) - .option("since", { type: "string", description: "Since" }) - .option("before", { type: "string", description: "Before" }) - .option("zone-name", { - type: "string", - description: "Filters by the name of the zone associated to the change.", - }) - .option("direction", { - type: "string", - description: "Changes the direction of the chronological sorting.", - choices: ["desc", "asc"], - }) - .option("per-page", { - type: "number", - description: "Sets the number of results to return per page.", - }) - .option("page", { - type: "number", - description: "Defines which page of results to return.", - }) - .option("hide-user-logs", { - type: "boolean", - description: "Indicates whether or not to hide user level audit logs.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "Get account audit logs", - builder, + usage: + "$0 audit-logs list\n\nGets a list of audit logs for an account. Can be filtered by who made the change, on which zone, and the timeframe of the change.", + flags: { + id: { + kind: "parsed", + brief: "Finds a specific log by its ID.", + optional: true, + parse: String, + }, + export: { + kind: "boolean", + brief: "Indicates that this request is an export of logs in CSV format.", + optional: true, + }, + "action-type": { + kind: "parsed", + brief: "Filters by the action type.", + optional: true, + parse: String, + }, + "actor-ip": { + kind: "parsed", + brief: + "Filters by the IP address of the request that made the change by specific IP address or valid CIDR Range.", + optional: true, + parse: String, + }, + "actor-email": { + kind: "parsed", + brief: "Filters by the email address of the actor that made the change.", + optional: true, + parse: String, + }, + since: { kind: "parsed", brief: "Since", optional: true, parse: String }, + before: { kind: "parsed", brief: "Before", optional: true, parse: String }, + "zone-name": { + kind: "parsed", + brief: "Filters by the name of the zone associated to the change.", + optional: true, + parse: String, + }, + direction: { + kind: "enum", + brief: "Changes the direction of the chronological sorting.", + values: ["desc", "asc"], + optional: true, + }, + "per-page": { + kind: "parsed", + brief: "Sets the number of results to return per page.", + optional: true, + parse: Number, + }, + page: { + kind: "parsed", + brief: "Defines which page of results to return.", + optional: true, + parse: Number, + }, + "hide-user-logs": { + kind: "boolean", + brief: "Indicates whether or not to hide user level audit logs.", + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "audit-logs list", classification: { safeFlags: ["export", "direction", "hide-user-logs", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -127,6 +136,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/basin-catalog/credentials/create.ts b/packages/cli/src/commands/_generated/basin-catalog/credentials/create.ts index c95b3f8ce9..c6ece1b669 100644 --- a/packages/cli/src/commands/_generated/basin-catalog/credentials/create.ts +++ b/packages/cli/src/commands/_generated/basin-catalog/credentials/create.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/basin-catalog/credentials/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/basin-catalog.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,44 +19,44 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 basin-catalog credentials create \n\nStore authentication credentials for a catalog. These credentials are used to authenticate with R2 storage when performing catalog operations." - ) - .positional("bucket-name", { - type: "string", - description: "Specifies the R2 bucket name.", - demandOption: true, - }) - .option("token", { - type: "string", - description: "Provides the Cloudflare API token for accessing R2.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Contains request to store catalog credentials.", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create ", describe: "Store catalog credentials", - builder, + usage: + "$0 basin-catalog credentials create \n\nStore authentication credentials for a catalog. These credentials are used to authenticate with R2 storage when performing catalog operations.", + flags: { + token: { + kind: "parsed", + brief: "Provides the Cloudflare API token for accessing R2.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Contains request to store catalog credentials.", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "bucket-name", + brief: "Specifies the R2 bucket name.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "basin-catalog credentials create", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -133,6 +132,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/basin-catalog/credentials/index.ts b/packages/cli/src/commands/_generated/basin-catalog/credentials/index.ts index b826165fb6..580d1e35ab 100644 --- a/packages/cli/src/commands/_generated/basin-catalog/credentials/index.ts +++ b/packages/cli/src/commands/_generated/basin-catalog/credentials/index.ts @@ -1,25 +1,20 @@ import $create from "./create.js"; import $status from "./status.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * credentials command group * @generated from apis/overlays/basin-catalog.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "credentials", describe: "Catalog access credentials for external query engines (Spark, Trino, etc.)", - builder: (yargs) => { - return yargs - .command($create) - .command($status) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + status: $status, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/basin-catalog/credentials/status.ts b/packages/cli/src/commands/_generated/basin-catalog/credentials/status.ts index 6f80bc7e4e..2a0df6c88e 100644 --- a/packages/cli/src/commands/_generated/basin-catalog/credentials/status.ts +++ b/packages/cli/src/commands/_generated/basin-catalog/credentials/status.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/basin-catalog/credentials/status.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * status command * @generated from apis/overlays/basin-catalog.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,32 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 basin-catalog credentials status \n\nCheck whether the configured catalog credentials are valid, invalid, or absent by probing authentication against the catalog." - ) - .positional("bucket-name", { - type: "string", - description: "Specifies the R2 bucket name.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "status ", describe: "Get Basin Catalog credential status", - builder, + usage: + "$0 basin-catalog credentials status \n\nCheck whether the configured catalog credentials are valid, invalid, or absent by probing authentication against the catalog.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "bucket-name", + brief: "Specifies the R2 bucket name.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "basin-catalog credentials status", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -74,6 +69,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/basin-catalog/delete.ts b/packages/cli/src/commands/_generated/basin-catalog/delete.ts index aa6ae9ead6..0916ea416a 100644 --- a/packages/cli/src/commands/_generated/basin-catalog/delete.ts +++ b/packages/cli/src/commands/_generated/basin-catalog/delete.ts @@ -1,11 +1,10 @@ import operation from "../_operations/basin-catalog/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/basin-catalog.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,39 +17,36 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 basin-catalog delete \n\nRemoves the catalog from the control plane without deleting R2 bucket objects. Set force=true to remove catalog namespaces, tables, views, and maintenance metadata. Force deletion is limited to a configured catalog object count." - ) - .positional("bucket-name", { - type: "string", - description: "Specifies the R2 bucket name.", - demandOption: true, - }) - .option("cascade", { - type: "boolean", - description: "Remove child metadata before deleting the catalog.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete Basin Catalog metadata", + usage: + "$0 basin-catalog delete \n\nRemoves the catalog from the control plane without deleting R2 bucket objects. Set force=true to remove catalog namespaces, tables, views, and maintenance metadata. Force deletion is limited to a configured catalog object count.", + flags: { + cascade: { + kind: "boolean", + brief: "Remove child metadata before deleting the catalog.", + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete Basin Catalog metadata", - builder, + }, + }, + operands: [ + { + placeholder: "bucket-name", + brief: "Specifies the R2 bucket name.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -58,7 +54,7 @@ const command: CommandModule = { classification: { safeFlags: ["cascade", "dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -100,6 +96,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Done` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/basin-catalog/disable.ts b/packages/cli/src/commands/_generated/basin-catalog/disable.ts index 6040a41906..ff1865445c 100644 --- a/packages/cli/src/commands/_generated/basin-catalog/disable.ts +++ b/packages/cli/src/commands/_generated/basin-catalog/disable.ts @@ -1,11 +1,10 @@ import operation from "../_operations/basin-catalog/disable.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * disable command * @generated from apis/overlays/basin-catalog.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,35 +17,31 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 basin-catalog disable \n\nDisable an R2 bucket as a catalog. This operation deactivates the catalog but preserves existing metadata and data files. The catalog can be re-enabled later." - ) - .positional("bucket-name", { - type: "string", - description: "Specifies the R2 bucket name to disable as catalog.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "disable ", + describe: "Disable Basin Catalog", + usage: + "$0 basin-catalog disable \n\nDisable an R2 bucket as a catalog. This operation deactivates the catalog but preserves existing metadata and data files. The catalog can be re-enabled later.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "disable ", - describe: "Disable Basin Catalog", - builder, + }, + }, + operands: [ + { + placeholder: "bucket-name", + brief: "Specifies the R2 bucket name to disable as catalog.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -54,7 +49,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -91,6 +86,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Done` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/basin-catalog/enable.ts b/packages/cli/src/commands/_generated/basin-catalog/enable.ts index c2d73c4361..4d284aa78c 100644 --- a/packages/cli/src/commands/_generated/basin-catalog/enable.ts +++ b/packages/cli/src/commands/_generated/basin-catalog/enable.ts @@ -1,11 +1,10 @@ import operation from "../_operations/basin-catalog/enable.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * enable command * @generated from apis/overlays/basin-catalog.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,45 +18,45 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 basin-catalog enable \n\nEnable an R2 bucket as an Apache Iceberg catalog. This operation creates the necessary catalog infrastructure and activates the bucket for storing Iceberg metadata and data files." - ) - .positional("bucket-name", { - type: "string", - description: "Specifies the R2 bucket name to enable as catalog.", - demandOption: true, - }) - .option("credential-token", { - type: "string", - description: "Provides the Cloudflare API token for accessing R2.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: - "Contains the optional request to enable a catalog. Send an empty body to keep the defaults. If you include \`credential\`, the service checks that the token can access the bucket, then stores it as the catalog's maintenance credential, like the store credentials operation. ", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "enable ", describe: "Enable R2 bucket as a catalog", - builder, + usage: + "$0 basin-catalog enable \n\nEnable an R2 bucket as an Apache Iceberg catalog. This operation creates the necessary catalog infrastructure and activates the bucket for storing Iceberg metadata and data files.", + flags: { + "credential-token": { + kind: "parsed", + brief: "Provides the Cloudflare API token for accessing R2.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: + "Contains the optional request to enable a catalog. Send an empty body to keep the defaults. If you include `credential`, the service checks that the token can access the bucket, then stores it as the catalog's maintenance credential, like the store credentials operation. ", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "bucket-name", + brief: "Specifies the R2 bucket name to enable as catalog.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "basin-catalog enable", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -124,6 +123,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/basin-catalog/get.ts b/packages/cli/src/commands/_generated/basin-catalog/get.ts index 137e812d0f..025487e2da 100644 --- a/packages/cli/src/commands/_generated/basin-catalog/get.ts +++ b/packages/cli/src/commands/_generated/basin-catalog/get.ts @@ -1,11 +1,10 @@ import operation from "../_operations/basin-catalog/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/basin-catalog.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,32 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 basin-catalog get \n\nRetrieve detailed information about a specific Basin Catalog by bucket name. Returns catalog status, maintenance configuration, and credential status." - ) - .positional("bucket-name", { - type: "string", - description: "Specifies the R2 bucket name.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get Basin Catalog details", - builder, + usage: + "$0 basin-catalog get \n\nRetrieve detailed information about a specific Basin Catalog by bucket name. Returns catalog status, maintenance configuration, and credential status.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "bucket-name", + brief: "Specifies the R2 bucket name.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "basin-catalog get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -74,6 +69,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/basin-catalog/index.ts b/packages/cli/src/commands/_generated/basin-catalog/index.ts index 2eb12a86f4..ad9f13f406 100644 --- a/packages/cli/src/commands/_generated/basin-catalog/index.ts +++ b/packages/cli/src/commands/_generated/basin-catalog/index.ts @@ -6,32 +6,27 @@ import $get from "./get.js"; import $list from "./list.js"; import $maintenanceconfigs from "./maintenance-configs/index.js"; import $namespaces from "./namespaces/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * basin-catalog command * @generated from apis/overlays/basin-catalog.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "basin-catalog", describe: "Iceberg-compatible data catalog for R2 — organize objects into tables and namespaces for SQL query engines", - builder: (yargs) => { - return yargs - .command($delete) - .command($disable) - .command($enable) - .command($get) - .command($list) - .command($credentials) - .command($maintenanceconfigs) - .command($namespaces) - .demandCommand(1, "Please specify a subcommand"); + routes: { + delete: $delete, + disable: $disable, + enable: $enable, + get: $get, + list: $list, + credentials: $credentials, + "maintenance-configs": $maintenanceconfigs, + namespaces: $namespaces, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/basin-catalog/list.ts b/packages/cli/src/commands/_generated/basin-catalog/list.ts index 7756525fa9..3c0f5357f7 100644 --- a/packages/cli/src/commands/_generated/basin-catalog/list.ts +++ b/packages/cli/src/commands/_generated/basin-catalog/list.ts @@ -1,11 +1,10 @@ import operation from "../_operations/basin-catalog/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/basin-catalog.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 basin-catalog list\n\nReturns a list of R2 buckets that have been enabled as Apache Iceberg catalogs for the specified account. Each catalog represents an R2 bucket configured to store Iceberg metadata and data files." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List Basin Catalogs", - builder, + usage: + "$0 basin-catalog list\n\nReturns a list of R2 buckets that have been enabled as Apache Iceberg catalogs for the specified account. Each catalog represents an R2 bucket configured to store Iceberg metadata and data files.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "basin-catalog list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/basin-catalog/maintenance-configs/get.ts b/packages/cli/src/commands/_generated/basin-catalog/maintenance-configs/get.ts index 2a111632f8..d7954e4033 100644 --- a/packages/cli/src/commands/_generated/basin-catalog/maintenance-configs/get.ts +++ b/packages/cli/src/commands/_generated/basin-catalog/maintenance-configs/get.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/basin-catalog/maintenance-configs/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/basin-catalog.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,32 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 basin-catalog maintenance-configs get \n\nRetrieve the maintenance configuration for a specific catalog, including compaction settings and credential status." - ) - .positional("bucket-name", { - type: "string", - description: "Specifies the R2 bucket name.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get catalog maintenance configuration", - builder, + usage: + "$0 basin-catalog maintenance-configs get \n\nRetrieve the maintenance configuration for a specific catalog, including compaction settings and credential status.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "bucket-name", + brief: "Specifies the R2 bucket name.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "basin-catalog maintenance-configs get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -74,6 +69,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/basin-catalog/maintenance-configs/index.ts b/packages/cli/src/commands/_generated/basin-catalog/maintenance-configs/index.ts index de974ec7c2..c43fdfefa5 100644 --- a/packages/cli/src/commands/_generated/basin-catalog/maintenance-configs/index.ts +++ b/packages/cli/src/commands/_generated/basin-catalog/maintenance-configs/index.ts @@ -1,25 +1,20 @@ import $get from "./get.js"; import $update from "./update.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * maintenance-configs command group * @generated from apis/overlays/basin-catalog.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "maintenance-configs", describe: "Table maintenance settings — compaction schedules and snapshot expiration policies", - builder: (yargs) => { - return yargs - .command($get) - .command($update) - .demandCommand(1, "Please specify a subcommand"); + routes: { + get: $get, + update: $update, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/basin-catalog/maintenance-configs/update.ts b/packages/cli/src/commands/_generated/basin-catalog/maintenance-configs/update.ts index 8b7a11ea7c..96c71ba9b9 100644 --- a/packages/cli/src/commands/_generated/basin-catalog/maintenance-configs/update.ts +++ b/packages/cli/src/commands/_generated/basin-catalog/maintenance-configs/update.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/basin-catalog/maintenance-configs/update.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/basin-catalog.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,68 +18,71 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 basin-catalog maintenance-configs update \n\nUpdate the maintenance configuration for a catalog. This allows you to enable or disable compaction and adjust target file sizes for optimization." - ) - .positional("bucket-name", { - type: "string", - description: "Specifies the R2 bucket name.", - demandOption: true, - }) - .option("compaction-state", { - type: "string", - description: "Specifies the state of maintenance operations.", +const command = apiCommand({ + command: "update ", + describe: "Update catalog maintenance configuration", + usage: + "$0 basin-catalog maintenance-configs update \n\nUpdate the maintenance configuration for a catalog. This allows you to enable or disable compaction and adjust target file sizes for optimization.", + flags: { + "compaction-state": { + kind: "parsed", + brief: "Specifies the state of maintenance operations.", + optional: true, choices: ["enabled", "disabled"], - }) - .coerce("compaction-state", (value) => - resolveFileToken(value, "compaction-state", "text") - ) - .option("compaction-target-size-mb", { - type: "string", - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "compaction-state", "text"), + }, + "compaction-target-size-mb": { + kind: "parsed", + brief: 'Sets the target file size for compaction in megabytes. Defaults to "128".', + optional: true, choices: ["64", "128", "256", "512"], - }) - .coerce("compaction-target-size-mb", (value) => - resolveFileToken(value, "compaction-target-size-mb", "text") - ) - .option("snapshot-expiration-max-snapshot-age", { - type: "string", - description: "Updates the maximum age for snapshots optionally.", - }) - .option("snapshot-expiration-min-snapshots-to-keep", { - type: "number", - description: - "Updates the minimum number of snapshots to retain optionally.", - }) - .option("snapshot-expiration-state", { - type: "string", - description: "Specifies the state of maintenance operations.", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "compaction-target-size-mb", "text"), + }, + "snapshot-expiration-max-snapshot-age": { + kind: "parsed", + brief: "Updates the maximum age for snapshots optionally.", + optional: true, + parse: String, + }, + "snapshot-expiration-min-snapshots-to-keep": { + kind: "parsed", + brief: "Updates the minimum number of snapshots to retain optionally.", + optional: true, + parse: Number, + }, + "snapshot-expiration-state": { + kind: "parsed", + brief: "Specifies the state of maintenance operations.", + optional: true, choices: ["enabled", "disabled"], - }) - .coerce("snapshot-expiration-state", (value) => - resolveFileToken(value, "snapshot-expiration-state", "text") - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "snapshot-expiration-state", "text"), + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: - "Contains request to update catalog maintenance configuration.", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "update ", - describe: "Update catalog maintenance configuration", - builder, + }, + body: { + kind: "parsed", + brief: "Contains request to update catalog maintenance configuration.", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "bucket-name", + brief: "Specifies the R2 bucket name.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -92,7 +94,7 @@ const command: CommandModule = { "snapshot-expiration-state", "dry-run", ], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -176,6 +178,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/basin-catalog/namespaces/index.ts b/packages/cli/src/commands/_generated/basin-catalog/namespaces/index.ts index cc3fcc84cd..b4d8aa4709 100644 --- a/packages/cli/src/commands/_generated/basin-catalog/namespaces/index.ts +++ b/packages/cli/src/commands/_generated/basin-catalog/namespaces/index.ts @@ -1,25 +1,20 @@ import $list from "./list.js"; import $tables from "./tables/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * namespaces command group * @generated from apis/overlays/basin-catalog.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "namespaces", describe: "Logical namespaces that group related tables within the data catalog", - builder: (yargs) => { - return yargs - .command($list) - .command($tables) - .demandCommand(1, "Please specify a subcommand"); + routes: { + list: $list, + tables: $tables, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/basin-catalog/namespaces/list.ts b/packages/cli/src/commands/_generated/basin-catalog/namespaces/list.ts index e3f6bfbd40..7069d1f54c 100644 --- a/packages/cli/src/commands/_generated/basin-catalog/namespaces/list.ts +++ b/packages/cli/src/commands/_generated/basin-catalog/namespaces/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/basin-catalog/namespaces/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/basin-catalog.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,61 +16,64 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 basin-catalog namespaces list\n\nReturns a list of namespaces in the specified Basin Catalog. Supports hierarchical filtering and pagination for efficient traversal of large namespace hierarchies." - ) - .option("bucket-name", { - type: "string", - description: "Specifies the R2 bucket name.", - demandOption: true, - }) - .option("page-token", { - type: "string", - description: +const command = apiCommand({ + command: "list", + describe: "List namespaces in catalog", + usage: + "$0 basin-catalog namespaces list\n\nReturns a list of namespaces in the specified Basin Catalog. Supports hierarchical filtering and pagination for efficient traversal of large namespace hierarchies.", + flags: { + "bucket-name": { + kind: "parsed", + brief: "Specifies the R2 bucket name.", + parse: String, + }, + "page-token": { + kind: "parsed", + brief: "Opaque pagination token from a previous response.\nUse this to fetch the next page of results.", - }) - .option("page-size", { - type: "number", - description: + optional: true, + parse: String, + }, + "page-size": { + kind: "parsed", + brief: "Maximum number of namespaces to return per page.\nDefaults to 100, maximum 1000.", - }) - .option("parent", { - type: "string", - description: + optional: true, + parse: Number, + }, + parent: { + kind: "parsed", + brief: 'Parent namespace to filter by. Only returns direct children of this namespace.\nFor nested namespaces, use %1F as separator (e.g., "bronze%1Fanalytics").\nOmit this parameter to list top-level namespaces.', - }) - .option("return-uuids", { - type: "boolean", - description: + optional: true, + parse: String, + }, + "return-uuids": { + kind: "boolean", + brief: "Whether to include namespace UUIDs in the response.\nSet to true to receive the namespace_uuids array.", - }) - .option("return-details", { - type: "boolean", - description: + optional: true, + }, + "return-details": { + kind: "boolean", + brief: "Whether to include additional metadata (timestamps).\nWhen true, response includes created_at and updated_at arrays.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "list", - describe: "List namespaces in catalog", - builder, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "basin-catalog namespaces list", classification: { safeFlags: ["return-uuids", "return-details", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -108,6 +110,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/get.ts b/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/get.ts index f4cf7fe564..3e5af788c3 100644 --- a/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/get.ts +++ b/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/get.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/basin-catalog/namespaces/tables/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/basin-catalog.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,47 +16,43 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 basin-catalog namespaces tables get \n\nReturns full Apache Iceberg metadata for a single table: schema, partition specs, sort orders, properties, and recent snapshot history. Designed for catalog introspection UIs that need per-table details without holding R2 credentials. The `metadata.snapshots`, `metadata.snapshot-log`, and `metadata.metadata-log` arrays are pruned to the most recent 10 entries by `timestamp-ms`. Use `total_snapshots` and `returned_snapshots` to surface the truncation to end users." - ) - .positional("table-name", { - type: "string", - description: "The table name within the given namespace.", - demandOption: true, - }) - .option("bucket-name", { - type: "string", - description: "Specifies the R2 bucket name.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: - 'The namespace identifier.\nFor nested namespaces, use %1F as separator (e.g., "bronze%1Fanalytics").', - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get table details", - builder, + usage: + "$0 basin-catalog namespaces tables get \n\nReturns full Apache Iceberg metadata for a single table: schema, partition specs, sort orders, properties, and recent snapshot history. Designed for catalog introspection UIs that need per-table details without holding R2 credentials. The `metadata.snapshots`, `metadata.snapshot-log`, and `metadata.metadata-log` arrays are pruned to the most recent 10 entries by `timestamp-ms`. Use `total_snapshots` and `returned_snapshots` to surface the truncation to end users.", + flags: { + "bucket-name": { + kind: "parsed", + brief: "Specifies the R2 bucket name.", + parse: String, + }, + namespace: { + kind: "parsed", + brief: + 'The namespace identifier.\nFor nested namespaces, use %1F as separator (e.g., "bronze%1Fanalytics").', + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "table-name", + brief: "The table name within the given namespace.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "basin-catalog namespaces tables get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -91,6 +86,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/index.ts b/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/index.ts index fefcaf9401..c92b238c49 100644 --- a/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/index.ts +++ b/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/index.ts @@ -2,27 +2,22 @@ import $get from "./get.js"; import $list from "./list.js"; import $maintenanceconfigs from "./maintenance-configs/index.js"; import $maintenanceruns from "./maintenance-runs/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * tables command group * @generated from apis/overlays/basin-catalog.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "tables", describe: "Tables within catalog namespaces", - builder: (yargs) => { - return yargs - .command($get) - .command($list) - .command($maintenanceconfigs) - .command($maintenanceruns) - .demandCommand(1, "Please specify a subcommand"); + routes: { + get: $get, + list: $list, + "maintenance-configs": $maintenanceconfigs, + "maintenance-runs": $maintenanceruns, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/list.ts b/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/list.ts index 64ec415f89..7ed3dade9d 100644 --- a/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/list.ts +++ b/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/list.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/basin-catalog/namespaces/tables/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/basin-catalog.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,62 +16,63 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 basin-catalog namespaces tables list\n\nReturns a list of tables in the specified namespace within a Basin Catalog. Supports pagination for efficient traversal of large table collections." - ) - .option("bucket-name", { - type: "string", - description: "Specifies the R2 bucket name.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: +const command = apiCommand({ + command: "list", + describe: "List tables in namespace", + usage: + "$0 basin-catalog namespaces tables list\n\nReturns a list of tables in the specified namespace within a Basin Catalog. Supports pagination for efficient traversal of large table collections.", + flags: { + "bucket-name": { + kind: "parsed", + brief: "Specifies the R2 bucket name.", + parse: String, + }, + namespace: { + kind: "parsed", + brief: 'The namespace identifier.\nFor nested namespaces, use %1F as separator (e.g., "bronze%1Fanalytics").', - demandOption: true, - }) - .option("page-token", { - type: "string", - description: + parse: String, + }, + "page-token": { + kind: "parsed", + brief: "Opaque pagination token from a previous response.\nUse this to fetch the next page of results.", - }) - .option("page-size", { - type: "number", - description: + optional: true, + parse: String, + }, + "page-size": { + kind: "parsed", + brief: "Maximum number of tables to return per page.\nDefaults to 100, maximum 1000.", - }) - .option("return-uuids", { - type: "boolean", - description: + optional: true, + parse: Number, + }, + "return-uuids": { + kind: "boolean", + brief: "Whether to include table UUIDs in the response.\nSet to true to receive the table_uuids array.", - }) - .option("return-details", { - type: "boolean", - description: + optional: true, + }, + "return-details": { + kind: "boolean", + brief: "Whether to include additional metadata (timestamps, locations).\nWhen true, response includes created_at, updated_at, metadata_locations, and locations arrays.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "list", - describe: "List tables in namespace", - builder, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "basin-catalog namespaces tables list", classification: { safeFlags: ["return-uuids", "return-details", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -112,6 +112,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/maintenance-configs/get.ts b/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/maintenance-configs/get.ts index 81d7de5cac..c27af14659 100644 --- a/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/maintenance-configs/get.ts +++ b/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/maintenance-configs/get.ts @@ -1,11 +1,10 @@ import operation from "../../../../_operations/basin-catalog/namespaces/tables/maintenance-configs/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/basin-catalog.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,47 +16,39 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 basin-catalog namespaces tables maintenance-configs get \n\nRetrieve the maintenance configuration for a specific table, including compaction settings." - ) - .positional("table-name", { - type: "string", - description: "The table name.", - demandOption: true, - }) - .option("bucket-name", { - type: "string", - description: "Specifies the R2 bucket name.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: - "The namespace identifier (use %1F as separator for nested namespaces).", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get table maintenance configuration", - builder, + usage: + "$0 basin-catalog namespaces tables maintenance-configs get \n\nRetrieve the maintenance configuration for a specific table, including compaction settings.", + flags: { + "bucket-name": { + kind: "parsed", + brief: "Specifies the R2 bucket name.", + parse: String, + }, + namespace: { + kind: "parsed", + brief: + "The namespace identifier (use %1F as separator for nested namespaces).", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { placeholder: "table-name", brief: "The table name.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "basin-catalog namespaces tables maintenance-configs get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -92,6 +83,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/maintenance-configs/index.ts b/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/maintenance-configs/index.ts index 7d253be3f1..6e1bbb59ba 100644 --- a/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/maintenance-configs/index.ts +++ b/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/maintenance-configs/index.ts @@ -1,26 +1,21 @@ import $get from "./get.js"; import $queue from "./queue.js"; import $update from "./update.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * maintenance-configs command group * @generated from apis/overlays/basin-catalog.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "maintenance-configs", describe: "Table-level maintenance configurations and operations", - builder: (yargs) => { - return yargs - .command($get) - .command($queue) - .command($update) - .demandCommand(1, "Please specify a subcommand"); + routes: { + get: $get, + queue: $queue, + update: $update, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/maintenance-configs/queue.ts b/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/maintenance-configs/queue.ts index 973423889a..e95fd5f62c 100644 --- a/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/maintenance-configs/queue.ts +++ b/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/maintenance-configs/queue.ts @@ -1,11 +1,10 @@ import operation from "../../../../_operations/basin-catalog/namespaces/tables/maintenance-configs/queue.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * queue command * @generated from apis/overlays/basin-catalog.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,59 +18,51 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 basin-catalog namespaces tables maintenance-configs queue \n\nQueue maintenance for normal polling. This request does not start a run." - ) - .positional("configuration-type", { - type: "string", - description: "Configuration type", - demandOption: true, - }) - .option("bucket-name", { - type: "string", - description: "Specifies the R2 bucket name.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Namespace", - demandOption: true, - }) - .option("table-name", { - type: "string", - description: "Table name", - demandOption: true, - }) - .option("request-id", { - type: "string", - description: "The request_id field", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "queue ", describe: "Queue table maintenance", - builder, + usage: + "$0 basin-catalog namespaces tables maintenance-configs queue \n\nQueue maintenance for normal polling. This request does not start a run.", + flags: { + "bucket-name": { + kind: "parsed", + brief: "Specifies the R2 bucket name.", + parse: String, + }, + namespace: { kind: "parsed", brief: "Namespace", parse: String }, + "table-name": { kind: "parsed", brief: "Table name", parse: String }, + "request-id": { + kind: "parsed", + brief: "The request_id field", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "configuration-type", + brief: "Configuration type", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "basin-catalog namespaces tables maintenance-configs queue", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -145,6 +136,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/maintenance-configs/update.ts b/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/maintenance-configs/update.ts index 2842ca2836..090d5de5f2 100644 --- a/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/maintenance-configs/update.ts +++ b/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/maintenance-configs/update.ts @@ -1,11 +1,10 @@ import operation from "../../../../_operations/basin-catalog/namespaces/tables/maintenance-configs/update.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/basin-catalog.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,79 +18,78 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 basin-catalog namespaces tables maintenance-configs update \n\nUpdate the maintenance configuration for a specific table. This allows you to enable or disable compaction and adjust target file sizes for optimization." - ) - .positional("table-name", { - type: "string", - description: "The table name.", - demandOption: true, - }) - .option("bucket-name", { - type: "string", - description: "Specifies the R2 bucket name.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: +const command = apiCommand({ + command: "update ", + describe: "Update table maintenance configuration", + usage: + "$0 basin-catalog namespaces tables maintenance-configs update \n\nUpdate the maintenance configuration for a specific table. This allows you to enable or disable compaction and adjust target file sizes for optimization.", + flags: { + "bucket-name": { + kind: "parsed", + brief: "Specifies the R2 bucket name.", + parse: String, + }, + namespace: { + kind: "parsed", + brief: "The namespace identifier (use %1F as separator for nested namespaces).", - demandOption: true, - }) - .option("compaction-state", { - type: "string", - description: "Specifies the state of maintenance operations.", + parse: String, + }, + "compaction-state": { + kind: "parsed", + brief: "Specifies the state of maintenance operations.", + optional: true, choices: ["enabled", "disabled"], - }) - .coerce("compaction-state", (value) => - resolveFileToken(value, "compaction-state", "text") - ) - .option("compaction-target-size-mb", { - type: "string", - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "compaction-state", "text"), + }, + "compaction-target-size-mb": { + kind: "parsed", + brief: 'Sets the target file size for compaction in megabytes. Defaults to "128".', + optional: true, choices: ["64", "128", "256", "512"], - }) - .coerce("compaction-target-size-mb", (value) => - resolveFileToken(value, "compaction-target-size-mb", "text") - ) - .option("snapshot-expiration-max-snapshot-age", { - type: "string", - description: "Updates the maximum age for snapshots optionally.", - }) - .option("snapshot-expiration-min-snapshots-to-keep", { - type: "number", - description: - "Updates the minimum number of snapshots to retain optionally.", - }) - .option("snapshot-expiration-state", { - type: "string", - description: "Specifies the state of maintenance operations.", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "compaction-target-size-mb", "text"), + }, + "snapshot-expiration-max-snapshot-age": { + kind: "parsed", + brief: "Updates the maximum age for snapshots optionally.", + optional: true, + parse: String, + }, + "snapshot-expiration-min-snapshots-to-keep": { + kind: "parsed", + brief: "Updates the minimum number of snapshots to retain optionally.", + optional: true, + parse: Number, + }, + "snapshot-expiration-state": { + kind: "parsed", + brief: "Specifies the state of maintenance operations.", + optional: true, choices: ["enabled", "disabled"], - }) - .coerce("snapshot-expiration-state", (value) => - resolveFileToken(value, "snapshot-expiration-state", "text") - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "snapshot-expiration-state", "text"), + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: - "Contains request to update table maintenance configuration.", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "update ", - describe: "Update table maintenance configuration", - builder, + }, + body: { + kind: "parsed", + brief: "Contains request to update table maintenance configuration.", + optional: true, + parse: String, + }, + }, + operands: [ + { placeholder: "table-name", brief: "The table name.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -103,7 +101,7 @@ const command: CommandModule = { "snapshot-expiration-state", "dry-run", ], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -196,6 +194,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/maintenance-runs/index.ts b/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/maintenance-runs/index.ts index b09e6cc81c..6d6e967c59 100644 --- a/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/maintenance-runs/index.ts +++ b/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/maintenance-runs/index.ts @@ -1,20 +1,17 @@ import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * maintenance-runs command group * @generated from apis/overlays/basin-catalog.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "maintenance-runs", describe: "History of maintenance runs performed on tables", - builder: (yargs) => { - return yargs.command($list).demandCommand(1, "Please specify a subcommand"); + routes: { + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/maintenance-runs/list.ts b/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/maintenance-runs/list.ts index 84a7955200..1c96c476de 100644 --- a/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/maintenance-runs/list.ts +++ b/packages/cli/src/commands/_generated/basin-catalog/namespaces/tables/maintenance-runs/list.ts @@ -1,11 +1,10 @@ import operation from "../../../../_operations/basin-catalog/namespaces/tables/maintenance-runs/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/basin-catalog.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,48 +16,45 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 basin-catalog namespaces tables maintenance-runs list\n\nRetrieves recent table maintenance runs for the current table." - ) - .option("bucket-name", { - type: "string", - description: "Specifies the R2 bucket name.", - demandOption: true, - }) - .option("namespace", { - type: "string", - description: "Namespace", - demandOption: true, - }) - .option("table-name", { - type: "string", - description: "Table name", - demandOption: true, - }) - .option("page-size", { type: "number", description: "Page size" }) - .option("page-token", { type: "string", description: "Page token" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List table maintenance runs", - builder, + usage: + "$0 basin-catalog namespaces tables maintenance-runs list\n\nRetrieves recent table maintenance runs for the current table.", + flags: { + "bucket-name": { + kind: "parsed", + brief: "Specifies the R2 bucket name.", + parse: String, + }, + namespace: { kind: "parsed", brief: "Namespace", parse: String }, + "table-name": { kind: "parsed", brief: "Table name", parse: String }, + "page-size": { + kind: "parsed", + brief: "Page size", + optional: true, + parse: Number, + }, + "page-token": { + kind: "parsed", + brief: "Page token", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "basin-catalog namespaces tables maintenance-runs list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -98,6 +94,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/billing/addresses/index.ts b/packages/cli/src/commands/_generated/billing/addresses/index.ts index 6fd108118a..9220a13410 100644 --- a/packages/cli/src/commands/_generated/billing/addresses/index.ts +++ b/packages/cli/src/commands/_generated/billing/addresses/index.ts @@ -1,22 +1,17 @@ import $validate from "./validate.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * addresses command group * @generated from apis/overlays/billing.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "addresses", describe: "Operations for addresses", - builder: (yargs) => { - return yargs - .command($validate) - .demandCommand(1, "Please specify a subcommand"); + routes: { + validate: $validate, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/billing/addresses/validate.ts b/packages/cli/src/commands/_generated/billing/addresses/validate.ts index 854d51a5ba..02cdbd77dd 100644 --- a/packages/cli/src/commands/_generated/billing/addresses/validate.ts +++ b/packages/cli/src/commands/_generated/billing/addresses/validate.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/billing/addresses/validate.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * validate command * @generated from apis/overlays/billing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient } from "#lib/auth.js"; import { compactBody, parseBody } from "#lib/body-parser.js"; import { formatDryRun } from "#lib/dry-run.js"; @@ -14,41 +13,63 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 billing addresses validate\n\nValidates a billing address and returns validated address suggestions. Authentication is not enforced to support pre-signup address validation flows, so credentials are accepted but not required." - ) - .option("address", { type: "string", description: "Address line 1." }) - .option("address2", { type: "string", description: "Address line 2." }) - .option("city", { type: "string", description: "City." }) - .option("country", { type: "string", description: "Country code." }) - .option("state", { type: "string", description: "State or province." }) - .option("zipcode", { type: "string", description: "Postal or zip code." }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "validate", describe: "Validate Billing Address", - builder, + usage: + "$0 billing addresses validate\n\nValidates a billing address and returns validated address suggestions. Authentication is not enforced to support pre-signup address validation flows, so credentials are accepted but not required.", + flags: { + address: { + kind: "parsed", + brief: "Address line 1.", + optional: true, + parse: String, + }, + address2: { + kind: "parsed", + brief: "Address line 2.", + optional: true, + parse: String, + }, + city: { kind: "parsed", brief: "City.", optional: true, parse: String }, + country: { + kind: "parsed", + brief: "Country code.", + optional: true, + parse: String, + }, + state: { + kind: "parsed", + brief: "State or province.", + optional: true, + parse: String, + }, + zipcode: { + kind: "parsed", + brief: "Postal or zip code.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "billing addresses validate", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -149,6 +170,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Validated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/billing/index.ts b/packages/cli/src/commands/_generated/billing/index.ts index 62b1584b49..afe5c630d9 100644 --- a/packages/cli/src/commands/_generated/billing/index.ts +++ b/packages/cli/src/commands/_generated/billing/index.ts @@ -3,29 +3,24 @@ import $profiles from "./profiles/index.js"; import $rateplans from "./rate-plans/index.js"; import $spendpolicies from "./spend-policies/index.js"; import $usage from "./usage/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * billing command * @generated from apis/overlays/billing.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "billing", describe: "Account billing profiles and usage data for Cloudflare subscriptions and add-on services", - builder: (yargs) => { - return yargs - .command($addresses) - .command($profiles) - .command($rateplans) - .command($spendpolicies) - .command($usage) - .demandCommand(1, "Please specify a subcommand"); + routes: { + addresses: $addresses, + profiles: $profiles, + "rate-plans": $rateplans, + "spend-policies": $spendpolicies, + usage: $usage, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/billing/profiles/create-payment-intent.ts b/packages/cli/src/commands/_generated/billing/profiles/create-payment-intent.ts index db9e4894bf..62d50eda34 100644 --- a/packages/cli/src/commands/_generated/billing/profiles/create-payment-intent.ts +++ b/packages/cli/src/commands/_generated/billing/profiles/create-payment-intent.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/billing/profiles/create-payment-intent.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create-payment-intent command * @generated from apis/overlays/billing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 billing profiles create-payment-intent\n\nCreates a Stripe payment intent for adding or updating a payment method on the account's billing profile. Returns a client secret for frontend payment method collection." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create-payment-intent", describe: "Create Payment Intent for Billing Profile", - builder, + usage: + "$0 billing profiles create-payment-intent\n\nCreates a Stripe payment intent for adding or updating a payment method on the account's billing profile. Returns a client secret for frontend payment method collection.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "billing profiles create-payment-intent", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/billing/profiles/create.ts b/packages/cli/src/commands/_generated/billing/profiles/create.ts index 36e4b9cf30..06390fdec6 100644 --- a/packages/cli/src/commands/_generated/billing/profiles/create.ts +++ b/packages/cli/src/commands/_generated/billing/profiles/create.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/billing/profiles/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/billing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,105 +18,146 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 billing profiles create\n\nCreates a billing profile for an account." - ) - .option("address", { - type: "string", - description: "Street address line 1.", - }) - .option("address2", { - type: "string", - description: "Street address line 2 (apt, suite, etc.).", - }) - .option("billing-email", { - type: "string", - description: "Primary billing email address.", - }) - .option("buying-rate-plan", { - type: "string", - description: "Rate plan being purchased right after profile setup.", - }) - .option("captcha-challenge-jwt", { - type: "string", - description: "Captcha challenge JWT issued during onboarding.", - }) - .option("cf-turnstile-response", { - type: "string", - description: "Cloudflare Turnstile response.", - }) - .option("city", { - type: "string", - description: "City on the billing profile.", - }) - .option("company", { - type: "string", - description: "Company name on the billing profile.", - }) - .option("country", { - type: "string", - description: "ISO 3166-1 alpha-2 country code.", - }) - .option("first-name", { - type: "string", - description: "First name on the billing profile.", - }) - .option("h-captcha-response", { - type: "string", - description: "hCaptcha response.", - }) - .option("last-name", { - type: "string", - description: "Last name on the billing profile.", - }) - .option("preferred-locale", { - type: "string", - description: "Preferred locale for invoice rendering (BCP 47).", - }) - .option("secondary-billing-email", { - type: "string", - description: "Secondary billing email address for CC on invoices.", - }) - .option("state", { - type: "string", - description: "State or region on the billing profile.", - }) - .option("tax-id-type", { - type: "string", - description: "Type of tax ID provided.", - }) - .option("telephone", { - type: "string", - description: "Contact phone number.", - }) - .option("vat", { type: "string", description: "VAT identifier." }) - .option("zipcode", { type: "string", description: "ZIP or postal code." }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Request body for creating or updating a billing profile.", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create", describe: "Create Billing Profile", - builder, + usage: + "$0 billing profiles create\n\nCreates a billing profile for an account.", + flags: { + address: { + kind: "parsed", + brief: "Street address line 1.", + optional: true, + parse: String, + }, + address2: { + kind: "parsed", + brief: "Street address line 2 (apt, suite, etc.).", + optional: true, + parse: String, + }, + "billing-email": { + kind: "parsed", + brief: "Primary billing email address.", + optional: true, + parse: String, + }, + "buying-rate-plan": { + kind: "parsed", + brief: "Rate plan being purchased right after profile setup.", + optional: true, + parse: String, + }, + "captcha-challenge-jwt": { + kind: "parsed", + brief: "Captcha challenge JWT issued during onboarding.", + optional: true, + parse: String, + }, + "cf-turnstile-response": { + kind: "parsed", + brief: "Cloudflare Turnstile response.", + optional: true, + parse: String, + }, + city: { + kind: "parsed", + brief: "City on the billing profile.", + optional: true, + parse: String, + }, + company: { + kind: "parsed", + brief: "Company name on the billing profile.", + optional: true, + parse: String, + }, + country: { + kind: "parsed", + brief: "ISO 3166-1 alpha-2 country code.", + optional: true, + parse: String, + }, + "first-name": { + kind: "parsed", + brief: "First name on the billing profile.", + optional: true, + parse: String, + }, + "h-captcha-response": { + kind: "parsed", + brief: "hCaptcha response.", + optional: true, + parse: String, + }, + "last-name": { + kind: "parsed", + brief: "Last name on the billing profile.", + optional: true, + parse: String, + }, + "preferred-locale": { + kind: "parsed", + brief: "Preferred locale for invoice rendering (BCP 47).", + optional: true, + parse: String, + }, + "secondary-billing-email": { + kind: "parsed", + brief: "Secondary billing email address for CC on invoices.", + optional: true, + parse: String, + }, + state: { + kind: "parsed", + brief: "State or region on the billing profile.", + optional: true, + parse: String, + }, + "tax-id-type": { + kind: "parsed", + brief: "Type of tax ID provided.", + optional: true, + parse: String, + }, + telephone: { + kind: "parsed", + brief: "Contact phone number.", + optional: true, + parse: String, + }, + vat: { + kind: "parsed", + brief: "VAT identifier.", + optional: true, + parse: String, + }, + zipcode: { + kind: "parsed", + brief: "ZIP or postal code.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Request body for creating or updating a billing profile.", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "billing profiles create", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -351,6 +391,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/billing/profiles/delete.ts b/packages/cli/src/commands/_generated/billing/profiles/delete.ts index aa323a16b4..6b98e23fa7 100644 --- a/packages/cli/src/commands/_generated/billing/profiles/delete.ts +++ b/packages/cli/src/commands/_generated/billing/profiles/delete.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/billing/profiles/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/billing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,30 +17,25 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 billing profiles delete\n\nDeletes the billing profile for an account." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete", + describe: "Delete Billing Profile", + usage: + "$0 billing profiles delete\n\nDeletes the billing profile for an account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete", - describe: "Delete Billing Profile", - builder, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { @@ -49,7 +43,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -78,6 +72,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/billing/profiles/get.ts b/packages/cli/src/commands/_generated/billing/profiles/get.ts index ff612aa519..770a8cadce 100644 --- a/packages/cli/src/commands/_generated/billing/profiles/get.ts +++ b/packages/cli/src/commands/_generated/billing/profiles/get.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/billing/profiles/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/billing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 billing profiles get\n\nGets the current billing profile for the account." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get", describe: "Get Billing Profile", - builder, + usage: + "$0 billing profiles get\n\nGets the current billing profile for the account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "billing profiles get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/billing/profiles/index.ts b/packages/cli/src/commands/_generated/billing/profiles/index.ts index 5928fd9540..8dcbfa8b7e 100644 --- a/packages/cli/src/commands/_generated/billing/profiles/index.ts +++ b/packages/cli/src/commands/_generated/billing/profiles/index.ts @@ -4,30 +4,25 @@ import $delete from "./delete.js"; import $get from "./get.js"; import $updateemail from "./update-email.js"; import $update from "./update.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * profiles command group * @generated from apis/overlays/billing.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "profiles", describe: "Billing profile with payment method, address, and invoice preferences", - builder: (yargs) => { - return yargs - .command($create) - .command($createpaymentintent) - .command($delete) - .command($get) - .command($update) - .command($updateemail) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + "create-payment-intent": $createpaymentintent, + delete: $delete, + get: $get, + update: $update, + "update-email": $updateemail, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/billing/profiles/update-email.ts b/packages/cli/src/commands/_generated/billing/profiles/update-email.ts index dab74b9fac..1b949cde90 100644 --- a/packages/cli/src/commands/_generated/billing/profiles/update-email.ts +++ b/packages/cli/src/commands/_generated/billing/profiles/update-email.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/billing/profiles/update-email.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update-email command * @generated from apis/overlays/billing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,47 +18,50 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 billing profiles update-email\n\nUpdates the billing email addresses and preferred locale for an account." - ) - .option("billing-email", { - type: "string", - description: "The billing_email field", - }) - .option("preferred-locale", { - type: "string", - description: "The preferred_locale field", - }) - .option("secondary-billing-email", { - type: "string", - description: "The secondary_billing_email field", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "update-email", describe: "Update Billing Email", - builder, + usage: + "$0 billing profiles update-email\n\nUpdates the billing email addresses and preferred locale for an account.", + flags: { + "billing-email": { + kind: "parsed", + brief: "The billing_email field", + optional: true, + parse: String, + }, + "preferred-locale": { + kind: "parsed", + brief: "The preferred_locale field", + optional: true, + parse: String, + }, + "secondary-billing-email": { + kind: "parsed", + brief: "The secondary_billing_email field", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "billing profiles update-email", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -133,6 +135,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/billing/profiles/update.ts b/packages/cli/src/commands/_generated/billing/profiles/update.ts index 3768c7af70..da3f4605ea 100644 --- a/packages/cli/src/commands/_generated/billing/profiles/update.ts +++ b/packages/cli/src/commands/_generated/billing/profiles/update.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/billing/profiles/update.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/billing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,105 +18,146 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 billing profiles update\n\nUpdates the billing profile for an account." - ) - .option("address", { - type: "string", - description: "Street address line 1.", - }) - .option("address2", { - type: "string", - description: "Street address line 2 (apt, suite, etc.).", - }) - .option("billing-email", { - type: "string", - description: "Primary billing email address.", - }) - .option("buying-rate-plan", { - type: "string", - description: "Rate plan being purchased right after profile setup.", - }) - .option("captcha-challenge-jwt", { - type: "string", - description: "Captcha challenge JWT issued during onboarding.", - }) - .option("cf-turnstile-response", { - type: "string", - description: "Cloudflare Turnstile response.", - }) - .option("city", { - type: "string", - description: "City on the billing profile.", - }) - .option("company", { - type: "string", - description: "Company name on the billing profile.", - }) - .option("country", { - type: "string", - description: "ISO 3166-1 alpha-2 country code.", - }) - .option("first-name", { - type: "string", - description: "First name on the billing profile.", - }) - .option("h-captcha-response", { - type: "string", - description: "hCaptcha response.", - }) - .option("last-name", { - type: "string", - description: "Last name on the billing profile.", - }) - .option("preferred-locale", { - type: "string", - description: "Preferred locale for invoice rendering (BCP 47).", - }) - .option("secondary-billing-email", { - type: "string", - description: "Secondary billing email address for CC on invoices.", - }) - .option("state", { - type: "string", - description: "State or region on the billing profile.", - }) - .option("tax-id-type", { - type: "string", - description: "Type of tax ID provided.", - }) - .option("telephone", { - type: "string", - description: "Contact phone number.", - }) - .option("vat", { type: "string", description: "VAT identifier." }) - .option("zipcode", { type: "string", description: "ZIP or postal code." }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Request body for creating or updating a billing profile.", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "update", describe: "Update Billing Profile", - builder, + usage: + "$0 billing profiles update\n\nUpdates the billing profile for an account.", + flags: { + address: { + kind: "parsed", + brief: "Street address line 1.", + optional: true, + parse: String, + }, + address2: { + kind: "parsed", + brief: "Street address line 2 (apt, suite, etc.).", + optional: true, + parse: String, + }, + "billing-email": { + kind: "parsed", + brief: "Primary billing email address.", + optional: true, + parse: String, + }, + "buying-rate-plan": { + kind: "parsed", + brief: "Rate plan being purchased right after profile setup.", + optional: true, + parse: String, + }, + "captcha-challenge-jwt": { + kind: "parsed", + brief: "Captcha challenge JWT issued during onboarding.", + optional: true, + parse: String, + }, + "cf-turnstile-response": { + kind: "parsed", + brief: "Cloudflare Turnstile response.", + optional: true, + parse: String, + }, + city: { + kind: "parsed", + brief: "City on the billing profile.", + optional: true, + parse: String, + }, + company: { + kind: "parsed", + brief: "Company name on the billing profile.", + optional: true, + parse: String, + }, + country: { + kind: "parsed", + brief: "ISO 3166-1 alpha-2 country code.", + optional: true, + parse: String, + }, + "first-name": { + kind: "parsed", + brief: "First name on the billing profile.", + optional: true, + parse: String, + }, + "h-captcha-response": { + kind: "parsed", + brief: "hCaptcha response.", + optional: true, + parse: String, + }, + "last-name": { + kind: "parsed", + brief: "Last name on the billing profile.", + optional: true, + parse: String, + }, + "preferred-locale": { + kind: "parsed", + brief: "Preferred locale for invoice rendering (BCP 47).", + optional: true, + parse: String, + }, + "secondary-billing-email": { + kind: "parsed", + brief: "Secondary billing email address for CC on invoices.", + optional: true, + parse: String, + }, + state: { + kind: "parsed", + brief: "State or region on the billing profile.", + optional: true, + parse: String, + }, + "tax-id-type": { + kind: "parsed", + brief: "Type of tax ID provided.", + optional: true, + parse: String, + }, + telephone: { + kind: "parsed", + brief: "Contact phone number.", + optional: true, + parse: String, + }, + vat: { + kind: "parsed", + brief: "VAT identifier.", + optional: true, + parse: String, + }, + zipcode: { + kind: "parsed", + brief: "ZIP or postal code.", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Request body for creating or updating a billing profile.", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "billing profiles update", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -351,6 +391,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/billing/rate-plans/get.ts b/packages/cli/src/commands/_generated/billing/rate-plans/get.ts index cb1f44e4d7..ee4ee26473 100644 --- a/packages/cli/src/commands/_generated/billing/rate-plans/get.ts +++ b/packages/cli/src/commands/_generated/billing/rate-plans/get.ts @@ -1,47 +1,42 @@ import operation from "../../_operations/billing/rate-plans/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/billing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 billing rate-plans get \n\nGets a rate plan's details by its public key (e.g., 'teams_free', 'cf_pro_20_20'). This is a public catalog endpoint, so authentication is not enforced and credentials are accepted but not required." - ) - .positional("public-key", { - type: "string", - description: "The public key identifier for the rate plan.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get Rate Plan by Public Key", - builder, + usage: + "$0 billing rate-plans get \n\nGets a rate plan's details by its public key (e.g., 'teams_free', 'cf_pro_20_20'). This is a public catalog endpoint, so authentication is not enforced and credentials are accepted but not required.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "public-key", + brief: "The public key identifier for the rate plan.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "billing rate-plans get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -63,6 +58,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/billing/rate-plans/index.ts b/packages/cli/src/commands/_generated/billing/rate-plans/index.ts index fc1576ceee..651d07a72b 100644 --- a/packages/cli/src/commands/_generated/billing/rate-plans/index.ts +++ b/packages/cli/src/commands/_generated/billing/rate-plans/index.ts @@ -1,20 +1,17 @@ import $get from "./get.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * rate-plans command group * @generated from apis/overlays/billing.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "rate-plans", describe: "Operations for rate-plans", - builder: (yargs) => { - return yargs.command($get).demandCommand(1, "Please specify a subcommand"); + routes: { + get: $get, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/billing/spend-policies/activity/index.ts b/packages/cli/src/commands/_generated/billing/spend-policies/activity/index.ts index d4e817b715..85d0eab49c 100644 --- a/packages/cli/src/commands/_generated/billing/spend-policies/activity/index.ts +++ b/packages/cli/src/commands/_generated/billing/spend-policies/activity/index.ts @@ -1,20 +1,17 @@ import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * activity command group * @generated from apis/overlays/billing.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "activity", describe: "Operations for spend-policies.activity", - builder: (yargs) => { - return yargs.command($list).demandCommand(1, "Please specify a subcommand"); + routes: { + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/billing/spend-policies/activity/list.ts b/packages/cli/src/commands/_generated/billing/spend-policies/activity/list.ts index 4febe16d62..de644fb075 100644 --- a/packages/cli/src/commands/_generated/billing/spend-policies/activity/list.ts +++ b/packages/cli/src/commands/_generated/billing/spend-policies/activity/list.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/billing/spend-policies/activity/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/billing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,47 +16,47 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 billing spend-policies activity list\n\nReturns configuration history from immutable policy revisions for the account, including deleted policies. Entries contain before/after values and verified actor attribution. Pages use descending revision IDs, not event or commit order; refresh the first page for new entries. This cursor is not an incremental consumer checkpoint. Defaults to `period=current_billing_cycle`: each revision's timestamp must be within its product's current subscription cycle (inclusive start, exclusive end). Each product's cycle is resolved independently from canonical aggregates, including for disabled or deleted policies. Set `period=all` for history across cycles. Filtering happens before pagination. No current cycles returns an empty page; unavailable or disabled cycle resolution returns `503` with code `1013`. Cursors pin resolved cycle bounds across pages and must be used with the same period selection. Cursors obtained before this filter was introduced must be refreshed." - ) - .option("limit", { - type: "number", - description: +const command = apiCommand({ + command: "list", + describe: "List Spend Policy Activity", + usage: + "$0 billing spend-policies activity list\n\nReturns configuration history from immutable policy revisions for the account, including deleted policies. Entries contain before/after values and verified actor attribution. Pages use descending revision IDs, not event or commit order; refresh the first page for new entries. This cursor is not an incremental consumer checkpoint. Defaults to `period=current_billing_cycle`: each revision's timestamp must be within its product's current subscription cycle (inclusive start, exclusive end). Each product's cycle is resolved independently from canonical aggregates, including for disabled or deleted policies. Set `period=all` for history across cycles. Filtering happens before pagination. No current cycles returns an empty page; unavailable or disabled cycle resolution returns `503` with code `1013`. Cursors pin resolved cycle bounds across pages and must be used with the same period selection. Cursors obtained before this filter was introduced must be refreshed.", + flags: { + limit: { + kind: "parsed", + brief: "Maximum number of audit entries to return. Defaults to 50. Values above 100 are capped at 100 rather than rejected.", - }) - .option("period", { - type: "string", - description: + optional: true, + parse: Number, + }, + period: { + kind: "enum", + brief: "Select current subscription billing-cycle history or history across all cycles.", - choices: ["current_billing_cycle", "all"], - }) - .option("cursor", { - type: "string", - description: + values: ["current_billing_cycle", "all"], + optional: true, + }, + cursor: { + kind: "parsed", + brief: "Opaque token from the preceding response's result_info.cursor. Pass it unchanged to retrieve older entries.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "list", - describe: "List Spend Policy Activity", - builder, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "billing spend-policies activity list", classification: { safeFlags: ["period", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -88,6 +87,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/billing/spend-policies/audit/index.ts b/packages/cli/src/commands/_generated/billing/spend-policies/audit/index.ts index 336a64529f..2e6530c0aa 100644 --- a/packages/cli/src/commands/_generated/billing/spend-policies/audit/index.ts +++ b/packages/cli/src/commands/_generated/billing/spend-policies/audit/index.ts @@ -1,20 +1,17 @@ import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * audit command group * @generated from apis/overlays/billing.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "audit", describe: "Operations for spend-policies.audit", - builder: (yargs) => { - return yargs.command($list).demandCommand(1, "Please specify a subcommand"); + routes: { + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/billing/spend-policies/audit/list.ts b/packages/cli/src/commands/_generated/billing/spend-policies/audit/list.ts index bf73b218d4..4ab4e6de44 100644 --- a/packages/cli/src/commands/_generated/billing/spend-policies/audit/list.ts +++ b/packages/cli/src/commands/_generated/billing/spend-policies/audit/list.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/billing/spend-policies/audit/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/billing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,47 +16,45 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 billing spend-policies audit list\n\nReturns the policy's evaluation history, newest first. At most one threshold-crossing entry (`limit_reached`) is recorded per policy version and billing period, so a policy update can record a new entry without any change in balance. Disabled policies still return their history; deleted policies return `404`. There is no pagination: use `limit` to set how many entries come back. Defaults to `period=current_billing_cycle`, resolved from the product's canonical aggregates, not calendar months. Crossings match their recorded billing-period bounds, even if recorded late. Set `period=all` for history across cycles. Filtering happens before LIMIT. No current cycle returns an empty array; unavailable or disabled cycle resolution returns `503` with code `1013`, never an empty success." - ) - .option("policy-id", { - type: "string", - description: "Identifies the spend policy.", - demandOption: true, - }) - .option("limit", { - type: "number", - description: +const command = apiCommand({ + command: "list", + describe: "List Spend Policy Audit Entries", + usage: + "$0 billing spend-policies audit list\n\nReturns the policy's evaluation history, newest first. At most one threshold-crossing entry (`limit_reached`) is recorded per policy version and billing period, so a policy update can record a new entry without any change in balance. Disabled policies still return their history; deleted policies return `404`. There is no pagination: use `limit` to set how many entries come back. Defaults to `period=current_billing_cycle`, resolved from the product's canonical aggregates, not calendar months. Crossings match their recorded billing-period bounds, even if recorded late. Set `period=all` for history across cycles. Filtering happens before LIMIT. No current cycle returns an empty array; unavailable or disabled cycle resolution returns `503` with code `1013`, never an empty success.", + flags: { + "policy-id": { + kind: "parsed", + brief: "Identifies the spend policy.", + parse: String, + }, + limit: { + kind: "parsed", + brief: "Maximum number of audit entries to return. Defaults to 50. Values above 100 are capped at 100 rather than rejected.", - }) - .option("period", { - type: "string", - description: + optional: true, + parse: Number, + }, + period: { + kind: "enum", + brief: "Select current subscription billing-cycle history or history across all cycles.", - choices: ["current_billing_cycle", "all"], - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + values: ["current_billing_cycle", "all"], + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "list", - describe: "List Spend Policy Audit Entries", - builder, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "billing spend-policies audit list", classification: { safeFlags: ["period", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -91,6 +88,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/billing/spend-policies/create.ts b/packages/cli/src/commands/_generated/billing/spend-policies/create.ts index 69aa07489c..16a6003f37 100644 --- a/packages/cli/src/commands/_generated/billing/spend-policies/create.ts +++ b/packages/cli/src/commands/_generated/billing/spend-policies/create.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/billing/spend-policies/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/billing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -23,71 +22,77 @@ import { } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 billing spend-policies create\n\nCreates a spend policy. Each account can have only one enabled `usage_block` policy per product. A second one returns `409`. There is no limit on `notification` policies." - ) - .option("action", { - type: "string", - description: +const command = apiCommand({ + command: "create", + describe: "Create Spend Policy", + usage: + "$0 billing spend-policies create\n\nCreates a spend policy. Each account can have only one enabled `usage_block` policy per product. A second one returns `409`. There is no limit on `notification` policies.", + flags: { + action: { + kind: "parsed", + brief: "The action taken when the threshold is reached. `notification` sends an email to `notification_email`. `usage_block` blocks further usage of the product until the end of the billing period. Raising the threshold above the current balance, disabling the policy, or deleting it lifts the block early.", + optional: true, choices: ["notification", "usage_block"], - }) - .coerce("action", (value) => resolveFileToken(value, "action", "text")) - .option("enabled", { - type: "boolean", - description: "Whether the policy is evaluated.", - }) - .option("name", { - type: "string", - description: + parse: String, + coerce: (value: string) => resolveFileToken(value, "action", "text"), + }, + enabled: { + kind: "boolean", + brief: "Whether the policy is evaluated.", + optional: true, + }, + name: { + kind: "parsed", + brief: "Display name of the policy. After surrounding whitespace is trimmed, it must be 1 to 200 bytes long. The value is stored as sent, untrimmed.", - }) - .option("notification-email", { - type: "string", - description: + optional: true, + parse: String, + }, + "notification-email": { + kind: "parsed", + brief: "Email address that receives notifications. Required when `action` is `notification`. When set, it must be a bare address (`user@example.com`); display-name forms such as `Name ` are rejected.", - }) - .option("product-id", { - type: "string", - description: + optional: true, + parse: String, + }, + "product-id": { + kind: "parsed", + brief: "The product the policy applies to: `workers` or `durable_objects`. Each product's balance and policies are separate. Both products support `notification` and `usage_block` policies on create and update.", + optional: true, choices: ["workers", "durable_objects"], - }) - .coerce("product-id", (value) => - resolveFileToken(value, "product-id", "text") - ) - .option("threshold-cents", { - type: "number", - description: + parse: String, + coerce: (value: string) => resolveFileToken(value, "product-id", "text"), + }, + "threshold-cents": { + kind: "parsed", + brief: "The spend threshold for the current billing period, in US cents. Must be greater than zero.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: + }, + body: { + kind: "parsed", + brief: "A spend policy as sent on create and on full replacement. Unknown fields and trailing JSON are rejected. Only the first 1 MiB of the body is read.", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "create", - describe: "Create Spend Policy", - builder, + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "billing spend-policies create", classification: { safeFlags: ["action", "enabled", "product-id", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -195,6 +200,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/billing/spend-policies/delete.ts b/packages/cli/src/commands/_generated/billing/spend-policies/delete.ts index d6738eacb0..aa37f14a00 100644 --- a/packages/cli/src/commands/_generated/billing/spend-policies/delete.ts +++ b/packages/cli/src/commands/_generated/billing/spend-policies/delete.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/billing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,41 +17,37 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 billing spend-policies delete \n\nSoft-deletes the spend policy. The policy is disabled and no longer appears in list, get or audit responses. The `If-Match` header must equal the policy's current `version`." - ) - .positional("policy-id", { - type: "string", - description: "Identifies the spend policy.", - demandOption: true, - }) - .option("if-match", { - type: "string", - description: +const command = apiCommand({ + command: "delete ", + describe: "Delete Spend Policy", + usage: + "$0 billing spend-policies delete \n\nSoft-deletes the spend policy. The policy is disabled and no longer appears in list, get or audit responses. The `If-Match` header must equal the policy's current `version`.", + flags: { + "if-match": { + kind: "parsed", + brief: 'The policy `version` the change is based on, as returned in `ETag`. Quoted (`"3"`) and bare (`3`) values are both accepted. Weak ETags (`W/"3"`) and `*` are not.', - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete Spend Policy", - builder, + }, + }, + operands: [ + { + placeholder: "policy-id", + brief: "Identifies the spend policy.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -60,7 +55,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -97,6 +92,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/billing/spend-policies/get.ts b/packages/cli/src/commands/_generated/billing/spend-policies/get.ts index c4061df78f..c29e33a473 100644 --- a/packages/cli/src/commands/_generated/billing/spend-policies/get.ts +++ b/packages/cli/src/commands/_generated/billing/spend-policies/get.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/billing/spend-policies/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/billing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,32 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 billing spend-policies get \n\nReturns one spend policy. The `ETag` response header holds the current `version`; send it as `If-Match` on a later update or delete." - ) - .positional("policy-id", { - type: "string", - description: "Identifies the spend policy.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get Spend Policy", - builder, + usage: + "$0 billing spend-policies get \n\nReturns one spend policy. The `ETag` response header holds the current `version`; send it as `If-Match` on a later update or delete.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "policy-id", + brief: "Identifies the spend policy.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "billing spend-policies get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -74,6 +69,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/billing/spend-policies/index.ts b/packages/cli/src/commands/_generated/billing/spend-policies/index.ts index 1a705c387a..11a5c1405c 100644 --- a/packages/cli/src/commands/_generated/billing/spend-policies/index.ts +++ b/packages/cli/src/commands/_generated/billing/spend-policies/index.ts @@ -5,30 +5,25 @@ import $delete from "./delete.js"; import $get from "./get.js"; import $list from "./list.js"; import $update from "./update.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * spend-policies command group * @generated from apis/overlays/billing.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "spend-policies", describe: "Operations for spend-policies", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($get) - .command($list) - .command($update) - .command($activity) - .command($audit) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + get: $get, + list: $list, + update: $update, + activity: $activity, + audit: $audit, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/billing/spend-policies/list.ts b/packages/cli/src/commands/_generated/billing/spend-policies/list.ts index 7349919e53..80ef926e89 100644 --- a/packages/cli/src/commands/_generated/billing/spend-policies/list.ts +++ b/packages/cli/src/commands/_generated/billing/spend-policies/list.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/billing/spend-policies/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/billing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 billing spend-policies list\n\nReturns every spend policy on the account that has not been deleted, including disabled ones. Results are sorted by `name`, then `id`. There is no pagination." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List Spend Policies", - builder, + usage: + "$0 billing spend-policies list\n\nReturns every spend policy on the account that has not been deleted, including disabled ones. Results are sorted by `name`, then `id`. There is no pagination.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "billing spend-policies list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/billing/spend-policies/update.ts b/packages/cli/src/commands/_generated/billing/spend-policies/update.ts index 5e667feb23..e1cdf5d5ba 100644 --- a/packages/cli/src/commands/_generated/billing/spend-policies/update.ts +++ b/packages/cli/src/commands/_generated/billing/spend-policies/update.ts @@ -1,10 +1,9 @@ -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/billing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -23,82 +22,89 @@ import { } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 billing spend-policies update \n\nReplaces the whole spend policy. Every field is required, as on create; there are no partial updates and `PATCH` is not supported. The `If-Match` header must equal the policy's current `version`. On success, `version` goes up by one and the new value is returned in `ETag`." - ) - .positional("policy-id", { - type: "string", - description: "Identifies the spend policy.", - demandOption: true, - }) - .option("if-match", { - type: "string", - description: +const command = apiCommand({ + command: "update ", + describe: "Update Spend Policy", + usage: + "$0 billing spend-policies update \n\nReplaces the whole spend policy. Every field is required, as on create; there are no partial updates and `PATCH` is not supported. The `If-Match` header must equal the policy's current `version`. On success, `version` goes up by one and the new value is returned in `ETag`.", + flags: { + "if-match": { + kind: "parsed", + brief: 'The policy `version` the change is based on, as returned in `ETag`. Quoted (`"3"`) and bare (`3`) values are both accepted. Weak ETags (`W/"3"`) and `*` are not.', - demandOption: true, - }) - .option("action", { - type: "string", - description: + parse: String, + }, + action: { + kind: "parsed", + brief: "The action taken when the threshold is reached. `notification` sends an email to `notification_email`. `usage_block` blocks further usage of the product until the end of the billing period. Raising the threshold above the current balance, disabling the policy, or deleting it lifts the block early.", + optional: true, choices: ["notification", "usage_block"], - }) - .coerce("action", (value) => resolveFileToken(value, "action", "text")) - .option("enabled", { - type: "boolean", - description: "Whether the policy is evaluated.", - }) - .option("name", { - type: "string", - description: + parse: String, + coerce: (value: string) => resolveFileToken(value, "action", "text"), + }, + enabled: { + kind: "boolean", + brief: "Whether the policy is evaluated.", + optional: true, + }, + name: { + kind: "parsed", + brief: "Display name of the policy. After surrounding whitespace is trimmed, it must be 1 to 200 bytes long. The value is stored as sent, untrimmed.", - }) - .option("notification-email", { - type: "string", - description: + optional: true, + parse: String, + }, + "notification-email": { + kind: "parsed", + brief: "Email address that receives notifications. Required when `action` is `notification`. When set, it must be a bare address (`user@example.com`); display-name forms such as `Name ` are rejected.", - }) - .option("product-id", { - type: "string", - description: + optional: true, + parse: String, + }, + "product-id": { + kind: "parsed", + brief: "The product the policy applies to: `workers` or `durable_objects`. Each product's balance and policies are separate. Both products support `notification` and `usage_block` policies on create and update.", + optional: true, choices: ["workers", "durable_objects"], - }) - .coerce("product-id", (value) => - resolveFileToken(value, "product-id", "text") - ) - .option("threshold-cents", { - type: "number", - description: + parse: String, + coerce: (value: string) => resolveFileToken(value, "product-id", "text"), + }, + "threshold-cents": { + kind: "parsed", + brief: "The spend threshold for the current billing period, in US cents. Must be greater than zero.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: + }, + body: { + kind: "parsed", + brief: "A spend policy as sent on create and on full replacement. Unknown fields and trailing JSON are rejected. Only the first 1 MiB of the body is read.", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "update ", - describe: "Update Spend Policy", - builder, + optional: true, + parse: String, + }, + }, + operands: [ + { + placeholder: "policy-id", + brief: "Identifies the spend policy.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "billing spend-policies update", classification: { safeFlags: ["action", "enabled", "product-id", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -238,6 +244,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/billing/usage/get-account-billable-metrics.ts b/packages/cli/src/commands/_generated/billing/usage/get-account-billable-metrics.ts index 9f4c243186..1c1ad694c4 100644 --- a/packages/cli/src/commands/_generated/billing/usage/get-account-billable-metrics.ts +++ b/packages/cli/src/commands/_generated/billing/usage/get-account-billable-metrics.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/billing/usage/get-account-billable-metrics.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get-account-billable-metrics command * @generated from apis/overlays/billing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,41 +16,40 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 billing usage get-account-billable-metrics\n\nLists billable metrics available to the account through contracts and subscriptions that overlap the requested period. Results are deduplicated and ordered. If no qualifying contract exists, the result is an empty array. When `from` and `to` are omitted, the period defaults to the start of the current month through today. The maximum date range is 31 days." - ) - .option("from", { - type: "string", - description: +const command = apiCommand({ + command: "get-account-billable-metrics", + describe: "List Account Billable Metrics (Version 2, Alpha, Restricted)", + usage: + "$0 billing usage get-account-billable-metrics\n\nLists billable metrics available to the account through contracts and subscriptions that overlap the requested period. Results are deduplicated and ordered. If no qualifying contract exists, the result is an empty array. When `from` and `to` are omitted, the period defaults to the start of the current month through today. The maximum date range is 31 days.", + flags: { + from: { + kind: "parsed", + brief: "Start date for the usage query (ISO 8601). Required if `to` is set. When omitted along with `to`, defaults to the start of the current month. Filters by charge period (when consumption happened), not billing period. The maximum date range is 31 days.", - }) - .option("to", { - type: "string", - description: + optional: true, + parse: String, + }, + to: { + kind: "parsed", + brief: "End date for the usage query (ISO 8601). Required if `from` is set. When omitted along with `from`, defaults to today. Filters by charge period (when consumption happened), not billing period. The maximum date range is 31 days.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "get-account-billable-metrics", - describe: "List Account Billable Metrics (Version 2, Alpha, Restricted)", - builder, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "billing usage get-account-billable-metrics", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -81,6 +79,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/billing/usage/get-account-usage-v2.ts b/packages/cli/src/commands/_generated/billing/usage/get-account-usage-v2.ts index 2479807cf7..eaf7397c59 100644 --- a/packages/cli/src/commands/_generated/billing/usage/get-account-usage-v2.ts +++ b/packages/cli/src/commands/_generated/billing/usage/get-account-usage-v2.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/billing/usage/get-account-usage-v2.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get-account-usage-v2 command * @generated from apis/overlays/billing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,41 +16,40 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 billing usage get-account-usage-v2\n\nReturns cost and usage data for a single Cloudflare account, aligned with the [FinOps FOCUS v1.3](https://focus.finops.org/focus-specification/v1-3/) Cost and Usage dataset specification. Each record represents one billable metric for one account on one day. This includes all metered usage, including usage that falls within free-tier allowances and may result in zero cost. **Note:** This endpoint serves `usage` records only; cost and pricing fields are absent from responses. To retrieve rated costs, use `POST` on the same path with `Metric: cost`. When `from` and `to` are omitted, defaults to the start of the current month through today. The maximum date range is 31 days." - ) - .option("from", { - type: "string", - description: +const command = apiCommand({ + command: "get-account-usage-v2", + describe: "Get Account Usage (Version 2, Alpha, Restricted)", + usage: + "$0 billing usage get-account-usage-v2\n\nReturns cost and usage data for a single Cloudflare account, aligned with the [FinOps FOCUS v1.3](https://focus.finops.org/focus-specification/v1-3/) Cost and Usage dataset specification. Each record represents one billable metric for one account on one day. This includes all metered usage, including usage that falls within free-tier allowances and may result in zero cost. **Note:** This endpoint serves `usage` records only; cost and pricing fields are absent from responses. To retrieve rated costs, use `POST` on the same path with `Metric: cost`. When `from` and `to` are omitted, defaults to the start of the current month through today. The maximum date range is 31 days.", + flags: { + from: { + kind: "parsed", + brief: "Start date for the usage query (ISO 8601). Required if `to` is set. When omitted along with `to`, defaults to the start of the current month. Filters by charge period (when consumption happened), not billing period. The maximum date range is 31 days.", - }) - .option("to", { - type: "string", - description: + optional: true, + parse: String, + }, + to: { + kind: "parsed", + brief: "End date for the usage query (ISO 8601). Required if `from` is set. When omitted along with `from`, defaults to today. Filters by charge period (when consumption happened), not billing period. The maximum date range is 31 days.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "get-account-usage-v2", - describe: "Get Account Usage (Version 2, Alpha, Restricted)", - builder, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "billing usage get-account-usage-v2", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -81,6 +79,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/billing/usage/get-info-v1.ts b/packages/cli/src/commands/_generated/billing/usage/get-info-v1.ts index 70664cbc65..a49fa90cc7 100644 --- a/packages/cli/src/commands/_generated/billing/usage/get-info-v1.ts +++ b/packages/cli/src/commands/_generated/billing/usage/get-info-v1.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/billing/usage/get-info-v1.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get-info-v1 command * @generated from apis/overlays/billing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 billing usage get-info-v1\n\nReturns high-level usage information for the account, including coverage, and subscription metadata." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get-info-v1", describe: "Get Account Billable Usage Info (Version 1, Alpha)", - builder, + usage: + "$0 billing usage get-info-v1\n\nReturns high-level usage information for the account, including coverage, and subscription metadata.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "billing usage get-info-v1", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/billing/usage/get-v1.ts b/packages/cli/src/commands/_generated/billing/usage/get-v1.ts index f7e90d0fb2..bcc4d10a1f 100644 --- a/packages/cli/src/commands/_generated/billing/usage/get-v1.ts +++ b/packages/cli/src/commands/_generated/billing/usage/get-v1.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/billing/usage/get-v1.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get-v1 command * @generated from apis/overlays/billing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,40 +16,39 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 billing usage get-v1\n\nReturns billable usage data for the account. When no query parameters are provided, returns usage for the current billing period." - ) - .option("from", { - type: "string", - description: - "Start date for the usage query (ISO 8601). The provided time range must include the subscription billing cycle anchor day, otherwise no usage data is returned. Use the info endpoint to retrieve the subscription anchor day.", - }) - .option("to", { - type: "string", - description: "End date for the usage query (ISO 8601).", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get-v1", describe: "Get Account Billable Usage (Version 1, Alpha)", - builder, + usage: + "$0 billing usage get-v1\n\nReturns billable usage data for the account. When no query parameters are provided, returns usage for the current billing period.", + flags: { + from: { + kind: "parsed", + brief: + "Start date for the usage query (ISO 8601). The provided time range must include the subscription billing cycle anchor day, otherwise no usage data is returned. Use the info endpoint to retrieve the subscription anchor day.", + optional: true, + parse: String, + }, + to: { + kind: "parsed", + brief: "End date for the usage query (ISO 8601).", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "billing usage get-v1", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -80,6 +78,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/billing/usage/index.ts b/packages/cli/src/commands/_generated/billing/usage/index.ts index c8b568c96f..2bdac0d2a1 100644 --- a/packages/cli/src/commands/_generated/billing/usage/index.ts +++ b/packages/cli/src/commands/_generated/billing/usage/index.ts @@ -3,29 +3,24 @@ import $getaccountusagev2 from "./get-account-usage-v2.js"; import $getinfov1 from "./get-info-v1.js"; import $getv1 from "./get-v1.js"; import $query from "./query.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * usage command group * @generated from apis/overlays/billing.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "usage", describe: "Metered usage data for billed services — requests, bandwidth, and feature consumption", - builder: (yargs) => { - return yargs - .command($getaccountbillablemetrics) - .command($getaccountusagev2) - .command($getinfov1) - .command($getv1) - .command($query) - .demandCommand(1, "Please specify a subcommand"); + routes: { + "get-account-billable-metrics": $getaccountbillablemetrics, + "get-account-usage-v2": $getaccountusagev2, + "get-info-v1": $getinfov1, + "get-v1": $getv1, + query: $query, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/billing/usage/query.ts b/packages/cli/src/commands/_generated/billing/usage/query.ts index 3303a6631d..80a9c135f4 100644 --- a/packages/cli/src/commands/_generated/billing/usage/query.ts +++ b/packages/cli/src/commands/_generated/billing/usage/query.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/billing/usage/query.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * query command * @generated from apis/overlays/billing.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,84 +18,94 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 billing usage query\n\nReturns cost and usage data for a single Cloudflare account, aligned with the [FinOps FOCUS v1.3](https://focus.finops.org/focus-specification/v1-3/) Cost and Usage dataset specification. This is the filterable counterpart to `GET` on the same path. It is a read-only operation and requires only the `#billing:read` permission; `POST` is used so that filter criteria can be supplied in a request body rather than in the query string. Each record represents one billable metric for one account on one day. This includes all metered usage, including usage that falls within free-tier allowances and may result in zero cost. **Note:** Cost and pricing fields are populated only when `Metric` is `cost`; otherwise they are absent from responses. The request body is optional. When it is omitted, or when `TimePeriod` is omitted, the range defaults to the start of the current month through today. The maximum date range is 31 days. Filters of different kinds are combined with AND. Values within one tag filter are combined with OR. Filter values that do not match usage produce an empty result set. Results can be grouped by up to two groups, in any combination of dimension keys and resource-tag keys. Tag groups are returned in the `Tags` field. Usage without a requested tag remains in an untagged group, with that key omitted from `Tags`. Requests that use tag filtering or tag grouping return HTTP 400 when the underlying usage data source does not support tags. Requests that use dimension grouping return HTTP 400 when the underlying usage data source does not support dimensions. `Granularity` is optional. When it is omitted, the response is as described above. With `DAILY`, each record covers one day. With `PERIOD`, each record covers the whole time period: `ChargePeriodStart` is the first day of the period and `ChargePeriodEnd` is the day after its last day. For `usage`, `ConsumedQuantity` is the sum of the daily quantities in the bucket. When `Granularity` is set and `Metric` is `cost`, each record is one billable metric for one bucket. `PricingQuantity` and `BilledCost` are summed across pricing tiers, so unit prices and the list and contracted costs derived from them are absent. Only cost held in US dollars is summed, so a total can be lower than the sum of the `cost` records returned without `Granularity` for the same range when that range also holds cost in another credit type. Requests for `usage` that use `PERIOD` granularity return HTTP 400 when the underlying usage data source does not support it." - ) - .option("filter-by-billable-metric-ids", { - type: "string", - array: true, - description: +const command = apiCommand({ + command: "query", + describe: "Query Account Usage (Version 2, Alpha, Restricted)", + usage: + "$0 billing usage query\n\nReturns cost and usage data for a single Cloudflare account, aligned with the [FinOps FOCUS v1.3](https://focus.finops.org/focus-specification/v1-3/) Cost and Usage dataset specification. This is the filterable counterpart to `GET` on the same path. It is a read-only operation and requires only the `#billing:read` permission; `POST` is used so that filter criteria can be supplied in a request body rather than in the query string. Each record represents one billable metric for one account on one day. This includes all metered usage, including usage that falls within free-tier allowances and may result in zero cost. **Note:** Cost and pricing fields are populated only when `Metric` is `cost`; otherwise they are absent from responses. The request body is optional. When it is omitted, or when `TimePeriod` is omitted, the range defaults to the start of the current month through today. The maximum date range is 31 days. Filters of different kinds are combined with AND. Values within one tag filter are combined with OR. Filter values that do not match usage produce an empty result set. Results can be grouped by up to two groups, in any combination of dimension keys and resource-tag keys. Tag groups are returned in the `Tags` field. Usage without a requested tag remains in an untagged group, with that key omitted from `Tags`. Requests that use tag filtering or tag grouping return HTTP 400 when the underlying usage data source does not support tags. Requests that use dimension grouping return HTTP 400 when the underlying usage data source does not support dimensions. `Granularity` is optional. When it is omitted, the response is as described above. With `DAILY`, each record covers one day. With `PERIOD`, each record covers the whole time period: `ChargePeriodStart` is the first day of the period and `ChargePeriodEnd` is the day after its last day. For `usage`, `ConsumedQuantity` is the sum of the daily quantities in the bucket. When `Granularity` is set and `Metric` is `cost`, each record is one billable metric for one bucket. `PricingQuantity` and `BilledCost` are summed across pricing tiers, so unit prices and the list and contracted costs derived from them are absent. Only cost held in US dollars is summed, so a total can be lower than the sum of the `cost` records returned without `Granularity` for the same range when that range also holds cost in another credit type. Requests for `usage` that use `PERIOD` granularity return HTTP 400 when the underlying usage data source does not support it.", + flags: { + "filter-by-billable-metric-ids": { + kind: "parsed", + brief: "Restrict results to rows whose `x_BillableMetricId` matches one of these billable metric ids (e.g. `workers_standard_requests`). Values must be unique. Cost billed under an archived billable metric carries that metric's catalog public id as `x_BillableMetricId` and is never matched by this filter; omit the filter to include it.", - }) - .option("filter-by-product-family-ids", { - type: "string", - array: true, - description: + variadic: true, + optional: true, + parse: String, + }, + "filter-by-product-family-ids": { + kind: "parsed", + brief: "Restrict results to billable metrics belonging to these product families. Values must be unique UUIDs.", - }) - .option("filter-by-tags", { - type: "string", - description: + variadic: true, + optional: true, + parse: String, + }, + "filter-by-tags": { + kind: "parsed", + brief: 'Restrict results by resource tags. Filters for different keys are combined with AND, while values within one filter are combined with OR. Keys must be unique and are case-sensitive. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"Key": string, "Values": [string]}].', - }) - .option("granularity", { - type: "string", - description: + optional: true, + parse: String, + }, + granularity: { + kind: "parsed", + brief: "Optional time bucket to sum records over. `DAILY` returns one record per day. `PERIOD` returns one record for the whole time period. When set with `Metric` `cost`, cost is summed across pricing tiers into one record per billable metric per bucket. When omitted, records are not summed: `usage` returns daily records and `cost` returns one record per rated breakdown. Available only on `POST` account usage.", + optional: true, choices: ["DAILY", "PERIOD"], - }) - .coerce("granularity", (value) => - resolveFileToken(value, "granularity", "text") - ) - .option("group-by", { - type: "string", - description: + parse: String, + coerce: (value: string) => resolveFileToken(value, "granularity", "text"), + }, + "group-by": { + kind: "parsed", + brief: 'Grouping definitions used to split result rows. At most two unique keys may be supplied. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"Key": string, "Type": "TAG" | "DIMENSION"}].', - }) - .option("metric", { - type: "string", - description: + optional: true, + parse: String, + }, + metric: { + kind: "parsed", + brief: "Type of cost/usage records to retrieve. `usage` returns unrated usage quantities. `cost` returns rated usage with cost and pricing fields; it is available only on `POST` account usage and only when the underlying usage data source is ClickHouse (other sources return an empty result set). Requests that combine `cost` with `GroupBy` or `FilterBy.Tags` return HTTP 400. Unrelated to `FilterBy.BillableMetricIds`. Defaults to `usage` when omitted.", - choices: ["usage", "cost"], default: "usage", - }) - .coerce("metric", (value) => resolveFileToken(value, "metric", "text")) - .option("time-period-from", { - type: "string", - description: "Start of the range (ISO 8601). Required if `To` is set.", - }) - .option("time-period-to", { - type: "string", - description: + choices: ["usage", "cost"], + parse: String, + coerce: (value: string) => resolveFileToken(value, "metric", "text"), + }, + "time-period-from": { + kind: "parsed", + brief: "Start of the range (ISO 8601). Required if `To` is set.", + optional: true, + parse: String, + }, + "time-period-to": { + kind: "parsed", + brief: "End of the range (ISO 8601). Required if `From` is set. Must be after `From` and no more than 31 days after it.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: + }, + body: { + kind: "parsed", + brief: "Filter criteria for a usage query. Every field is optional; an empty object is equivalent to omitting the body entirely. Unknown fields are rejected.", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "query", - describe: "Query Account Usage (Version 2, Alpha, Restricted)", - builder, + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "billing usage query", classification: { safeFlags: ["granularity", "metric", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -183,6 +192,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/bot-management/feedback/create.ts b/packages/cli/src/commands/_generated/bot-management/feedback/create.ts index 265e589be6..ac62c26c82 100644 --- a/packages/cli/src/commands/_generated/bot-management/feedback/create.ts +++ b/packages/cli/src/commands/_generated/bot-management/feedback/create.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/bot-management/feedback/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/bot-management.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { compactBody, parseBody, parseJsonMap } from "#lib/body-parser.js"; import { formatDryRun } from "#lib/dry-run.js"; @@ -18,75 +17,97 @@ import { } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 bot-management feedback create\n\nSubmit a feedback report for the specified zone. Use `type` to indicate whether the report is a false positive (good traffic flagged as bot) or a false negative (bot traffic missed). Furthermore, you can also use `expression` as a wirefilter to identify the affected traffic sample. See more accepted API fields and expression types at https://developers.cloudflare.com/bots/concepts/feedback-loop/#api-fields and https://developers.cloudflare.com/bots/concepts/feedback-loop/#expression-fields, respectively." - ) - .option("description", { - type: "string", - description: "The description field", - }) - .option("expression", { - type: "string", - description: - "Wirefilter expression describing the traffic being reported.", - }) - .option("first-request-seen-at", { - type: "string", - description: "The first_request_seen_at field", - }) - .option("last-request-seen-at", { - type: "string", - description: "The last_request_seen_at field", - }) - .option("requests", { type: "number", description: "The requests field" }) - .option("requests-by-attribute", { - type: "string", - description: +const command = apiCommand({ + command: "create", + describe: "Submit a feedback report", + usage: + "$0 bot-management feedback create\n\nSubmit a feedback report for the specified zone. Use `type` to indicate whether the report is a false positive (good traffic flagged as bot) or a false negative (bot traffic missed). Furthermore, you can also use `expression` as a wirefilter to identify the affected traffic sample. See more accepted API fields and expression types at https://developers.cloudflare.com/bots/concepts/feedback-loop/#api-fields and https://developers.cloudflare.com/bots/concepts/feedback-loop/#expression-fields, respectively.", + flags: { + description: { + kind: "parsed", + brief: "The description field", + optional: true, + parse: String, + }, + expression: { + kind: "parsed", + brief: "Wirefilter expression describing the traffic being reported.", + optional: true, + parse: String, + }, + "first-request-seen-at": { + kind: "parsed", + brief: "The first_request_seen_at field", + optional: true, + parse: String, + }, + "last-request-seen-at": { + kind: "parsed", + brief: "The last_request_seen_at field", + optional: true, + parse: String, + }, + requests: { + kind: "parsed", + brief: "The requests field", + optional: true, + parse: Number, + }, + "requests-by-attribute": { + kind: "parsed", + brief: 'Top attributes contributing to the feedback sample. Keys include topASNs, topCountries, topHosts, topIPs, topJA3Hashes, topJA4s, topPaths, topUserAgents. Provide as a JSON object or @path/to/file.json. Shape: {"": [{...}]}.', - }) - .option("requests-by-score", { - type: "string", - description: + optional: true, + parse: String, + }, + "requests-by-score": { + kind: "parsed", + brief: 'Map of bot scores (1-99) to request counts. Sum must equal `requests`. Provide as a JSON object or @path/to/file.json. Shape: {"": number}.', - }) - .option("requests-by-score-src", { - type: "string", - description: + optional: true, + parse: String, + }, + "requests-by-score-src": { + kind: "parsed", + brief: 'Map of score source to request counts. Sum must equal `requests`. Provide as a JSON object or @path/to/file.json. Shape: {"": number}.', - }) - .option("subtype", { type: "string", description: "The subtype field" }) - .option("type", { - type: "string", - description: "Type of feedback report.", + optional: true, + parse: String, + }, + subtype: { + kind: "parsed", + brief: "The subtype field", + optional: true, + parse: String, + }, + type: { + kind: "parsed", + brief: "Type of feedback report.", + optional: true, choices: ["false_positive", "false_negative"], - }) - .coerce("type", (value) => resolveFileToken(value, "type", "text")) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + parse: String, + coerce: (value: string) => resolveFileToken(value, "type", "text"), + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "create", - describe: "Submit a feedback report", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "bot-management feedback create", classification: { safeFlags: ["type", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -310,6 +331,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/bot-management/feedback/index.ts b/packages/cli/src/commands/_generated/bot-management/feedback/index.ts index 79a70d65c0..940aed45e6 100644 --- a/packages/cli/src/commands/_generated/bot-management/feedback/index.ts +++ b/packages/cli/src/commands/_generated/bot-management/feedback/index.ts @@ -1,24 +1,19 @@ import $create from "./create.js"; import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * feedback command group * @generated from apis/overlays/bot-management.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "feedback", describe: "Operations for feedback", - builder: (yargs) => { - return yargs - .command($create) - .command($list) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/bot-management/feedback/list.ts b/packages/cli/src/commands/_generated/bot-management/feedback/list.ts index 74721ad19b..bfa586b367 100644 --- a/packages/cli/src/commands/_generated/bot-management/feedback/list.ts +++ b/packages/cli/src/commands/_generated/bot-management/feedback/list.ts @@ -1,42 +1,36 @@ import operation from "../../_operations/bot-management/feedback/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/bot-management.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 bot-management feedback list\n\nReturns all feedback reports previously submitted for the specified zone. Feedback reports help improve detection by sharing samples of traffic that were misclassified as bots or humans." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List zone feedback reports", - builder, + usage: + "$0 bot-management feedback list\n\nReturns all feedback reports previously submitted for the specified zone. Feedback reports help improve detection by sharing samples of traffic that were misclassified as bots or humans.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "bot-management feedback list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -64,6 +58,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/bot-management/get.ts b/packages/cli/src/commands/_generated/bot-management/get.ts index 0b1445de8f..fc9de0d854 100644 --- a/packages/cli/src/commands/_generated/bot-management/get.ts +++ b/packages/cli/src/commands/_generated/bot-management/get.ts @@ -1,40 +1,35 @@ import operation from "../_operations/bot-management/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/bot-management.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { formatDryRun } from "#lib/dry-run.js"; import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage("$0 bot-management get\n\nRetrieve a zone's Bot Management Config") - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get", describe: "Get Zone Bot Management Config", - builder, + usage: "$0 bot-management get\n\nRetrieve a zone's Bot Management Config", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "bot-management get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -62,6 +57,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/bot-management/index.ts b/packages/cli/src/commands/_generated/bot-management/index.ts index 7c909b1bc4..f3c42785ee 100644 --- a/packages/cli/src/commands/_generated/bot-management/index.ts +++ b/packages/cli/src/commands/_generated/bot-management/index.ts @@ -1,26 +1,21 @@ import $feedback from "./feedback/index.js"; import $get from "./get.js"; import $update from "./update.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * bot-management command * @generated from apis/overlays/bot-management.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "bot-management", describe: "bot-management", - builder: (yargs) => { - return yargs - .command($get) - .command($update) - .command($feedback) - .demandCommand(1, "Please specify a subcommand"); + routes: { + get: $get, + update: $update, + feedback: $feedback, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/bot-management/update.ts b/packages/cli/src/commands/_generated/bot-management/update.ts index 28ccc8ea81..dc6882623c 100644 --- a/packages/cli/src/commands/_generated/bot-management/update.ts +++ b/packages/cli/src/commands/_generated/bot-management/update.ts @@ -1,11 +1,10 @@ import operation from "../_operations/bot-management/update.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * update command * @generated from apis/overlays/bot-management.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getZoneId } from "#lib/auth.js"; import { compactBody, parseBody } from "#lib/body-parser.js"; import { formatDryRun } from "#lib/dry-run.js"; @@ -14,241 +13,270 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - '$0 bot-management update\n\nUpdates the Bot Management configuration for a zone. This API is used to update: - **Bot Fight Mode** - **Super Bot Fight Mode** - **Bot Management for Enterprise** See [Bot Plans](https://developers.cloudflare.com/bots/plans/) for more information on the different plans \\ If you recently upgraded or downgraded your plan, refer to the following examples to clean up old configurations. Copy and paste the example body to remove old zone configurations based on your current plan. #### Clean up configuration for Bot Fight Mode plan ```json { "sbfm_likely_automated": "allow", "sbfm_definitely_automated": "allow", "sbfm_verified_bots": "allow", "sbfm_static_resource_protection": false, "optimize_wordpress": false, "suppress_session_score": false } ``` #### Clean up configuration for SBFM Pro plan ```json { "sbfm_likely_automated": "allow", "fight_mode": false } ``` #### Clean up configuration for SBFM Biz plan ```json { "fight_mode": false } ``` #### Clean up configuration for BM Enterprise Subscription plan It is strongly recommended that you ensure you have [custom rules](https://developers.cloudflare.com/waf/custom-rules/) in place to protect your zone before disabling the SBFM rules. Without these protections, your zone is vulnerable to attacks. ```json { "sbfm_likely_automated": "allow", "sbfm_definitely_automated": "allow", "sbfm_verified_bots": "allow", "sbfm_static_resource_protection": false, "optimize_wordpress": false, "fight_mode": false } ```' - ) - .option("ai-agents-anthropic-agent", { - type: "string", - description: "Action to apply to one supported personal AI agent.", +const command = apiCommand({ + command: "update", + describe: "Update Zone Bot Management Config", + usage: + '$0 bot-management update\n\nUpdates the Bot Management configuration for a zone. This API is used to update: - **Bot Fight Mode** - **Super Bot Fight Mode** - **Bot Management for Enterprise** See [Bot Plans](https://developers.cloudflare.com/bots/plans/) for more information on the different plans \\ If you recently upgraded or downgraded your plan, refer to the following examples to clean up old configurations. Copy and paste the example body to remove old zone configurations based on your current plan. #### Clean up configuration for Bot Fight Mode plan ```json { "sbfm_likely_automated": "allow", "sbfm_definitely_automated": "allow", "sbfm_verified_bots": "allow", "sbfm_static_resource_protection": false, "optimize_wordpress": false, "suppress_session_score": false } ``` #### Clean up configuration for SBFM Pro plan ```json { "sbfm_likely_automated": "allow", "fight_mode": false } ``` #### Clean up configuration for SBFM Biz plan ```json { "fight_mode": false } ``` #### Clean up configuration for BM Enterprise Subscription plan It is strongly recommended that you ensure you have [custom rules](https://developers.cloudflare.com/waf/custom-rules/) in place to protect your zone before disabling the SBFM rules. Without these protections, your zone is vulnerable to attacks. ```json { "sbfm_likely_automated": "allow", "sbfm_definitely_automated": "allow", "sbfm_verified_bots": "allow", "sbfm_static_resource_protection": false, "optimize_wordpress": false, "fight_mode": false } ```', + flags: { + "ai-agents-anthropic-agent": { + kind: "parsed", + brief: "Action to apply to one supported personal AI agent.", + optional: true, choices: ["disabled", "block", "only_on_ad_pages"], - }) - .coerce("ai-agents-anthropic-agent", (value) => - resolveFileToken(value, "ai-agents-anthropic-agent", "text") - ) - .option("ai-agents-google-agent", { - type: "string", - description: "Action to apply to one supported personal AI agent.", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "ai-agents-anthropic-agent", "text"), + }, + "ai-agents-google-agent": { + kind: "parsed", + brief: "Action to apply to one supported personal AI agent.", + optional: true, choices: ["disabled", "block", "only_on_ad_pages"], - }) - .coerce("ai-agents-google-agent", (value) => - resolveFileToken(value, "ai-agents-google-agent", "text") - ) - .option("ai-agents-instinct", { - type: "string", - description: "Action to apply to one supported personal AI agent.", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "ai-agents-google-agent", "text"), + }, + "ai-agents-instinct": { + kind: "parsed", + brief: "Action to apply to one supported personal AI agent.", + optional: true, choices: ["disabled", "block", "only_on_ad_pages"], - }) - .coerce("ai-agents-instinct", (value) => - resolveFileToken(value, "ai-agents-instinct", "text") - ) - .option("ai-agents-muse", { - type: "string", - description: "Action to apply to one supported personal AI agent.", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "ai-agents-instinct", "text"), + }, + "ai-agents-muse": { + kind: "parsed", + brief: "Action to apply to one supported personal AI agent.", + optional: true, choices: ["disabled", "block", "only_on_ad_pages"], - }) - .coerce("ai-agents-muse", (value) => - resolveFileToken(value, "ai-agents-muse", "text") - ) - .option("ai-agents-openai-agent", { - type: "string", - description: "Action to apply to one supported personal AI agent.", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "ai-agents-muse", "text"), + }, + "ai-agents-openai-agent": { + kind: "parsed", + brief: "Action to apply to one supported personal AI agent.", + optional: true, choices: ["disabled", "block", "only_on_ad_pages"], - }) - .coerce("ai-agents-openai-agent", (value) => - resolveFileToken(value, "ai-agents-openai-agent", "text") - ) - .option("ai-bots-migration-opt-out", { - type: "boolean", - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "ai-agents-openai-agent", "text"), + }, + "ai-bots-migration-opt-out": { + kind: "boolean", + brief: "Temporary migration flag tracking zones opted out of AI bots managed-rule updates.", - }) - .option("ai-bots-protection", { - type: "string", - description: "Enable rule to block AI Scrapers and Crawlers.", + optional: true, + }, + "ai-bots-protection": { + kind: "parsed", + brief: "Enable rule to block AI Scrapers and Crawlers.", + optional: true, choices: ["block", "disabled", "only_on_ad_pages"], - }) - .coerce("ai-bots-protection", (value) => - resolveFileToken(value, "ai-bots-protection", "text") - ) - .option("ai-search", { - type: "string", - description: "Configure robots.txt policy for AI search bots.", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "ai-bots-protection", "text"), + }, + "ai-search": { + kind: "parsed", + brief: "Configure robots.txt policy for AI search bots.", + optional: true, choices: ["disabled", "block", "only_on_ad_pages"], - }) - .coerce("ai-search", (value) => - resolveFileToken(value, "ai-search", "text") - ) - .option("ai-training", { - type: "string", - description: "Configure robots.txt policy for AI model training bots.", + parse: String, + coerce: (value: string) => resolveFileToken(value, "ai-search", "text"), + }, + "ai-training": { + kind: "parsed", + brief: "Configure robots.txt policy for AI model training bots.", + optional: true, choices: ["disabled", "disallow", "block", "only_on_ad_pages"], - }) - .coerce("ai-training", (value) => - resolveFileToken(value, "ai-training", "text") - ) - .option("ai-user", { - type: "string", - description: - "Configure robots.txt policy for AI assistant and agent bots.", + parse: String, + coerce: (value: string) => resolveFileToken(value, "ai-training", "text"), + }, + "ai-user": { + kind: "parsed", + brief: "Configure robots.txt policy for AI assistant and agent bots.", + optional: true, choices: ["disabled", "block", "only_on_ad_pages"], - }) - .coerce("ai-user", (value) => resolveFileToken(value, "ai-user", "text")) - .option("bot-preference-sync-enabled", { - type: "boolean", - description: + parse: String, + coerce: (value: string) => resolveFileToken(value, "ai-user", "text"), + }, + "bot-preference-sync-enabled": { + kind: "boolean", + brief: "Enable Bot Preference Sync for this zone. When enabled, Cloudflare can serve robots.txt content derived from the zone's AI Search, AI User, and AI Training preferences.", - }) - .option("cf-robots-variant", { - type: "string", - description: - "Specifies the Robots Access Control License variant to use.", + optional: true, + }, + "cf-robots-variant": { + kind: "parsed", + brief: "Specifies the Robots Access Control License variant to use.", + optional: true, choices: ["off", "policy_only"], - }) - .coerce("cf-robots-variant", (value) => - resolveFileToken(value, "cf-robots-variant", "text") - ) - .option("content-bots-protection", { - type: "string", - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "cf-robots-variant", "text"), + }, + "content-bots-protection": { + kind: "parsed", + brief: "Enable rule to block content bots. When enabled, blocks automated traffic with low bot scores, excluding safe verified bot categories. Exceptions should be managed via skip rules.", + optional: true, choices: ["block", "disabled"], - }) - .coerce("content-bots-protection", (value) => - resolveFileToken(value, "content-bots-protection", "text") - ) - .option("crawler-protection", { - type: "string", - description: - "Enable rule to punish AI Scrapers and Crawlers via a link maze.", + parse: String, + coerce: (value: string) => + resolveFileToken(value, "content-bots-protection", "text"), + }, + "crawler-protection": { + kind: "parsed", + brief: "Enable rule to punish AI Scrapers and Crawlers via a link maze.", + optional: true, choices: ["enabled", "disabled"], - }) - .coerce("crawler-protection", (value) => - resolveFileToken(value, "crawler-protection", "text") - ) - .option("enable-js", { - type: "boolean", - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "crawler-protection", "text"), + }, + "enable-js": { + kind: "boolean", + brief: "Use lightweight, invisible JavaScript detections to improve Bot Management. [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/).", - }) - .option("is-robots-txt-managed", { - type: "boolean", - description: + optional: true, + }, + "is-robots-txt-managed": { + kind: "boolean", + brief: "Enable cloudflare managed robots.txt. If an existing robots.txt is detected, then managed robots.txt will be prepended to the existing robots.txt.", - }) - .option("jsd-api-results-enabled", { - type: "boolean", - description: + optional: true, + }, + "jsd-api-results-enabled": { + kind: "boolean", + brief: "Whether to use JavaScript Detection results submitted through the API for this zone.", - }) - .option("fight-mode", { - type: "boolean", - description: "Whether to enable Bot Fight Mode.", - }) - .option("stale-zone-configuration-optimize-wordpress", { - type: "boolean", - description: + optional: true, + }, + "fight-mode": { + kind: "boolean", + brief: "Whether to enable Bot Fight Mode.", + optional: true, + }, + "stale-zone-configuration-optimize-wordpress": { + kind: "boolean", + brief: "Indicates that the zone's wordpress optimization for SBFM is turned on.", - }) - .option("stale-zone-configuration-sbfm-definitely-automated", { - type: "string", - description: + optional: true, + }, + "stale-zone-configuration-sbfm-definitely-automated": { + kind: "parsed", + brief: "Indicates that the zone's definitely automated requests are being blocked or challenged.", - }) - .option("stale-zone-configuration-sbfm-likely-automated", { - type: "string", - description: + optional: true, + parse: String, + }, + "stale-zone-configuration-sbfm-likely-automated": { + kind: "parsed", + brief: "Indicates that the zone's likely automated requests are being blocked or challenged.", - }) - .option("stale-zone-configuration-sbfm-static-resource-protection", { - type: "string", - description: + optional: true, + parse: String, + }, + "stale-zone-configuration-sbfm-static-resource-protection": { + kind: "parsed", + brief: "Indicates that the zone's static resource protection is turned on.", - }) - .option("stale-zone-configuration-sbfm-verified-bots", { - type: "string", - description: + optional: true, + parse: String, + }, + "stale-zone-configuration-sbfm-verified-bots": { + kind: "parsed", + brief: "Indicates that the zone's verified bot requests are being blocked.", - }) - .option("stale-zone-configuration-suppress-session-score", { - type: "boolean", - description: - "Indicates that the zone's session score tracking is disabled.", - }) - .option("stale-zone-configuration-fight-mode", { - type: "boolean", - description: "Indicates that the zone's Bot Fight Mode is turned on.", - }) - .option("optimize-wordpress", { - type: "boolean", - description: + optional: true, + parse: String, + }, + "stale-zone-configuration-suppress-session-score": { + kind: "boolean", + brief: "Indicates that the zone's session score tracking is disabled.", + optional: true, + }, + "stale-zone-configuration-fight-mode": { + kind: "boolean", + brief: "Indicates that the zone's Bot Fight Mode is turned on.", + optional: true, + }, + "optimize-wordpress": { + kind: "boolean", + brief: "Whether to optimize Super Bot Fight Mode protections for Wordpress.", - }) - .option("sbfm-definitely-automated", { - type: "string", - description: + optional: true, + }, + "sbfm-definitely-automated": { + kind: "parsed", + brief: "Super Bot Fight Mode (SBFM) action to take on definitely automated requests.", + optional: true, choices: ["allow", "block", "managed_challenge"], - }) - .coerce("sbfm-definitely-automated", (value) => - resolveFileToken(value, "sbfm-definitely-automated", "text") - ) - .option("sbfm-static-resource-protection", { - type: "boolean", - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "sbfm-definitely-automated", "text"), + }, + "sbfm-static-resource-protection": { + kind: "boolean", + brief: "Super Bot Fight Mode (SBFM) to enable static resource protection.\nEnable if static resources on your application need bot protection.\nNote: Static resource protection can also result in legitimate traffic being blocked.", - }) - .option("sbfm-verified-bots", { - type: "string", - description: + optional: true, + }, + "sbfm-verified-bots": { + kind: "parsed", + brief: "Super Bot Fight Mode (SBFM) action to take on verified bots requests.", + optional: true, choices: ["allow", "block"], - }) - .coerce("sbfm-verified-bots", (value) => - resolveFileToken(value, "sbfm-verified-bots", "text") - ) - .option("sbfm-likely-automated", { - type: "string", - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "sbfm-verified-bots", "text"), + }, + "sbfm-likely-automated": { + kind: "parsed", + brief: "Super Bot Fight Mode (SBFM) action to take on likely automated requests.", + optional: true, choices: ["allow", "block", "managed_challenge"], - }) - .coerce("sbfm-likely-automated", (value) => - resolveFileToken(value, "sbfm-likely-automated", "text") - ) - .option("auto-update-model", { - type: "boolean", - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "sbfm-likely-automated", "text"), + }, + "auto-update-model": { + kind: "boolean", + brief: "Automatically update to the newest bot detection models created by Cloudflare as they are released. [Learn more.](https://developers.cloudflare.com/bots/reference/machine-learning-models#model-versions-and-release-notes)", - }) - .option("bm-cookie-enabled", { - type: "boolean", - description: + optional: true, + }, + "bm-cookie-enabled": { + kind: "boolean", + brief: "Indicates that the bot management cookie can be placed on end user devices accessing the site. Defaults to true", - }) - .option("suppress-session-score", { - type: "boolean", - description: + optional: true, + }, + "suppress-session-score": { + kind: "boolean", + brief: "Whether to disable tracking the highest bot score for a session in the Bot Management cookie.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "update", - describe: "Update Zone Bot Management Config", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { @@ -286,7 +314,7 @@ const command: CommandModule = { "suppress-session-score", "dry-run", ], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -464,6 +492,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/botnet-feed/asn/day-report.ts b/packages/cli/src/commands/_generated/botnet-feed/asn/day-report.ts index 97ea1f5b45..6568cf8aee 100644 --- a/packages/cli/src/commands/_generated/botnet-feed/asn/day-report.ts +++ b/packages/cli/src/commands/_generated/botnet-feed/asn/day-report.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/botnet-feed/asn/day-report.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * day-report command * @generated from apis/overlays/botnet-feed.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,37 +16,27 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 botnet-feed asn day-report \n\nGets all the data the botnet tracking database has for a given ASN registered to user account for given date. If no date is given, it will return results for the previous day." - ) - .positional("asn-id", { - type: "string", - description: "Asn ID", - demandOption: true, - }) - .option("date", { type: "string", description: "Date" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "day-report ", describe: "Get daily report", - builder, + usage: + "$0 botnet-feed asn day-report \n\nGets all the data the botnet tracking database has for a given ASN registered to user account for given date. If no date is given, it will return results for the previous day.", + flags: { + date: { kind: "parsed", brief: "Date", optional: true, parse: String }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [{ placeholder: "asn-id", brief: "Asn ID", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "botnet-feed asn day-report", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -80,6 +69,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/botnet-feed/asn/full-report.ts b/packages/cli/src/commands/_generated/botnet-feed/asn/full-report.ts index d689e23d57..e6c8a4731f 100644 --- a/packages/cli/src/commands/_generated/botnet-feed/asn/full-report.ts +++ b/packages/cli/src/commands/_generated/botnet-feed/asn/full-report.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/botnet-feed/asn/full-report.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * full-report command * @generated from apis/overlays/botnet-feed.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 botnet-feed asn full-report \n\nGets all the data the botnet threat feed tracking database has for a given ASN registered to user account." - ) - .positional("asn-id", { - type: "string", - description: "Asn ID", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "full-report ", describe: "Get full report", - builder, + usage: + "$0 botnet-feed asn full-report \n\nGets all the data the botnet threat feed tracking database has for a given ASN registered to user account.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [{ placeholder: "asn-id", brief: "Asn ID", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "botnet-feed asn full-report", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -74,6 +63,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/botnet-feed/asn/index.ts b/packages/cli/src/commands/_generated/botnet-feed/asn/index.ts index bcabff34ef..3b62dbe1c2 100644 --- a/packages/cli/src/commands/_generated/botnet-feed/asn/index.ts +++ b/packages/cli/src/commands/_generated/botnet-feed/asn/index.ts @@ -1,25 +1,20 @@ import $dayreport from "./day-report.js"; import $fullreport from "./full-report.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * asn command group * @generated from apis/overlays/botnet-feed.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "asn", describe: "ASN-level botnet activity data showing networks with known C2 infrastructure", - builder: (yargs) => { - return yargs - .command($dayreport) - .command($fullreport) - .demandCommand(1, "Please specify a subcommand"); + routes: { + "day-report": $dayreport, + "full-report": $fullreport, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/botnet-feed/configs/asn/delete.ts b/packages/cli/src/commands/_generated/botnet-feed/configs/asn/delete.ts index beccebea12..8ad3d42b98 100644 --- a/packages/cli/src/commands/_generated/botnet-feed/configs/asn/delete.ts +++ b/packages/cli/src/commands/_generated/botnet-feed/configs/asn/delete.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/botnet-feed/configs/asn/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/botnet-feed.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,35 +17,25 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 botnet-feed configs asn delete \n\nDelete an ASN from botnet threat feed for a given user." - ) - .positional("asn-id", { - type: "string", - description: "Asn ID", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete an ASN", + usage: + "$0 botnet-feed configs asn delete \n\nDelete an ASN from botnet threat feed for a given user.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete an ASN", - builder, + }, + }, + operands: [{ placeholder: "asn-id", brief: "Asn ID", parse: String }], handler: async (argv): Promise => runWithTelemetry( { @@ -54,7 +43,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -86,6 +75,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/botnet-feed/configs/asn/get.ts b/packages/cli/src/commands/_generated/botnet-feed/configs/asn/get.ts index 1d81842e3f..bb5d013007 100644 --- a/packages/cli/src/commands/_generated/botnet-feed/configs/asn/get.ts +++ b/packages/cli/src/commands/_generated/botnet-feed/configs/asn/get.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/botnet-feed/configs/asn/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/botnet-feed.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 botnet-feed configs asn get\n\nGets a list of all ASNs registered for a user for the DDoS Botnet Feed API." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get", describe: "Get list of ASNs", - builder, + usage: + "$0 botnet-feed configs asn get\n\nGets a list of all ASNs registered for a user for the DDoS Botnet Feed API.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "botnet-feed configs asn get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/botnet-feed/configs/asn/index.ts b/packages/cli/src/commands/_generated/botnet-feed/configs/asn/index.ts index eb2310df9a..8ee4cfad74 100644 --- a/packages/cli/src/commands/_generated/botnet-feed/configs/asn/index.ts +++ b/packages/cli/src/commands/_generated/botnet-feed/configs/asn/index.ts @@ -1,24 +1,19 @@ import $delete from "./delete.js"; import $get from "./get.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * asn command group * @generated from apis/overlays/botnet-feed.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "asn", describe: "Operations for configs.asn", - builder: (yargs) => { - return yargs - .command($delete) - .command($get) - .demandCommand(1, "Please specify a subcommand"); + routes: { + delete: $delete, + get: $get, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/botnet-feed/configs/index.ts b/packages/cli/src/commands/_generated/botnet-feed/configs/index.ts index 0e8bc2335e..c9b007dfec 100644 --- a/packages/cli/src/commands/_generated/botnet-feed/configs/index.ts +++ b/packages/cli/src/commands/_generated/botnet-feed/configs/index.ts @@ -1,21 +1,18 @@ import $asn from "./asn/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * configs command group * @generated from apis/overlays/botnet-feed.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "configs", describe: "Botnet feed subscription configuration and notification preferences", - builder: (yargs) => { - return yargs.command($asn).demandCommand(1, "Please specify a subcommand"); + routes: { + asn: $asn, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/botnet-feed/index.ts b/packages/cli/src/commands/_generated/botnet-feed/index.ts index 5d827db809..d158465cbe 100644 --- a/packages/cli/src/commands/_generated/botnet-feed/index.ts +++ b/packages/cli/src/commands/_generated/botnet-feed/index.ts @@ -1,25 +1,20 @@ import $asn from "./asn/index.js"; import $configs from "./configs/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * botnet-feed command * @generated from apis/overlays/botnet-feed.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "botnet-feed", describe: "Botnet threat intelligence feeds — IP and ASN-level data on known command-and-control infrastructure", - builder: (yargs) => { - return yargs - .command($asn) - .command($configs) - .demandCommand(1, "Please specify a subcommand"); + routes: { + asn: $asn, + configs: $configs, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/brand-protection/index.ts b/packages/cli/src/commands/_generated/brand-protection/index.ts index aca9575953..fcb506bb77 100644 --- a/packages/cli/src/commands/_generated/brand-protection/index.ts +++ b/packages/cli/src/commands/_generated/brand-protection/index.ts @@ -6,31 +6,26 @@ import $submit from "./submit.js"; import $trial from "./trial/index.js"; import $urlinfo from "./url-info.js"; import $urls from "./urls/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * brand-protection command * @generated from apis/overlays/brand-protection.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "brand-protection", describe: "brand-protection", - builder: (yargs) => { - return yargs - .command($submit) - .command($urlinfo) - .command($logomatches) - .command($logos) - .command($matches) - .command($queries) - .command($trial) - .command($urls) - .demandCommand(1, "Please specify a subcommand"); + routes: { + submit: $submit, + "url-info": $urlinfo, + "logo-matches": $logomatches, + logos: $logos, + matches: $matches, + queries: $queries, + trial: $trial, + urls: $urls, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/brand-protection/logo-matches/get.ts b/packages/cli/src/commands/_generated/brand-protection/logo-matches/get.ts index ae1bc84e6c..da0e1a82ea 100644 --- a/packages/cli/src/commands/_generated/brand-protection/logo-matches/get.ts +++ b/packages/cli/src/commands/_generated/brand-protection/logo-matches/get.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/brand-protection/logo-matches/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/brand-protection.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,60 +16,63 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 brand-protection logo-matches get\n\nLists images that matched a saved logo query, most recently matched first by default. Set `download=true` to include each matched image as base64 data." - ) - .option("offset", { - type: "string", - description: "Number of matches to skip, for pagination. Defaults to 0.", - }) - .option("limit", { - type: "string", - description: "Maximum number of matches to return. Defaults to 50.", - }) - .option("query-id", { - type: "string", - description: "ID of the logo query whose matches to list.", - demandOption: true, - }) - .option("download", { - type: "string", - description: +const command = apiCommand({ + command: "get", + describe: "List logo matches", + usage: + "$0 brand-protection logo-matches get\n\nLists images that matched a saved logo query, most recently matched first by default. Set `download=true` to include each matched image as base64 data.", + flags: { + offset: { + kind: "parsed", + brief: "Number of matches to skip, for pagination. Defaults to 0.", + optional: true, + parse: String, + }, + limit: { + kind: "parsed", + brief: "Maximum number of matches to return. Defaults to 50.", + optional: true, + parse: String, + }, + "query-id": { + kind: "parsed", + brief: "ID of the logo query whose matches to list.", + parse: String, + }, + download: { + kind: "parsed", + brief: "Set to `true` to include each matched image as base64 data in `image_data`, with its MIME type in `content_type`.", - }) - .option("order-by", { - type: "string", - description: + optional: true, + parse: String, + }, + "order-by": { + kind: "enum", + brief: "Field to sort by: `matchedAt`, `domain`, `similarityScore`, or `registrar`. Defaults to `matchedAt`.", - choices: ["matchedAt", "domain", "similarityScore", "registrar"], - }) - .option("order", { - type: "string", - description: "Sort direction: `asc` or `desc`. Defaults to `desc`.", - choices: ["asc", "desc"], - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + values: ["matchedAt", "domain", "similarityScore", "registrar"], + optional: true, + }, + order: { + kind: "enum", + brief: "Sort direction: `asc` or `desc`. Defaults to `desc`.", + values: ["asc", "desc"], + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "get", - describe: "List logo matches", - builder, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "brand-protection logo-matches get", classification: { safeFlags: ["order-by", "order", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -104,6 +106,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/brand-protection/logo-matches/index.ts b/packages/cli/src/commands/_generated/brand-protection/logo-matches/index.ts index 268fe51f88..4776323bc2 100644 --- a/packages/cli/src/commands/_generated/brand-protection/logo-matches/index.ts +++ b/packages/cli/src/commands/_generated/brand-protection/logo-matches/index.ts @@ -1,20 +1,17 @@ import $get from "./get.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * logo-matches command group * @generated from apis/overlays/brand-protection.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "logo-matches", describe: "Operations for logo-matches", - builder: (yargs) => { - return yargs.command($get).demandCommand(1, "Please specify a subcommand"); + routes: { + get: $get, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/brand-protection/logos/create.ts b/packages/cli/src/commands/_generated/brand-protection/logos/create.ts index dc012a392a..9397677c6f 100644 --- a/packages/cli/src/commands/_generated/brand-protection/logos/create.ts +++ b/packages/cli/src/commands/_generated/brand-protection/logos/create.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/brand-protection/logos/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/brand-protection.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,55 +19,58 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 brand-protection logos create\n\nUploads a logo and creates a saved logo query that finds visually similar images on scanned websites. The tag must be unique among the account's logo queries. By default, the new query also searches previously scanned images (see `search_lookback`). Creation fails when the account has reached its Brand Protection query limit, which counts domain and logo queries together." - ) - .option("image-data", { - type: "string", - description: +const command = apiCommand({ + command: "create", + describe: "Create logo query", + usage: + "$0 brand-protection logos create\n\nUploads a logo and creates a saved logo query that finds visually similar images on scanned websites. The tag must be unique among the account's logo queries. By default, the new query also searches previously scanned images (see `search_lookback`). Creation fails when the account has reached its Brand Protection query limit, which counts domain and logo queries together.", + flags: { + "image-data": { + kind: "parsed", + brief: "Base64 encoded image data. Can include data URI prefix (e.g., 'data:image/png;base64,...') or just the base64 string. Supported formats: PNG, JPEG, GIF, WebP, BMP, and SVG. ICO is also accepted when the data includes a `data:image/x-icon;base64,` prefix.", - }) - .option("search-lookback", { - type: "boolean", - description: + optional: true, + parse: String, + }, + "search-lookback": { + kind: "boolean", + brief: "If true, also search previously scanned images for matches above the similarity threshold. Defaults to `true`.", default: true, - }) - .option("similarity-threshold", { - type: "number", - description: "Minimum similarity score (0-1) required for visual matches", - }) - .option("tag", { - type: "string", - description: + }, + "similarity-threshold": { + kind: "parsed", + brief: "Minimum similarity score (0-1) required for visual matches", + optional: true, + parse: Number, + }, + tag: { + kind: "parsed", + brief: "Name of the logo query. Must be unique among the account's logo queries.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "create", - describe: "Create logo query", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "brand-protection logos create", classification: { safeFlags: ["search-lookback", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -159,6 +161,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/brand-protection/logos/delete.ts b/packages/cli/src/commands/_generated/brand-protection/logos/delete.ts index 50d2d45d31..04c75b6e93 100644 --- a/packages/cli/src/commands/_generated/brand-protection/logos/delete.ts +++ b/packages/cli/src/commands/_generated/brand-protection/logos/delete.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/brand-protection/logos/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/brand-protection.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,35 +17,27 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 brand-protection logos delete \n\nPermanently deletes a saved logo query and all of its matches. If the query does not exist in this account, the request fails with error code 404." - ) - .positional("query-id", { - type: "string", - description: "ID of the logo query.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Delete logo query", + usage: + "$0 brand-protection logos delete \n\nPermanently deletes a saved logo query and all of its matches. If the query does not exist in this account, the request fails with error code 404.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Delete logo query", - builder, + }, + }, + operands: [ + { placeholder: "query-id", brief: "ID of the logo query.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -54,7 +45,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -86,6 +77,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/brand-protection/logos/get.ts b/packages/cli/src/commands/_generated/brand-protection/logos/get.ts index c32d9ab532..0215ad6102 100644 --- a/packages/cli/src/commands/_generated/brand-protection/logos/get.ts +++ b/packages/cli/src/commands/_generated/brand-protection/logos/get.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/brand-protection/logos/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/brand-protection.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,41 +16,40 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 brand-protection logos get\n\nLists the account's saved logo queries. Set `id` to return a single query object instead of an array. Set `download=true` to include each logo image as base64 data." - ) - .option("id", { - type: "string", - description: +const command = apiCommand({ + command: "get", + describe: "List logo queries", + usage: + "$0 brand-protection logos get\n\nLists the account's saved logo queries. Set `id` to return a single query object instead of an array. Set `download=true` to include each logo image as base64 data.", + flags: { + id: { + kind: "parsed", + brief: "ID of a logo query. When set, `result` is that single query object instead of an array.", - }) - .option("download", { - type: "string", - description: + optional: true, + parse: String, + }, + download: { + kind: "parsed", + brief: "Set to `true` to include each logo image as base64 data in `image_data`, with its MIME type in `content_type`.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "get", - describe: "List logo queries", - builder, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "brand-protection logos get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -81,6 +79,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/brand-protection/logos/index.ts b/packages/cli/src/commands/_generated/brand-protection/logos/index.ts index aefe3e2f0e..8cab623a0f 100644 --- a/packages/cli/src/commands/_generated/brand-protection/logos/index.ts +++ b/packages/cli/src/commands/_generated/brand-protection/logos/index.ts @@ -1,26 +1,21 @@ import $create from "./create.js"; import $delete from "./delete.js"; import $get from "./get.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * logos command group * @generated from apis/overlays/brand-protection.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "logos", describe: "Operations for logos", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($get) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + get: $get, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/brand-protection/matches/bulk-dismiss.ts b/packages/cli/src/commands/_generated/brand-protection/matches/bulk-dismiss.ts index f89babbbe7..f10219e6c9 100644 --- a/packages/cli/src/commands/_generated/brand-protection/matches/bulk-dismiss.ts +++ b/packages/cli/src/commands/_generated/brand-protection/matches/bulk-dismiss.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/brand-protection/matches/bulk-dismiss.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * bulk-dismiss command * @generated from apis/overlays/brand-protection.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,53 +19,56 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredEnumField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 brand-protection matches bulk-dismiss\n\nDismisses or undismisses up to 100 domain matches in one request and returns a result for each item. Send `matches` as (`query_id`, `domain_id`) pairs to change each match for one query. The legacy `match_ids` format is still accepted, but it changes each match for every query that shares it; prefer `matches`." - ) - .option("action", { - type: "string", - description: +const command = apiCommand({ + command: "bulk-dismiss", + describe: "Bulk dismiss or undismiss matches", + usage: + "$0 brand-protection matches bulk-dismiss\n\nDismisses or undismisses up to 100 domain matches in one request and returns a result for each item. Send `matches` as (`query_id`, `domain_id`) pairs to change each match for one query. The legacy `match_ids` format is still accepted, but it changes each match for every query that shares it; prefer `matches`.", + flags: { + action: { + kind: "parsed", + brief: "`dismiss` to dismiss the matches, or `undismiss` to restore them.", + optional: true, choices: ["dismiss", "undismiss"], - }) - .coerce("action", (value) => resolveFileToken(value, "action", "text")) - .option("match-ids", { - type: "string", - array: true, - description: + parse: String, + coerce: (value: string) => resolveFileToken(value, "action", "text"), + }, + "match-ids": { + kind: "parsed", + brief: "Legacy format; prefer `matches`. Match IDs to update. Each ID changes the match for every query that shares it, not just one query. 1 to 100 items; duplicate IDs are rejected.", - }) - .option("matches", { - type: "string", - description: + variadic: true, + optional: true, + parse: String, + }, + matches: { + kind: "parsed", + brief: 'Matches to update, as (`query_id`, `domain_id`) pairs. Each pair changes the match for that query only. 1 to 100 items; duplicate pairs are rejected. Send only one format. If both are supplied, `match_ids` takes precedence and `matches` is ignored. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"domain_id": number, "query_id": number}].', - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "bulk-dismiss", - describe: "Bulk dismiss or undismiss matches", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "brand-protection matches bulk-dismiss", classification: { safeFlags: ["action", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -129,6 +131,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/brand-protection/matches/get.ts b/packages/cli/src/commands/_generated/brand-protection/matches/get.ts index 67dcfafeec..028c0ed0d6 100644 --- a/packages/cli/src/commands/_generated/brand-protection/matches/get.ts +++ b/packages/cli/src/commands/_generated/brand-protection/matches/get.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/brand-protection/matches/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/brand-protection.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,78 +16,86 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 brand-protection matches get\n\nLists domains that matched one or more saved domain queries, most recently matched first by default. When you pass several comma-separated `query_id` values, matches are deduplicated by domain and each match includes a `match_details` array with per-query dismissed state. Set `include_domain_id=true` to get the `domain_id` needed to dismiss or undismiss a match." - ) - .option("offset", { - type: "string", - description: "Number of matches to skip, for pagination. Defaults to 0.", - }) - .option("limit", { - type: "string", - description: "Maximum number of matches to return. Defaults to 50.", - }) - .option("query-id", { - type: "string", - array: true, - description: +const command = apiCommand({ + command: "get", + describe: "List domain matches", + usage: + "$0 brand-protection matches get\n\nLists domains that matched one or more saved domain queries, most recently matched first by default. When you pass several comma-separated `query_id` values, matches are deduplicated by domain and each match includes a `match_details` array with per-query dismissed state. Set `include_domain_id=true` to get the `domain_id` needed to dismiss or undismiss a match.", + flags: { + offset: { + kind: "parsed", + brief: "Number of matches to skip, for pagination. Defaults to 0.", + optional: true, + parse: String, + }, + limit: { + kind: "parsed", + brief: "Maximum number of matches to return. Defaults to 50.", + optional: true, + parse: String, + }, + "query-id": { + kind: "parsed", + brief: "ID of a domain query, or a comma-separated list of domain query IDs. When you pass several IDs, matches are deduplicated by domain and each match includes a `match_details` array with per-query metadata and dismissed state.", - demandOption: true, - }) - .option("include-domain-id", { - type: "string", - description: + variadic: true, + parse: String, + }, + "include-domain-id": { + kind: "parsed", + brief: "Set to `true` to include `domain_id` on each match. Required to dismiss or undismiss a match. Defaults to `false`.", - }) - .option("include-dismissed", { - type: "string", - description: + optional: true, + parse: String, + }, + "include-dismissed": { + kind: "parsed", + brief: "Set to `false` to exclude dismissed matches. Dismissed matches are included when this is omitted or `true`.", - }) - .option("domain-search", { - type: "string", - description: + optional: true, + parse: String, + }, + "domain-search": { + kind: "parsed", + brief: "Return only matches whose domain contains this text (case-insensitive).", - }) - .option("quality", { - type: "string", - description: "Filter matches by quality. Options: 'high' or 'low'", - choices: ["high", "low"], - }) - .option("order-by", { - type: "string", - description: + optional: true, + parse: String, + }, + quality: { + kind: "enum", + brief: "Filter matches by quality. Options: 'high' or 'low'", + values: ["high", "low"], + optional: true, + }, + "order-by": { + kind: "enum", + brief: "Field to sort by: `domain`, `first_seen`, or `registrar`. Defaults to `first_seen`.", - choices: ["domain", "first_seen", "registrar"], - }) - .option("order", { - type: "string", - description: + values: ["domain", "first_seen", "registrar"], + optional: true, + }, + order: { + kind: "enum", + brief: "Sort direction: `asc` or `desc`. Defaults to `desc`. For single-query requests, `asc` applies only when `orderBy` is set.", - choices: ["asc", "desc"], - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + values: ["asc", "desc"], + optional: true, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "get", - describe: "List domain matches", - builder, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "brand-protection matches get", classification: { safeFlags: ["quality", "order-by", "order", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -125,6 +132,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/brand-protection/matches/index.ts b/packages/cli/src/commands/_generated/brand-protection/matches/index.ts index 26e5371804..3422aa0cb5 100644 --- a/packages/cli/src/commands/_generated/brand-protection/matches/index.ts +++ b/packages/cli/src/commands/_generated/brand-protection/matches/index.ts @@ -1,24 +1,19 @@ import $bulkdismiss from "./bulk-dismiss.js"; import $get from "./get.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * matches command group * @generated from apis/overlays/brand-protection.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "matches", describe: "Operations for matches", - builder: (yargs) => { - return yargs - .command($bulkdismiss) - .command($get) - .demandCommand(1, "Please specify a subcommand"); + routes: { + "bulk-dismiss": $bulkdismiss, + get: $get, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/brand-protection/queries/dismiss.ts b/packages/cli/src/commands/_generated/brand-protection/queries/dismiss.ts index 311854c3d7..4f75ad4972 100644 --- a/packages/cli/src/commands/_generated/brand-protection/queries/dismiss.ts +++ b/packages/cli/src/commands/_generated/brand-protection/queries/dismiss.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/brand-protection/queries/dismiss.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * dismiss command * @generated from apis/overlays/brand-protection.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,42 +16,38 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 brand-protection queries dismiss \n\nMarks a matched domain as dismissed for one domain query. Dismissals are per query: dismissing a domain in one query does not affect other queries. Get `domain_id` from List domain matches with `include_domain_id=true`. Dismissing an already dismissed match succeeds. If the query or match does not exist, the request fails with error code 404." - ) - .positional("domain-id", { - type: "string", - description: - "ID of the matched domain, as returned in \`domain_id\` by List domain matches with \`include_domain_id=true\`.", - demandOption: true, - }) - .option("query-id", { - type: "string", - description: "ID of the domain query that the match belongs to.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "dismiss ", describe: "Dismiss a domain match", - builder, + usage: + "$0 brand-protection queries dismiss \n\nMarks a matched domain as dismissed for one domain query. Dismissals are per query: dismissing a domain in one query does not affect other queries. Get `domain_id` from List domain matches with `include_domain_id=true`. Dismissing an already dismissed match succeeds. If the query or match does not exist, the request fails with error code 404.", + flags: { + "query-id": { + kind: "parsed", + brief: "ID of the domain query that the match belongs to.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "domain-id", + brief: + "ID of the matched domain, as returned in \`domain_id\` by List domain matches with \`include_domain_id=true\`.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "brand-protection queries dismiss", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -84,6 +79,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/brand-protection/queries/get.ts b/packages/cli/src/commands/_generated/brand-protection/queries/get.ts index c438e360f4..2abe2c5833 100644 --- a/packages/cli/src/commands/_generated/brand-protection/queries/get.ts +++ b/packages/cli/src/commands/_generated/brand-protection/queries/get.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/brand-protection/queries/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/brand-protection.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,46 +16,47 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 brand-protection queries get\n\nLists the account's saved domain queries, most recently updated first. Set `id` to return a single query object instead of an array. Set `page` or `per_page` to paginate the list; the response then includes `result_info`. Without them, every query is returned." - ) - .option("id", { - type: "string", - description: +const command = apiCommand({ + command: "get", + describe: "List domain queries", + usage: + "$0 brand-protection queries get\n\nLists the account's saved domain queries, most recently updated first. Set `id` to return a single query object instead of an array. Set `page` or `per_page` to paginate the list; the response then includes `result_info`. Without them, every query is returned.", + flags: { + id: { + kind: "parsed", + brief: "ID of a domain query. When set, `result` is that single query object instead of an array, and `page` and `per_page` are ignored.", - }) - .option("page", { - type: "number", - description: + optional: true, + parse: String, + }, + page: { + kind: "parsed", + brief: "Page number for paginated list requests. Defaults to 1 when only per_page is supplied. Omit page and per_page to return every query.", - }) - .option("per-page", { - type: "number", - description: + optional: true, + parse: Number, + }, + "per-page": { + kind: "parsed", + brief: "Number of queries per page for paginated list requests. Defaults to 100 when only page is supplied. Maximum 100. Omit page and per_page to return every query.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "get", - describe: "List domain queries", - builder, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "brand-protection queries get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -87,6 +87,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/brand-protection/queries/index.ts b/packages/cli/src/commands/_generated/brand-protection/queries/index.ts index 5b7c25ea61..dfaa60f9e4 100644 --- a/packages/cli/src/commands/_generated/brand-protection/queries/index.ts +++ b/packages/cli/src/commands/_generated/brand-protection/queries/index.ts @@ -1,26 +1,21 @@ import $dismiss from "./dismiss.js"; import $get from "./get.js"; import $undismiss from "./undismiss.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * queries command group * @generated from apis/overlays/brand-protection.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "queries", describe: "Operations for queries", - builder: (yargs) => { - return yargs - .command($dismiss) - .command($get) - .command($undismiss) - .demandCommand(1, "Please specify a subcommand"); + routes: { + dismiss: $dismiss, + get: $get, + undismiss: $undismiss, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/brand-protection/queries/undismiss.ts b/packages/cli/src/commands/_generated/brand-protection/queries/undismiss.ts index 040ae3df52..c12273da9e 100644 --- a/packages/cli/src/commands/_generated/brand-protection/queries/undismiss.ts +++ b/packages/cli/src/commands/_generated/brand-protection/queries/undismiss.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/brand-protection/queries/undismiss.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * undismiss command * @generated from apis/overlays/brand-protection.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,42 +16,38 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 brand-protection queries undismiss \n\nRemoves the dismissed status from a matched domain for one domain query. Undismissing a domain in one query does not affect other queries. Get `domain_id` from List domain matches with `include_domain_id=true`. Undismissing a match that is not dismissed succeeds. If the query or match does not exist, the request fails with error code 404." - ) - .positional("domain-id", { - type: "string", - description: - "ID of the matched domain, as returned in \`domain_id\` by List domain matches with \`include_domain_id=true\`.", - demandOption: true, - }) - .option("query-id", { - type: "string", - description: "ID of the domain query that the match belongs to.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "undismiss ", describe: "Undismiss a domain match", - builder, + usage: + "$0 brand-protection queries undismiss \n\nRemoves the dismissed status from a matched domain for one domain query. Undismissing a domain in one query does not affect other queries. Get `domain_id` from List domain matches with `include_domain_id=true`. Undismissing a match that is not dismissed succeeds. If the query or match does not exist, the request fails with error code 404.", + flags: { + "query-id": { + kind: "parsed", + brief: "ID of the domain query that the match belongs to.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "domain-id", + brief: + "ID of the matched domain, as returned in \`domain_id\` by List domain matches with \`include_domain_id=true\`.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "brand-protection queries undismiss", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -84,6 +79,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/brand-protection/submit.ts b/packages/cli/src/commands/_generated/brand-protection/submit.ts index 945f0477f2..19e1d6f68f 100644 --- a/packages/cli/src/commands/_generated/brand-protection/submit.ts +++ b/packages/cli/src/commands/_generated/brand-protection/submit.ts @@ -1,11 +1,10 @@ import operation from "../_operations/brand-protection/submit.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * submit command * @generated from apis/overlays/brand-protection.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,61 +19,65 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 brand-protection submit\n\nSubmit an image and find the n closest matches from the scanned images index without creating any match records. Returns similarity scores and metadata for each match." - ) - .option("show-historic", { - type: "string", - description: +const command = apiCommand({ + command: "submit", + describe: "Search scanned images", + usage: + "$0 brand-protection submit\n\nSubmit an image and find the n closest matches from the scanned images index without creating any match records. Returns similarity scores and metadata for each match.", + flags: { + "show-historic": { + kind: "parsed", + brief: "Include scanned images without domain metadata (historic data). Default: false (only show images with domain)", - }) - .option("download", { - type: "string", - description: "If true, include base64-encoded image data in the response", - }) - .option("image-data", { - type: "string", - description: + optional: true, + parse: String, + }, + download: { + kind: "parsed", + brief: "If true, include base64-encoded image data in the response", + optional: true, + parse: String, + }, + "image-data": { + kind: "parsed", + brief: "Base64 encoded image data. Can include data URI prefix (e.g., 'data:image/png;base64,...') or just the base64 string.", - }) - .option("score-threshold", { - type: "number", - description: - "Minimum similarity score threshold for matches (0-1, default: 0)", - default: 0, - }) - .option("top-k", { - type: "number", - description: + optional: true, + parse: String, + }, + "score-threshold": { + kind: "parsed", + brief: "Minimum similarity score threshold for matches (0-1, default: 0)", + default: "0", + parse: Number, + }, + "top-k": { + kind: "parsed", + brief: "Number of closest matches to return. Defaults to 10. Accepts 1 to 100, but values above 50 are treated as 50.", - default: 10, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + default: "10", + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "submit", - describe: "Search scanned images", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "brand-protection submit", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -167,6 +170,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/brand-protection/trial/create.ts b/packages/cli/src/commands/_generated/brand-protection/trial/create.ts index 14229202f8..06bc5cc84b 100644 --- a/packages/cli/src/commands/_generated/brand-protection/trial/create.ts +++ b/packages/cli/src/commands/_generated/brand-protection/trial/create.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/brand-protection/trial/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/brand-protection.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -20,36 +19,38 @@ import { withProgress } from "#lib/progress.js"; import { promptForRequiredField } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 brand-protection trial create\n\nUses AI to scan all domains in the lookback table and identify potential phishing or impersonation attempts against the given brand string." - ) - .option("brand", { type: "string", description: "The brand field" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create", describe: "Analyze domains for brand impersonation", - builder, + usage: + "$0 brand-protection trial create\n\nUses AI to scan all domains in the lookback table and identify potential phishing or impersonation attempts against the given brand string.", + flags: { + brand: { + kind: "parsed", + brief: "The brand field", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "brand-protection trial create", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -115,6 +116,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/brand-protection/trial/index.ts b/packages/cli/src/commands/_generated/brand-protection/trial/index.ts index 3cb82133ac..1d856c1154 100644 --- a/packages/cli/src/commands/_generated/brand-protection/trial/index.ts +++ b/packages/cli/src/commands/_generated/brand-protection/trial/index.ts @@ -1,22 +1,17 @@ import $create from "./create.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * trial command group * @generated from apis/overlays/brand-protection.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "trial", describe: "Operations for trial", - builder: (yargs) => { - return yargs - .command($create) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/brand-protection/url-info.ts b/packages/cli/src/commands/_generated/brand-protection/url-info.ts index 29abf30223..b43e27f1d9 100644 --- a/packages/cli/src/commands/_generated/brand-protection/url-info.ts +++ b/packages/cli/src/commands/_generated/brand-protection/url-info.ts @@ -1,11 +1,10 @@ import operation from "../_operations/brand-protection/url-info.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * url-info command * @generated from apis/overlays/brand-protection.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,31 +16,26 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 brand-protection url-info\n\nReturns the number of saved domain and logo queries in the account. This is the count checked against the account's Brand Protection query limit." - ) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "url-info", describe: "Get total query count", - builder, + usage: + "$0 brand-protection url-info\n\nReturns the number of saved domain and logo queries in the account. This is the count checked against the account's Brand Protection query limit.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "brand-protection url-info", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -66,6 +60,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/brand-protection/urls/get.ts b/packages/cli/src/commands/_generated/brand-protection/urls/get.ts index 193b08cb3c..68dddae5c4 100644 --- a/packages/cli/src/commands/_generated/brand-protection/urls/get.ts +++ b/packages/cli/src/commands/_generated/brand-protection/urls/get.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/brand-protection/urls/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/brand-protection.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,33 +16,38 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 brand-protection urls get\n\nGet account-scoped URL Scanner summaries by submitted URL or scan UUID. Lookups cover scans submitted within about the last 30 days; a daily cleanup at 00:00 UTC removes older ownership records. Completed results may be served from a cache that is cleared daily, so a cached copy is kept for at most about 48 hours. The response is a v2 migration contract, not the v1 enrichment shape." - ) - .option("url", { type: "string", description: "An HTTP or HTTPS URL." }) - .option("url-id", { type: "string", description: "Url ID" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get", describe: "Get URL scan information", - builder, + usage: + "$0 brand-protection urls get\n\nGet account-scoped URL Scanner summaries by submitted URL or scan UUID. Lookups cover scans submitted within about the last 30 days; a daily cleanup at 00:00 UTC removes older ownership records. Completed results may be served from a cache that is cleared daily, so a cached copy is kept for at most about 48 hours. The response is a v2 migration contract, not the v1 enrichment shape.", + flags: { + url: { + kind: "parsed", + brief: "An HTTP or HTTPS URL.", + optional: true, + parse: String, + }, + "url-id": { + kind: "parsed", + brief: "Url ID", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "brand-protection urls get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -73,6 +77,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/brand-protection/urls/index.ts b/packages/cli/src/commands/_generated/brand-protection/urls/index.ts index d395a326b8..b6375586d5 100644 --- a/packages/cli/src/commands/_generated/brand-protection/urls/index.ts +++ b/packages/cli/src/commands/_generated/brand-protection/urls/index.ts @@ -1,24 +1,19 @@ import $get from "./get.js"; import $submit from "./submit.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * urls command group * @generated from apis/overlays/brand-protection.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "urls", describe: "Operations for urls", - builder: (yargs) => { - return yargs - .command($get) - .command($submit) - .demandCommand(1, "Please specify a subcommand"); + routes: { + get: $get, + submit: $submit, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/brand-protection/urls/submit.ts b/packages/cli/src/commands/_generated/brand-protection/urls/submit.ts index 73c382c347..331f2787d7 100644 --- a/packages/cli/src/commands/_generated/brand-protection/urls/submit.ts +++ b/packages/cli/src/commands/_generated/brand-protection/urls/submit.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/brand-protection/urls/submit.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * submit command * @generated from apis/overlays/brand-protection.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,27 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 brand-protection urls submit\n\nSubmit one unlisted URL Scanner scan. The returned URL Scanner UUID replaces the numeric v1 URL ID." - ) - .option("url", { - type: "string", - description: "An HTTP or HTTPS URL.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "submit", describe: "Submit a URL for scanning", - builder, + usage: + "$0 brand-protection urls submit\n\nSubmit one unlisted URL Scanner scan. The returned URL Scanner UUID replaces the numeric v1 URL ID.", + flags: { + url: { kind: "parsed", brief: "An HTTP or HTTPS URL.", parse: String }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "brand-protection urls submit", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -75,6 +65,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/browser-run/crawl/create.ts b/packages/cli/src/commands/_generated/browser-run/crawl/create.ts index 82b30962eb..5907e0138f 100644 --- a/packages/cli/src/commands/_generated/browser-run/crawl/create.ts +++ b/packages/cli/src/commands/_generated/browser-run/crawl/create.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/browser-run/crawl/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/browser-run.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,39 +18,38 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 browser-run crawl create\n\nStarts a crawl job for the provided URL and its children. Check available options like `gotoOptions` and `waitFor*` to control page load behaviour." - ) - .option("cache-ttl", { - type: "number", - description: "Cache TTL default is 5s. Set to 0 to disable.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create", describe: "Crawl websites.", - builder, + usage: + "$0 browser-run crawl create\n\nStarts a crawl job for the provided URL and its children. Check available options like `gotoOptions` and `waitFor*` to control page load behaviour.", + flags: { + "cache-ttl": { + kind: "parsed", + brief: "Cache TTL default is 5s. Set to 0 to disable.", + optional: true, + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "browser-run crawl create", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -106,6 +104,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/browser-run/crawl/delete.ts b/packages/cli/src/commands/_generated/browser-run/crawl/delete.ts index bd648263b6..14502f6423 100644 --- a/packages/cli/src/commands/_generated/browser-run/crawl/delete.ts +++ b/packages/cli/src/commands/_generated/browser-run/crawl/delete.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/browser-run/crawl/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/browser-run.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,35 +17,31 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 browser-run crawl delete \n\nCancels an ongoing crawl job by setting its status to cancelled and stopping all queued URLs." - ) - .positional("job-id", { - type: "string", - description: "The ID of the crawl job to cancel.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Cancel a crawl job.", + usage: + "$0 browser-run crawl delete \n\nCancels an ongoing crawl job by setting its status to cancelled and stopping all queued URLs.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Cancel a crawl job.", - builder, + }, + }, + operands: [ + { + placeholder: "job-id", + brief: "The ID of the crawl job to cancel.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -54,7 +49,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -86,6 +81,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/browser-run/crawl/get.ts b/packages/cli/src/commands/_generated/browser-run/crawl/get.ts index 079d578871..7d171acc01 100644 --- a/packages/cli/src/commands/_generated/browser-run/crawl/get.ts +++ b/packages/cli/src/commands/_generated/browser-run/crawl/get.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/browser-run/crawl/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/browser-run.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,24 +16,22 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 browser-run crawl get \n\nReturns the result of a crawl job." - ) - .positional("job-id", { - type: "string", - description: "Crawl job ID.", - demandOption: true, - }) - .option("cache-ttl", { - type: "number", - description: "Cache TTL default is 5s. Set to 0 to disable.", - }) - .option("status", { - type: "string", - description: "Filter by URL status.", - choices: [ +const command = apiCommand({ + command: "get ", + describe: "Get crawl result.", + usage: + "$0 browser-run crawl get \n\nReturns the result of a crawl job.", + flags: { + "cache-ttl": { + kind: "parsed", + brief: "Cache TTL default is 5s. Set to 0 to disable.", + optional: true, + parse: Number, + }, + status: { + kind: "enum", + brief: "Filter by URL status.", + values: [ "queued", "errored", "completed", @@ -42,29 +39,34 @@ function builder(yargs: Argv) { "skipped", "cancelled", ], - }) - .option("cursor", { type: "number", description: "Cursor for pagination." }) - .option("limit", { type: "number", description: "Limit for pagination." }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + }, + cursor: { + kind: "parsed", + brief: "Cursor for pagination.", + optional: true, + parse: Number, + }, + limit: { + kind: "parsed", + brief: "Limit for pagination.", + optional: true, + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "get ", - describe: "Get crawl result.", - builder, + }, + }, + operands: [{ placeholder: "job-id", brief: "Crawl job ID.", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "browser-run crawl get", classification: { safeFlags: ["status", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -100,6 +102,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/browser-run/crawl/index.ts b/packages/cli/src/commands/_generated/browser-run/crawl/index.ts index 7db4bd0afd..06db58e330 100644 --- a/packages/cli/src/commands/_generated/browser-run/crawl/index.ts +++ b/packages/cli/src/commands/_generated/browser-run/crawl/index.ts @@ -1,26 +1,21 @@ import $create from "./create.js"; import $delete from "./delete.js"; import $get from "./get.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * crawl command group * @generated from apis/overlays/browser-run.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "crawl", describe: "Operations for crawl", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($get) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + get: $get, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/browser-run/devtools/browser/create.ts b/packages/cli/src/commands/_generated/browser-run/devtools/browser/create.ts index 962a5a3a34..1e537a8864 100644 --- a/packages/cli/src/commands/_generated/browser-run/devtools/browser/create.ts +++ b/packages/cli/src/commands/_generated/browser-run/devtools/browser/create.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/browser-run/devtools/browser/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/browser-run.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,65 +17,72 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 browser-run devtools browser create\n\nAcquires a browser and returns its session ID and websocket URL. Optionally accepts a JSON body with session guardrails to restrict outbound HTTP/S traffic." - ) - .option("keep-alive", { - type: "number", - description: "Keep-alive time in milliseconds.", - }) - .option("lab", { - type: "boolean", - description: "Use experimental browser.", - }) - .option("targets", { - type: "boolean", - description: "Include browser targets in response.", - }) - .option("live-view-url-expires-in-ms", { - type: "number", - description: +const command = apiCommand({ + command: "create", + describe: "Get a browser session ID.", + usage: + "$0 browser-run devtools browser create\n\nAcquires a browser and returns its session ID and websocket URL. Optionally accepts a JSON body with session guardrails to restrict outbound HTTP/S traffic.", + flags: { + "keep-alive": { + kind: "parsed", + brief: "Keep-alive time in milliseconds.", + optional: true, + parse: Number, + }, + lab: { + kind: "boolean", + brief: "Use experimental browser.", + optional: true, + }, + targets: { + kind: "boolean", + brief: "Include browser targets in response.", + optional: true, + }, + "live-view-url-expires-in-ms": { + kind: "parsed", + brief: "How long the live view URL remains valid, in milliseconds (max 60 minutes). Only used when targets is true.", - }) - .option("recording", { type: "boolean", description: "Recording" }) - .option("guardrails-allowed-domain-sets", { - type: "string", - array: true, - description: + optional: true, + parse: Number, + }, + recording: { kind: "boolean", brief: "Recording", optional: true }, + "guardrails-allowed-domain-sets": { + kind: "parsed", + brief: "Max 4 entries: curated preset names (common-cdns) and/or https URLs of newline-separated hostname lists.", - }) - .option("guardrails-allowed-domains", { - type: "string", - array: true, - description: + variadic: true, + optional: true, + parse: String, + }, + "guardrails-allowed-domains": { + kind: "parsed", + brief: "Hostname patterns, max 50. Supports exact hosts (example.com) or a single * wildcard anywhere. Prefer *.example.com (subdomain wildcard) over *example.com (prefix wildcard) to avoid matching overbroad lookalikes like evilexample.com.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + variadic: true, + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "create", - describe: "Get a browser session ID.", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "browser-run devtools browser create", classification: { safeFlags: ["lab", "targets", "recording", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -154,6 +160,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/browser-run/devtools/browser/delete.ts b/packages/cli/src/commands/_generated/browser-run/devtools/browser/delete.ts index eced16ec03..4819ddf890 100644 --- a/packages/cli/src/commands/_generated/browser-run/devtools/browser/delete.ts +++ b/packages/cli/src/commands/_generated/browser-run/devtools/browser/delete.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/browser-run/devtools/browser/delete.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * delete command * @generated from apis/overlays/browser-run.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -18,35 +17,31 @@ import { withProgress } from "#lib/progress.js"; import { confirmDelete } from "#lib/prompt.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 browser-run devtools browser delete \n\nCloses an existing browser session." - ) - .positional("session-id", { - type: "string", - description: "Browser session ID to close.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", +const command = apiCommand({ + command: "delete ", + describe: "Close browser session.", + usage: + "$0 browser-run devtools browser delete \n\nCloses an existing browser session.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("force", { - type: "boolean", + }, + force: { + kind: "boolean", + brief: "Skip confirmation (useful in scripts and CI)", alias: "f", - description: "Skip confirmation (useful in scripts and CI)", default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "delete ", - describe: "Close browser session.", - builder, + }, + }, + operands: [ + { + placeholder: "session-id", + brief: "Browser session ID to close.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { @@ -54,7 +49,7 @@ const command: CommandModule = { classification: { safeFlags: ["dry-run", "force"], shortFlagAliases: { f: { canonical: "force", type: "boolean" } }, - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -86,6 +81,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Deleted` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/browser-run/devtools/browser/index.ts b/packages/cli/src/commands/_generated/browser-run/devtools/browser/index.ts index 575d5ba1a0..809cc7184a 100644 --- a/packages/cli/src/commands/_generated/browser-run/devtools/browser/index.ts +++ b/packages/cli/src/commands/_generated/browser-run/devtools/browser/index.ts @@ -4,29 +4,24 @@ import $liveview from "./live-view/index.js"; import $protocol from "./protocol.js"; import $targets from "./targets/index.js"; import $version from "./version.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * browser command group * @generated from apis/overlays/browser-run.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "browser", describe: "Operations for devtools.browser", - builder: (yargs) => { - return yargs - .command($create) - .command($delete) - .command($protocol) - .command($version) - .command($liveview) - .command($targets) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, + delete: $delete, + protocol: $protocol, + version: $version, + "live-view": $liveview, + targets: $targets, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/browser-run/devtools/browser/live-view/create.ts b/packages/cli/src/commands/_generated/browser-run/devtools/browser/live-view/create.ts index b4d8f58657..493024a5bd 100644 --- a/packages/cli/src/commands/_generated/browser-run/devtools/browser/live-view/create.ts +++ b/packages/cli/src/commands/_generated/browser-run/devtools/browser/live-view/create.ts @@ -1,11 +1,10 @@ import operation from "../../../../_operations/browser-run/devtools/browser/live-view/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/browser-run.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -19,69 +18,66 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 browser-run devtools browser live-view create \n\nGenerates time-limited URLs to view a remote browser session. Set `guardrails: { mode: 'readonly' }` to create a view-only link." - ) - .positional("session-id", { - type: "string", - description: "Browser session ID", - demandOption: true, - }) - .option("expires-in-ms", { - type: "number", - description: +const command = apiCommand({ + command: "create ", + describe: "Mint live view URLs for a browser session", + usage: + "$0 browser-run devtools browser live-view create \n\nGenerates time-limited URLs to view a remote browser session. Set `guardrails: { mode: 'readonly' }` to create a view-only link.", + flags: { + "expires-in-ms": { + kind: "parsed", + brief: "How long the live view URLs remain valid, in milliseconds. Default: 5 minutes. Max: 60 minutes.", - default: 300000, - }) - .option("guardrails-mode", { - type: "string", - description: "The guardrails.mode field", + default: "300000", + parse: Number, + }, + "guardrails-mode": { + kind: "parsed", + brief: "The guardrails.mode field", + optional: true, choices: ["readonly"], - }) - .coerce("guardrails-mode", (value) => - resolveFileToken(value, "guardrails-mode", "text") - ) - .option("view-mode", { - type: "string", - description: + parse: String, + coerce: (value: string) => + resolveFileToken(value, "guardrails-mode", "text"), + }, + "view-mode": { + kind: "parsed", + brief: "UI mode: 'devtools' (Chrome DevTools), 'tab' (single tab view), 'full' (multi-tab browser)", - choices: ["devtools", "tab", "full"], default: "devtools", - }) - .coerce("view-mode", (value) => - resolveFileToken(value, "view-mode", "text") - ) - .option("target-id", { - type: "string", - description: + choices: ["devtools", "tab", "full"], + parse: String, + coerce: (value: string) => resolveFileToken(value, "view-mode", "text"), + }, + "target-id": { + kind: "parsed", + brief: "Target ID (page) to connect to. If omitted, auto-resolves to the first active page.", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", + optional: true, + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", default: false, - }) - .option("body", { - type: "string", - description: "Raw JSON request body (bypasses individual flags)", - }); -} - -type Args = InferArgs; - -const command: CommandModule = { - command: "create ", - describe: "Mint live view URLs for a browser session", - builder, + }, + body: { + kind: "parsed", + brief: "Raw JSON request body (bypasses individual flags)", + optional: true, + parse: String, + }, + }, + operands: [ + { placeholder: "session-id", brief: "Browser session ID", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "browser-run devtools browser live-view create", classification: { safeFlags: ["guardrails-mode", "view-mode", "dry-run"], - } satisfies ArgClassification, + } satisfies ArgClassification, }, argv as Record, async () => { @@ -153,6 +149,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Created` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/browser-run/devtools/browser/live-view/index.ts b/packages/cli/src/commands/_generated/browser-run/devtools/browser/live-view/index.ts index 1a424501e9..c571e673f4 100644 --- a/packages/cli/src/commands/_generated/browser-run/devtools/browser/live-view/index.ts +++ b/packages/cli/src/commands/_generated/browser-run/devtools/browser/live-view/index.ts @@ -1,22 +1,17 @@ import $create from "./create.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * live-view command group * @generated from apis/overlays/browser-run.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "live-view", describe: "Operations for devtools.browser.live-view", - builder: (yargs) => { - return yargs - .command($create) - .demandCommand(1, "Please specify a subcommand"); + routes: { + create: $create, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/browser-run/devtools/browser/protocol.ts b/packages/cli/src/commands/_generated/browser-run/devtools/browser/protocol.ts index 3324793920..1acf52868c 100644 --- a/packages/cli/src/commands/_generated/browser-run/devtools/browser/protocol.ts +++ b/packages/cli/src/commands/_generated/browser-run/devtools/browser/protocol.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/browser-run/devtools/browser/protocol.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * protocol command * @generated from apis/overlays/browser-run.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,28 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 browser-run devtools browser protocol \n\nReturns the complete Chrome DevTools Protocol schema including all domains, commands, events, and types. This schema describes the entire CDP API surface." - ) - .positional("session-id", { - type: "string", - description: "Browser session ID.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "protocol ", describe: "Get Chrome DevTools Protocol schema.", - builder, + usage: + "$0 browser-run devtools browser protocol \n\nReturns the complete Chrome DevTools Protocol schema including all domains, commands, events, and types. This schema describes the entire CDP API surface.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { placeholder: "session-id", brief: "Browser session ID.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "browser-run devtools browser protocol", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -74,6 +65,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/browser-run/devtools/browser/targets/activate.ts b/packages/cli/src/commands/_generated/browser-run/devtools/browser/targets/activate.ts index 990ee9bf97..36659f5a6d 100644 --- a/packages/cli/src/commands/_generated/browser-run/devtools/browser/targets/activate.ts +++ b/packages/cli/src/commands/_generated/browser-run/devtools/browser/targets/activate.ts @@ -1,11 +1,10 @@ import operation from "../../../../_operations/browser-run/devtools/browser/targets/activate.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * activate command * @generated from apis/overlays/browser-run.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,41 +16,37 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 browser-run devtools browser targets activate \n\nActivates (brings to front) a specific browser target by its ID." - ) - .positional("target-id", { - type: "string", - description: "Target ID to activate.", - demandOption: true, - }) - .option("session-id", { - type: "string", - description: "Browser session ID.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "activate ", describe: "Activate a browser target.", - builder, + usage: + "$0 browser-run devtools browser targets activate \n\nActivates (brings to front) a specific browser target by its ID.", + flags: { + "session-id": { + kind: "parsed", + brief: "Browser session ID.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { + placeholder: "target-id", + brief: "Target ID to activate.", + parse: String, + }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "browser-run devtools browser targets activate", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -83,6 +78,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/browser-run/devtools/browser/targets/close.ts b/packages/cli/src/commands/_generated/browser-run/devtools/browser/targets/close.ts index 0fa58e869e..5867a487c1 100644 --- a/packages/cli/src/commands/_generated/browser-run/devtools/browser/targets/close.ts +++ b/packages/cli/src/commands/_generated/browser-run/devtools/browser/targets/close.ts @@ -1,11 +1,10 @@ import operation from "../../../../_operations/browser-run/devtools/browser/targets/close.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * close command * @generated from apis/overlays/browser-run.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,41 +16,33 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 browser-run devtools browser targets close \n\nCloses a specific browser target (tab, page, etc.) by its ID. Returns 'Target is closing' on success or an error if the target is not found." - ) - .positional("target-id", { - type: "string", - description: "Target ID to close.", - demandOption: true, - }) - .option("session-id", { - type: "string", - description: "Browser session ID.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "close ", describe: "Close a browser target.", - builder, + usage: + "$0 browser-run devtools browser targets close \n\nCloses a specific browser target (tab, page, etc.) by its ID. Returns 'Target is closing' on success or an error if the target is not found.", + flags: { + "session-id": { + kind: "parsed", + brief: "Browser session ID.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { placeholder: "target-id", brief: "Target ID to close.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "browser-run devtools browser targets close", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -83,6 +74,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/browser-run/devtools/browser/targets/create.ts b/packages/cli/src/commands/_generated/browser-run/devtools/browser/targets/create.ts index 6195c3fcdd..87545c2026 100644 --- a/packages/cli/src/commands/_generated/browser-run/devtools/browser/targets/create.ts +++ b/packages/cli/src/commands/_generated/browser-run/devtools/browser/targets/create.ts @@ -1,11 +1,10 @@ import operation from "../../../../_operations/browser-run/devtools/browser/targets/create.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * create command * @generated from apis/overlays/browser-run.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,42 +16,36 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 browser-run devtools browser targets create \n\nOpens a new tab in the browser. Optionally specify a URL to navigate to." - ) - .positional("session-id", { - type: "string", - description: "Browser session ID.", - demandOption: true, - }) - .option("url", { type: "string", description: "Url" }) - .option("live-view-url-expires-in-ms", { - type: "number", - description: - "How long the live view URL remains valid, in milliseconds (max 60 minutes)", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "create ", describe: "Open a new browser tab.", - builder, + usage: + "$0 browser-run devtools browser targets create \n\nOpens a new tab in the browser. Optionally specify a URL to navigate to.", + flags: { + url: { kind: "parsed", brief: "Url", optional: true, parse: String }, + "live-view-url-expires-in-ms": { + kind: "parsed", + brief: + "How long the live view URL remains valid, in milliseconds (max 60 minutes)", + optional: true, + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { placeholder: "session-id", brief: "Browser session ID.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "browser-run devtools browser targets create", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -86,6 +79,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Updated` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/browser-run/devtools/browser/targets/get.ts b/packages/cli/src/commands/_generated/browser-run/devtools/browser/targets/get.ts index aa23b22c07..7c86da3c33 100644 --- a/packages/cli/src/commands/_generated/browser-run/devtools/browser/targets/get.ts +++ b/packages/cli/src/commands/_generated/browser-run/devtools/browser/targets/get.ts @@ -1,11 +1,10 @@ import operation from "../../../../_operations/browser-run/devtools/browser/targets/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/browser-run.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,41 +16,31 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 browser-run devtools browser targets get \n\nReturns the debuggable target with the given ID." - ) - .positional("target-id", { - type: "string", - description: "Target ID.", - demandOption: true, - }) - .option("session-id", { - type: "string", - description: "Browser session ID.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get a target by ID.", - builder, + usage: + "$0 browser-run devtools browser targets get \n\nReturns the debuggable target with the given ID.", + flags: { + "session-id": { + kind: "parsed", + brief: "Browser session ID.", + parse: String, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [{ placeholder: "target-id", brief: "Target ID.", parse: String }], handler: async (argv): Promise => runWithTelemetry( { command: "browser-run devtools browser targets get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -83,6 +72,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/browser-run/devtools/browser/targets/index.ts b/packages/cli/src/commands/_generated/browser-run/devtools/browser/targets/index.ts index 3835a5d861..a71d2b5cbe 100644 --- a/packages/cli/src/commands/_generated/browser-run/devtools/browser/targets/index.ts +++ b/packages/cli/src/commands/_generated/browser-run/devtools/browser/targets/index.ts @@ -3,28 +3,23 @@ import $close from "./close.js"; import $create from "./create.js"; import $get from "./get.js"; import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * targets command group * @generated from apis/overlays/browser-run.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "targets", describe: "Operations for devtools.browser.targets", - builder: (yargs) => { - return yargs - .command($activate) - .command($close) - .command($create) - .command($get) - .command($list) - .demandCommand(1, "Please specify a subcommand"); + routes: { + activate: $activate, + close: $close, + create: $create, + get: $get, + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/browser-run/devtools/browser/targets/list.ts b/packages/cli/src/commands/_generated/browser-run/devtools/browser/targets/list.ts index 5ff2394137..8cb5b686b0 100644 --- a/packages/cli/src/commands/_generated/browser-run/devtools/browser/targets/list.ts +++ b/packages/cli/src/commands/_generated/browser-run/devtools/browser/targets/list.ts @@ -1,11 +1,10 @@ import operation from "../../../../_operations/browser-run/devtools/browser/targets/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/browser-run.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,41 +16,38 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 browser-run devtools browser targets list\n\nReturns a list of all debuggable targets including tabs, pages, service workers, and other browser contexts." - ) - .option("session-id", { - type: "string", - description: "Browser session ID.", - demandOption: true, - }) - .option("live-view-url-expires-in-ms", { - type: "number", - description: - "How long the live view URLs remain valid, in milliseconds (max 60 minutes)", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List targets.", - builder, + usage: + "$0 browser-run devtools browser targets list\n\nReturns a list of all debuggable targets including tabs, pages, service workers, and other browser contexts.", + flags: { + "session-id": { + kind: "parsed", + brief: "Browser session ID.", + parse: String, + }, + "live-view-url-expires-in-ms": { + kind: "parsed", + brief: + "How long the live view URLs remain valid, in milliseconds (max 60 minutes)", + optional: true, + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "browser-run devtools browser targets list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -84,6 +80,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/browser-run/devtools/browser/version.ts b/packages/cli/src/commands/_generated/browser-run/devtools/browser/version.ts index 8d228f43c6..5ab360d266 100644 --- a/packages/cli/src/commands/_generated/browser-run/devtools/browser/version.ts +++ b/packages/cli/src/commands/_generated/browser-run/devtools/browser/version.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/browser-run/devtools/browser/version.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * version command * @generated from apis/overlays/browser-run.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,28 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 browser-run devtools browser version \n\nGet browser version metadata." - ) - .positional("session-id", { - type: "string", - description: "Browser session ID.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "version ", describe: "Get browser version metadata.", - builder, + usage: + "$0 browser-run devtools browser version \n\nGet browser version metadata.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { placeholder: "session-id", brief: "Browser session ID.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "browser-run devtools browser version", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -74,6 +65,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/browser-run/devtools/index.ts b/packages/cli/src/commands/_generated/browser-run/devtools/index.ts index de06c7ca9a..f9aa268d6e 100644 --- a/packages/cli/src/commands/_generated/browser-run/devtools/index.ts +++ b/packages/cli/src/commands/_generated/browser-run/devtools/index.ts @@ -1,26 +1,21 @@ import $browser from "./browser/index.js"; import $json from "./json/index.js"; import $session from "./session/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * devtools command group * @generated from apis/overlays/browser-run.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "devtools", describe: "Operations for devtools", - builder: (yargs) => { - return yargs - .command($browser) - .command($json) - .command($session) - .demandCommand(1, "Please specify a subcommand"); + routes: { + browser: $browser, + json: $json, + session: $session, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/browser-run/devtools/json/get.ts b/packages/cli/src/commands/_generated/browser-run/devtools/json/get.ts index 45fac5273b..7c224df0d4 100644 --- a/packages/cli/src/commands/_generated/browser-run/devtools/json/get.ts +++ b/packages/cli/src/commands/_generated/browser-run/devtools/json/get.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/browser-run/devtools/json/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/browser-run.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,41 +16,35 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 browser-run devtools json get \n\nReturns a list of all debuggable targets including tabs, pages, service workers, and other browser contexts." - ) - .positional("session-id", { - type: "string", - description: "Browser session ID.", - demandOption: true, - }) - .option("live-view-url-expires-in-ms", { - type: "number", - description: - "How long the live view URLs remain valid, in milliseconds (max 60 minutes)", - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "List targets.", - builder, + usage: + "$0 browser-run devtools json get \n\nReturns a list of all debuggable targets including tabs, pages, service workers, and other browser contexts.", + flags: { + "live-view-url-expires-in-ms": { + kind: "parsed", + brief: + "How long the live view URLs remain valid, in milliseconds (max 60 minutes)", + optional: true, + parse: Number, + }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { placeholder: "session-id", brief: "Browser session ID.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "browser-run devtools json get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -84,6 +77,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/browser-run/devtools/json/index.ts b/packages/cli/src/commands/_generated/browser-run/devtools/json/index.ts index 47a597d454..dc225d09f3 100644 --- a/packages/cli/src/commands/_generated/browser-run/devtools/json/index.ts +++ b/packages/cli/src/commands/_generated/browser-run/devtools/json/index.ts @@ -1,20 +1,17 @@ import $get from "./get.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * json command group * @generated from apis/overlays/browser-run.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "json", describe: "Operations for devtools.json", - builder: (yargs) => { - return yargs.command($get).demandCommand(1, "Please specify a subcommand"); + routes: { + get: $get, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/browser-run/devtools/session/get.ts b/packages/cli/src/commands/_generated/browser-run/devtools/session/get.ts index fabe0654d6..92a9b66302 100644 --- a/packages/cli/src/commands/_generated/browser-run/devtools/session/get.ts +++ b/packages/cli/src/commands/_generated/browser-run/devtools/session/get.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/browser-run/devtools/session/get.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * get command * @generated from apis/overlays/browser-run.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,36 +16,28 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 browser-run devtools session get \n\nGet details for a specific browser session." - ) - .positional("session-id", { - type: "string", - description: "Session ID.", - demandOption: true, - }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "get ", describe: "Get session details.", - builder, + usage: + "$0 browser-run devtools session get \n\nGet details for a specific browser session.", + flags: { + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [ + { placeholder: "session-id", brief: "Session ID.", parse: String }, + ], handler: async (argv): Promise => runWithTelemetry( { command: "browser-run devtools session get", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -74,6 +65,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/browser-run/devtools/session/index.ts b/packages/cli/src/commands/_generated/browser-run/devtools/session/index.ts index b9f4ae9e28..94c46330d5 100644 --- a/packages/cli/src/commands/_generated/browser-run/devtools/session/index.ts +++ b/packages/cli/src/commands/_generated/browser-run/devtools/session/index.ts @@ -1,24 +1,19 @@ import $get from "./get.js"; import $list from "./list.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * session command group * @generated from apis/overlays/browser-run.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "session", describe: "Operations for devtools.session", - builder: (yargs) => { - return yargs - .command($get) - .command($list) - .demandCommand(1, "Please specify a subcommand"); + routes: { + get: $get, + list: $list, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/browser-run/devtools/session/list.ts b/packages/cli/src/commands/_generated/browser-run/devtools/session/list.ts index c7ada8e12b..66b5766b7a 100644 --- a/packages/cli/src/commands/_generated/browser-run/devtools/session/list.ts +++ b/packages/cli/src/commands/_generated/browser-run/devtools/session/list.ts @@ -1,11 +1,10 @@ import operation from "../../../_operations/browser-run/devtools/session/list.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * list command * @generated from apis/overlays/browser-run.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -17,33 +16,28 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 browser-run devtools session list\n\nList active browser sessions." - ) - .option("limit", { type: "number", description: "Limit" }) - .option("offset", { type: "number", description: "Offset" }) - .option("dry-run", { - type: "boolean", - description: "Validate and show what would happen without executing", - default: false, - }); -} - -type Args = InferArgs; - -const command: CommandModule = { +const command = apiCommand({ command: "list", describe: "List sessions.", - builder, + usage: + "$0 browser-run devtools session list\n\nList active browser sessions.", + flags: { + limit: { kind: "parsed", brief: "Limit", optional: true, parse: Number }, + offset: { kind: "parsed", brief: "Offset", optional: true, parse: Number }, + "dry-run": { + kind: "boolean", + brief: "Validate and show what would happen without executing", + default: false, + }, + }, + operands: [], handler: async (argv): Promise => runWithTelemetry( { command: "browser-run devtools session list", - classification: { - safeFlags: ["dry-run"], - } satisfies ArgClassification, + classification: { safeFlags: ["dry-run"] } satisfies ArgClassification< + typeof argv + >, }, argv as Record, async () => { @@ -73,6 +67,6 @@ const command: CommandModule = { formatOutput(result, { successLabel: `Loaded` }); } ), -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/browser-run/index.ts b/packages/cli/src/commands/_generated/browser-run/index.ts index 72ed39f8ad..3a3d882776 100644 --- a/packages/cli/src/commands/_generated/browser-run/index.ts +++ b/packages/cli/src/commands/_generated/browser-run/index.ts @@ -3,28 +3,23 @@ import $devtools from "./devtools/index.js"; import $quickaction from "./quick-action/index.js"; import $recording from "./recording/index.js"; import $script from "./script/index.js"; -import type { CommonYargsOptions } from "#lib/cli-types.js"; /** * browser-run command * @generated from apis/overlays/browser-run.ts */ -import type { CommandModule } from "yargs"; +import { apiGroup } from "#lib/api-command.js"; -const command: CommandModule = { +const command = apiGroup({ command: "browser-run", describe: "browser-run", - builder: (yargs) => { - return yargs - .command($crawl) - .command($devtools) - .command($quickaction) - .command($recording) - .command($script) - .demandCommand(1, "Please specify a subcommand"); + routes: { + crawl: $crawl, + devtools: $devtools, + "quick-action": $quickaction, + recording: $recording, + script: $script, }, - - handler: () => {}, -}; +}); export default command; diff --git a/packages/cli/src/commands/_generated/browser-run/quick-action/accessibility-tree.ts b/packages/cli/src/commands/_generated/browser-run/quick-action/accessibility-tree.ts index a1d203137f..a1b1d2833f 100644 --- a/packages/cli/src/commands/_generated/browser-run/quick-action/accessibility-tree.ts +++ b/packages/cli/src/commands/_generated/browser-run/quick-action/accessibility-tree.ts @@ -1,11 +1,10 @@ import operation from "../../_operations/browser-run/quick-action/accessibility-tree.js"; -import type { CommonYargsOptions, InferArgs } from "#lib/cli-types.js"; -import type { ArgClassification } from "#lib/telemetry/index.js"; /** * accessibility-tree command * @generated from apis/overlays/browser-run.ts */ -import type { Argv, CommandModule } from "yargs"; +import type { ArgClassification } from "#lib/telemetry/index.js"; +import { apiCommand } from "#lib/api-command.js"; import { createCommandClient, getAccountId, @@ -24,176 +23,244 @@ import { formatOutput } from "#lib/output.js"; import { withProgress } from "#lib/progress.js"; import { runWithTelemetry } from "#lib/telemetry/index.js"; -function builder(yargs: Argv) { - return yargs - .usage( - "$0 browser-run quick-action accessibility-tree\n\nReturns the page's accessibility tree. Use `interestingOnly` to only return semantically meaningful nodes; use `root` to scope the tree to a CSS-selector-anchored subtree. Control page loading with `gotoOptions` and `waitFor*` options." - ) - .option("cache-ttl", { - type: "number", - description: "Cache TTL default is 5s. Set to 0 to disable.", - }) - .option("browser", { - type: "string", - description: - "Rendering backend. Set to `kitesurf` to use Kitesurf (beta).", - choices: ["kitesurf"], - }) - .option("action-timeout", { - type: "number", - description: +const command = apiCommand({ + command: "accessibility-tree", + describe: "Get accessibility tree page", + usage: + "$0 browser-run quick-action accessibility-tree\n\nReturns the page's accessibility tree. Use `interestingOnly` to only return semantically meaningful nodes; use `root` to scope the tree to a CSS-selector-anchored subtree. Control page loading with `gotoOptions` and `waitFor*` options.", + flags: { + "cache-ttl": { + kind: "parsed", + brief: "Cache TTL default is 5s. Set to 0 to disable.", + optional: true, + parse: Number, + }, + browser: { + kind: "enum", + brief: "Rendering backend. Set to `kitesurf` to use Kitesurf (beta).", + values: ["kitesurf"], + optional: true, + }, + "action-timeout": { + kind: "parsed", + brief: "The maximum duration allowed for the browser action to complete after the page has loaded (such as taking screenshots, extracting content, or generating PDFs). If this time limit is exceeded, the action stops and returns a timeout error.", - }) - .option("add-script-tag", { - type: "string", - description: + optional: true, + parse: Number, + }, + "add-script-tag": { + kind: "parsed", + brief: 'Adds a script element into the page with the desired URL or content. Provide as a JSON array of objects or @path/to/file.json. Shape: [{"content"?: string, "id"?: string, "type"?: string, "url"?: string}]. ? marks optional keys.', - }) - .option("add-style-tag", { - type: "string", - description: + optional: true, + parse: String, + }, + "add-style-tag": { + kind: "parsed", + brief: 'Adds a `` tag into the page with the desired URL or a `