@nebulaos/cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +298 -0
- package/dist/bin/nebulaos.js +2629 -0
- package/dist/bin/nebulaos.js.map +1 -0
- package/dist/index.d.ts +117 -0
- package/dist/index.js +2752 -0
- package/dist/index.js.map +1 -0
- package/package.json +59 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { AxiosInstance } from 'axios';
|
|
3
|
+
|
|
4
|
+
declare function createProgram(): Command;
|
|
5
|
+
|
|
6
|
+
declare function getApiClient(): AxiosInstance;
|
|
7
|
+
declare function resetApiClient(): void;
|
|
8
|
+
|
|
9
|
+
interface ContextConfig {
|
|
10
|
+
name: string;
|
|
11
|
+
apiUrl: string;
|
|
12
|
+
token: string;
|
|
13
|
+
organizationId?: string;
|
|
14
|
+
}
|
|
15
|
+
interface CLIConfig {
|
|
16
|
+
contexts: Record<string, ContextConfig>;
|
|
17
|
+
currentContext: string | null;
|
|
18
|
+
defaults: {
|
|
19
|
+
output: "table" | "json" | "yaml" | "quiet";
|
|
20
|
+
pageSize: number;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
declare function getConfig(): CLIConfig;
|
|
24
|
+
declare function getCurrentContext(): ContextConfig;
|
|
25
|
+
declare function setContext(name: string, context: ContextConfig): void;
|
|
26
|
+
declare function removeContext(name: string): void;
|
|
27
|
+
declare function useContext(name: string): void;
|
|
28
|
+
declare function listContexts(): Array<ContextConfig & {
|
|
29
|
+
active: boolean;
|
|
30
|
+
}>;
|
|
31
|
+
declare function setDefault<K extends keyof CLIConfig["defaults"]>(key: K, value: CLIConfig["defaults"][K]): void;
|
|
32
|
+
declare function getConfigPath(): string;
|
|
33
|
+
|
|
34
|
+
type OutputFormat = "table" | "json" | "yaml" | "quiet";
|
|
35
|
+
declare function resolveFormat(flagValue?: string): OutputFormat;
|
|
36
|
+
interface TableOptions {
|
|
37
|
+
headers: string[];
|
|
38
|
+
rows: string[][];
|
|
39
|
+
}
|
|
40
|
+
declare function printTable({ headers, rows }: TableOptions): void;
|
|
41
|
+
declare function printJson(data: unknown): void;
|
|
42
|
+
declare function printYaml(data: unknown): void;
|
|
43
|
+
declare function printQuiet(ids: string[]): void;
|
|
44
|
+
interface OutputData {
|
|
45
|
+
table: TableOptions;
|
|
46
|
+
data: unknown;
|
|
47
|
+
ids: string[];
|
|
48
|
+
}
|
|
49
|
+
declare function output(format: OutputFormat, outputData: OutputData): void;
|
|
50
|
+
declare function printSuccess(message: string): void;
|
|
51
|
+
declare function printWarning(message: string): void;
|
|
52
|
+
declare function printDetail(label: string, value: string): void;
|
|
53
|
+
|
|
54
|
+
declare enum ExitCode {
|
|
55
|
+
Success = 0,
|
|
56
|
+
GeneralError = 1,
|
|
57
|
+
InvalidArgument = 2,
|
|
58
|
+
AuthenticationError = 3,
|
|
59
|
+
AuthorizationError = 4,
|
|
60
|
+
NotFound = 5,
|
|
61
|
+
ConflictError = 6,
|
|
62
|
+
ValidationError = 7,
|
|
63
|
+
NetworkError = 8,
|
|
64
|
+
TimeoutError = 9,
|
|
65
|
+
ServerError = 10,
|
|
66
|
+
ConfigError = 11
|
|
67
|
+
}
|
|
68
|
+
declare class CLIError extends Error {
|
|
69
|
+
readonly exitCode: ExitCode;
|
|
70
|
+
readonly hint?: string | undefined;
|
|
71
|
+
constructor(message: string, exitCode?: ExitCode, hint?: string | undefined);
|
|
72
|
+
}
|
|
73
|
+
declare class AuthenticationError extends CLIError {
|
|
74
|
+
constructor(message?: string);
|
|
75
|
+
}
|
|
76
|
+
declare class AuthorizationError extends CLIError {
|
|
77
|
+
constructor(message?: string);
|
|
78
|
+
}
|
|
79
|
+
declare class NotFoundError extends CLIError {
|
|
80
|
+
constructor(resource: string, identifier: string);
|
|
81
|
+
}
|
|
82
|
+
declare class ValidationError extends CLIError {
|
|
83
|
+
constructor(message: string);
|
|
84
|
+
}
|
|
85
|
+
declare class NetworkError extends CLIError {
|
|
86
|
+
constructor(message?: string);
|
|
87
|
+
}
|
|
88
|
+
declare class ConfigError extends CLIError {
|
|
89
|
+
constructor(message: string);
|
|
90
|
+
}
|
|
91
|
+
declare function handleError(error: unknown): never;
|
|
92
|
+
|
|
93
|
+
interface PaginationMeta {
|
|
94
|
+
page: number;
|
|
95
|
+
pageSize: number;
|
|
96
|
+
total: number;
|
|
97
|
+
totalPages: number;
|
|
98
|
+
}
|
|
99
|
+
declare function printPaginationInfo(meta: PaginationMeta): void;
|
|
100
|
+
declare function buildPaginationParams(options: {
|
|
101
|
+
page?: number;
|
|
102
|
+
pageSize?: number;
|
|
103
|
+
}): Record<string, number>;
|
|
104
|
+
|
|
105
|
+
declare function truncate(text: string | null | undefined, maxLength?: number, type?: string): string;
|
|
106
|
+
declare function truncateId(id: string): string;
|
|
107
|
+
declare function formatDate(date: string | null | undefined): string;
|
|
108
|
+
|
|
109
|
+
declare function addGlobalFlags(program: Command): Command;
|
|
110
|
+
declare function addPaginationFlags(command: Command): Command;
|
|
111
|
+
|
|
112
|
+
declare function withAuth<T>(fn: (context: ContextConfig) => Promise<T>): () => Promise<T>;
|
|
113
|
+
declare function requireAuth(): ContextConfig;
|
|
114
|
+
|
|
115
|
+
declare function createAuthCommand(): Command;
|
|
116
|
+
|
|
117
|
+
export { AuthenticationError, AuthorizationError, type CLIConfig, CLIError, ConfigError, type ContextConfig, ExitCode, NetworkError, NotFoundError, type OutputData, type OutputFormat, type PaginationMeta, type TableOptions, ValidationError, addGlobalFlags, addPaginationFlags, buildPaginationParams, createAuthCommand, createProgram, formatDate, getApiClient, getConfig, getConfigPath, getCurrentContext, handleError, listContexts, output, printDetail, printJson, printPaginationInfo, printQuiet, printSuccess, printTable, printWarning, printYaml, removeContext, requireAuth, resetApiClient, resolveFormat, setContext, setDefault, truncate, truncateId, useContext, withAuth };
|