@swell/cli
Version:
Swell's command line interface/utility
95 lines (94 loc) • 4.83 kB
TypeScript
import { InspectScope } from './lib/apps/inspect-scope.js';
import { GroupInfo } from './lib/inspect/table.js';
import { SwellCommand } from './swell-command.js';
export declare const inspectResourceBaseArgs: {
identifier: import("@oclif/core/lib/interfaces/parser.js").Arg<string | undefined, Record<string, unknown>>;
};
export declare const inspectResourceBaseFlags: {
app: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
live: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
json: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
yes: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
};
export interface InspectResourceCommandParsed {
args: {
identifier?: string;
};
flags: {
app?: string;
json?: boolean;
live?: boolean;
yes?: boolean;
};
}
export declare abstract class InspectResourceCommand extends SwellCommand {
/** Plural label for preamble + empty state, e.g. 'Webhooks'. */
protected abstract resourceLabel: string;
/** Singular label for error messages, e.g. 'webhook'. */
protected abstract resourceLabelSingular: string;
/** Admin path prefix, e.g. '/data/:webhooks'. */
protected abstract adminPath: string;
/** Subcommand name as used in CLI, e.g. 'webhooks'. */
protected abstract commandName: string;
/**
* Record field used to look up a bare-name identifier. Defaults to 'name';
* override for resources that identify records by a different key
* (e.g. webhooks use 'alias').
*/
protected nameField: string;
/**
* Return the strict paste-back identifier for a record. Used as column 1
* content so every row is individually pasteable back into a detail query.
*
* Default implementation:
* - no `app_id` → `record.id` (store-level records have no app-slug form)
* - no name/alias → `record.id` (degenerate, no meaningful slug)
* - otherwise → `app.<slug>.<name>`, using the raw hex when the slug map
* has no entry (still pasteable via the hex appPart branch)
*/
protected keyFor(record: any, appSlugById: Record<string, string>): string;
/**
* Optional compact meta rendered after the key. Only non-default state
* should surface — enabled rows with no failures return undefined so the
* listing stays to one key per line.
*/
protected metaFor(_record: any, _appSlugById: Record<string, string>): string | undefined;
/**
* Post-process raw list results before rendering. Default is identity;
* override to drop noise that the API returns unconditionally (e.g.
* deprecated system records that have no server-side filter equivalent).
* Detail-mode lookups bypass this hook.
*/
protected filterListResults<T>(results: T[]): T[];
/**
* Return the section grouping for a list record in global mode. Override
* to change labels (e.g. content treats no-app_id rows as `<custom>`).
*/
protected groupForRecord(record: any, appSlugById: Record<string, string>): GroupInfo;
protected catch(error: Error): Promise<any>;
protected runInspect(parsed: InspectResourceCommandParsed): Promise<void>;
protected showList(scope: InspectScope, flags: InspectResourceCommandParsed['flags']): Promise<void>;
protected getListResults(scope: InspectScope, _flags: InspectResourceCommandParsed['flags']): Promise<any[]>;
protected getAppSlugById(scope: InspectScope): Promise<Record<string, string>>;
protected afterList(_scope: InspectScope, _flags: InspectResourceCommandParsed['flags']): void;
protected showDetail(identifier: string, scope: InspectScope, flags: InspectResourceCommandParsed['flags']): Promise<void>;
/**
* Per-subclass detail-mode hints. Return runnable commands pointing to
* runtime/sibling addresses for the inspected record. Interpolated values
* must derive from the record's own fields, not constants — that keeps the
* hint self-consistent with column 1 and absorbs platform-side renames.
* Default is no hints.
*/
protected hints(_record: any): string[];
/**
* Emit a fetched detail record. Prints JSON unconditionally; in non-`--json`
* mode follows with a `Next steps:` block of `hints(record)` lines.
*
* `--json` is the machine-readable contract — hints belong in the same
* stream as the human-facing output and are simply omitted there.
*/
protected emitDetail(record: any, flags: InspectResourceCommandParsed['flags']): void;
private lookupByAppAndName;
private printPreamble;
protected throwNotFound(identifier: string): never;
}