UNPKG

@swell/cli

Version:

Swell's command line interface/utility

59 lines (58 loc) 1.94 kB
export interface InspectScope { /** Undefined when scope is global (no app filter applied). */ appId?: string; /** Present whenever appId is present; used for section headers and detail lookups. */ appSlug?: string; /** Query fragment merged into list requests. Empty object when global. */ query: Record<string, any>; } export interface ResolveScopeContext { resolveAppId: (appIdOrSlug: string) => Promise<string>; readCurrentAppSlug: () => Promise<string | undefined>; } export declare class ScopeError extends Error { constructor(message: string); } /** * Resolve the scope of an `inspect` subcommand. * * Grammar: * (no --app) → global listing, no filter * --app=<slug> → filter by the named app * --app=. → filter by the app in the current directory's swell.json * * The `.` sentinel is the only place swell.json influences behavior; the * default is always global so the same invocation produces the same output * regardless of cwd. */ export declare function resolveInspectScope(ctx: ResolveScopeContext, flags?: { app?: string; }): Promise<InspectScope>; export type IdentifierKind = { id: string; kind: 'id'; } | { appPart: string; kind: 'slug'; name: string; } | { kind: 'name'; name: string; } | { input: string; kind: 'invalid'; }; /** * Classify an inspect-subcommand identifier argument. * * - `id`: 24-char hex (Mongo ObjectId) * - `slug`: dotted form `app.<appPart>.<name>` where appPart can be either * an ObjectId or a public/private app slug * - `name`: bare identifier (letters, digits, hyphen, underscore) — * requires app context to resolve * * Resources whose stored ids are non-hex dotted strings (notifications) * handle dispatch in their own `showDetail` override; the base classifier * stays narrow. */ export declare function classifyIdentifier(identifier: string): IdentifierKind;