@vigilbase/cli
Version:
Vigilbase CLI — security scanners, agent tools, and Vigilbase One from the terminal.
99 lines (98 loc) • 3.31 kB
TypeScript
import type { CliConfigLegacy } from '../lib/config.js';
import type { Writer } from '../lib/format.js';
import type { CliOutputMode, ExitCode } from '../types.js';
import type { VigilbaseClient } from '../lib/client.js';
import type { VigilbaseOneClient } from '../lib/one-client.js';
import { EXIT } from '../types.js';
export type ParsedCliValues = {
isJson?: boolean;
isHelp?: boolean;
isVersion?: boolean;
'base-url'?: string;
'one-url'?: string;
'auth-url'?: string;
'client-id'?: string;
timeout?: string;
style?: string;
isNoSkill?: boolean;
via?: string;
isPublic?: boolean;
token?: string;
isTokenStdin?: boolean;
isNoOpen?: boolean;
email?: string;
role?: string;
isConfirm?: boolean;
'account-id'?: string;
tool?: string;
limit?: string;
'target-id'?: string;
'customer-id'?: string;
'zone-id'?: string;
'days'?: string;
'offset'?: string;
'status'?: string;
'severity'?: string;
'attack-category'?: string;
'order-by'?: string;
'order-direction'?: string;
'asset-id'?: string;
'provider'?: string;
'dataset'?: string;
'search'?: string;
'start'?: string;
'end'?: string;
'sort'?: string;
'frs-min'?: string;
'before'?: string;
'note'?: string;
'cursor'?: string;
'action-prefix'?: string;
'outcome'?: string;
'hours'?: string;
'metrics'?: string;
'min-weight'?: string;
'range'?: string;
'region'?: string;
'issue-id'?: string;
'revision'?: string;
isAll?: boolean;
isLight?: boolean;
profile?: string;
'cf-auth'?: string;
'cf-bin'?: string;
out?: string;
isOverwrite?: boolean;
isDryRun?: boolean;
'max-requests-per-5min'?: string;
isYes?: boolean;
};
export type CommandContext = {
command: string;
rest: string[];
values: ParsedCliValues;
mode: CliOutputMode;
config: CliConfigLegacy;
writer: Writer;
publicClient: VigilbaseClient;
env: NodeJS.ProcessEnv;
stdin?: NodeJS.ReadableStream;
/** Raw stdout, only to tell whether it is a terminal; text output still goes through `writer`. */
stdoutStream?: NodeJS.WritableStream & {
isTTY?: boolean;
};
/** Raw stderr for prompts that must not end in a newline; text output still goes through `writer`. */
stderrStream?: NodeJS.WritableStream;
loginHandler?: (config: CliConfigLegacy) => Promise<ExitCode>;
};
export type CommandHandler = (ctx: CommandContext) => Promise<ExitCode>;
/** Reject known flags from other command groups instead of silently ignoring filters. */
export declare function assertCommandFlags(ctx: CommandContext, allowed: readonly string[]): void;
export declare function outputJson(ctx: CommandContext, value: unknown): void;
export declare function outputLines(ctx: CommandContext, lines: string[]): void;
export declare function asRecord(value: unknown): Record<string, unknown> | null;
export declare function asArray(value: unknown): unknown[];
export declare function requireOneClient(ctx: CommandContext): Promise<VigilbaseOneClient>;
export declare function withSpinner<T>(ctx: CommandContext, label: string, work: () => Promise<T>): Promise<T>;
export declare function ok(): ExitCode;
export { EXIT };