@sap/cli-core
Version:
Command-Line Interface (CLI) Core Module
220 lines (219 loc) • 5.83 kB
TypeScript
import { Method as HTTPMethod, AxiosRequestConfig as HTTPConfig, AxiosResponse as HTTPResponse } from "axios";
import { Command as CommandType } from "commander";
export type Secret = {
id: number;
tenantUrl: string;
customClient: boolean;
client_id: string;
client_secret: string;
access_token: string;
expires_in: number;
expires_after: number;
refresh_token: string;
token_url: string;
authorization_url: string;
token_type: string;
jti: string;
scope: string;
id_token: string;
authorization_flow: GrantType;
};
export declare const ALLOWED_SECRET_TYPES: string[];
export type { HTTPMethod, HTTPConfig, HTTPResponse };
export type In = "query" | "body" | "header" | "path";
export type DataType = "boolean" | "string" | "number";
export type ParameterMapping = {
name: string;
in: In;
source: {
type: "option";
name: string;
dataType: DataType;
} | {
type: "value";
value: any;
};
};
export type ParameterMappings = Array<ParameterMapping>;
export declare enum LogLevel {
INACTIVE = 1,
ERROR = 2,
WARN = 3,
INFO = 4,
DEBUG = 5,
TRACE = 6
}
export type JSONOneOf<T> = {
oneOf: Array<T | JSONReference>;
};
export type JSONObject = {
type: "object";
description?: string;
properties: {
[key: string]: JSONSchema;
};
required?: Array<string>;
};
export type JSONSimpleType = {
type: DataType;
description?: string;
enum?: Array<boolean | string | number>;
default?: boolean | string | number;
};
export type JSONReference = {
$ref: string;
};
// @ts-expect-error Type alias 'Schema' circularly references itself.ts(2456)
export type JSONSchema = JSONObject | JSONSimpleType | JSONReference | JSONOneOf<JSONSchema>;
export type Parameter = {
name: string;
in: In;
description: string;
required?: boolean;
allowEmptyValue?: boolean;
schema: JSONSchema;
};
export type Operation = {
operationId: string;
parameters?: Array<JSONReference | Parameter>;
summary?: string;
description?: string;
deprecated?: boolean;
"x-deprecation-new-command"?: string;
"x-deprecated-with-wave"?: string;
"x-decommissioned-after-wave"?: string;
"x-deprecation-sap-help-url"?: string;
"x-requestbody-fileonly"?: boolean;
"x-user-to-confirm"?: string;
"x-read-path"?: string;
requestBody?: {
description: string;
content: {
[contentType: string]: {
schema: JSONSchema | JSONReference;
};
};
required?: boolean;
};
responses?: {
[httpStatusCode: number]: unknown;
};
};
export type HTTPMethodPath = {
[method in HTTPMethod]?: Operation;
};
export type Parameters = Array<Parameter | JSONReference>;
export type ParameterPath = {
parameters?: Parameters;
};
export type Discovery = {
openapi: string;
info: {
["x-document-version"]: string;
version: string;
};
tags: Array<{
name: string;
description: string;
}>;
paths: {
[path: string]: HTTPMethodPath | ParameterPath;
};
components?: {
parameters?: {
[parameter: string]: Parameter;
};
schemas?: {
[schema: string]: JSONSchema;
};
};
};
export declare const CHARACTERS: string[];
export type PackageJson = {
name: string;
description: string;
version: string;
bin?: {
[key: string]: string;
};
engines: {
node: string;
};
};
export type DiscoveryMetadata = {
tenant: string;
addedAt: number;
hash: string;
};
export type KeyValuePair = {
[key: string]: any;
};
export type DefaultFunction = () => Promise<string>;
export type ChoicesFunction = () => Promise<Array<string>>;
export type Choices = Array<string>;
export type Option = {
longName: string;
description: string;
default?: string | DefaultFunction;
required?: boolean;
choices?: Choices | ChoicesFunction;
args?: Array<{
name: string;
optional?: boolean;
}>;
hidden?: boolean;
prompts?: {
initial?: any;
message: string | (() => string);
type: "confirm" | "text" | "password" | "multiselect" | "number" | "select";
inputValidator?: (value: any) => boolean;
};
};
export type HandlerProps = {
command: string;
args: KeyValuePair;
options: KeyValuePair;
};
export type CommanderHandler = (...args: any[]) => void | Promise<void>;
export type Handler = (command: CommandType) => Promise<CommanderHandler>;
export type CommandsArgument = {
argument: string;
description: string;
};
export type TopCommand = {
type: "topCommand";
command: string;
description: string;
subCommands: Array<Command>;
options?: Array<Option>;
};
export type LeafCommand = {
type: "command";
command: string;
description: string;
options?: Array<Option>;
deprecationInfo?: {
deprecated: boolean;
newCommand?: string;
deprecatedWithWave?: string;
decommissionedAfterWave?: string;
sapHelpUrl?: string;
};
args?: Array<CommandsArgument>;
handler: Handler;
};
export type DeprecatedProperties = Array<{
name: string;
deprecatedWithWave?: string;
decommissionedAfterWave?: string;
sapHelpUrl?: string;
customMessage?: string;
}>;
export type Command = TopCommand | LeafCommand;
export type AddCommands = (program: CommandType) => Promise<void>;
export type ResponsePostProcessor = (response: HTTPResponse) => Promise<void>;
export declare enum GrantType {
authorization_code = "authorization_code",
client_credentials = "client_credentials",
refresh_token = "refresh_token"
}