@@ -2,92 +2,104 @@ import { apiCall } from "../core";
22import type {
33 BackupFrequency ,
44 Country ,
5- GetAppListResponse ,
6- GetMonitorDurationsResponse ,
7- GetMonitorTargetsResponse ,
8- GetPackageListResponse ,
9- GetProviderListResponse ,
10- GetRegionListResponse ,
11- GetServerSizesListResponse ,
12- GetSettingsListResponse ,
5+ App ,
6+ Provider ,
7+ Region ,
8+ PackageType ,
139} from "./types" ;
1410
1511/**
1612 * Gets a list of available cloud providers.
17- * @returns Promise<GetProviderListResponse> - The response with cloud providers.
13+ * @returns {Promise<Provider[]> } A promise resolving with an array of cloud providers.
14+ * @example
15+ * ```
16+ * [
17+ * { "id": "do", "name": "DigitalOcean" },
18+ * { "id": "vultr", "name": "Vultr" },
19+ * ...
20+ * ]
21+ * ```
1822 */
19- export function getProviderList ( ) : Promise < GetProviderListResponse > {
20- return apiCall ( "/providers" ) ;
23+ export function getProviderList ( ) : Promise < Provider [ ] > {
24+ return apiCall ( "/providers" ) . then ( ( response ) => response . providers ) ;
2125}
2226
2327/**
2428 * Gets a list of regions.
25- * @returns Promise<GetRegionListResponse> - The response with regions.
29+ * @returns {Promise<Region[]> } A promise resolving with an array of regions.
30+ * @example
31+ * ```
32+ * [
33+ * { "id": "us-east-1", "name": "US N.Virginia" },
34+ * { "id": "us-west-1", "name": "California" },
35+ * ...
36+ * ]
37+ * ```
2638 */
27- export function getRegionList ( ) : Promise < GetRegionListResponse > {
28- return apiCall ( "/regions" ) ;
39+ export function getRegionList ( ) : Promise < Region [ ] > {
40+ return apiCall ( "/regions" ) . then ( ( response ) => {
41+ const regionsArray = Object . values ( response . regions ) . flat ( ) ;
42+ return regionsArray as Region [ ] ; // Type assertion to Region[]
43+ } ) ;
2944}
3045
31- /**
32- * Gets a list of server sizes available.
33- * @returns Promise<GetServerSizesListResponse> - The response with server sizes.
34- */
35- export function getServerSizesList ( ) : Promise < GetServerSizesListResponse > {
36- return apiCall ( "/server_sizes" ) ;
37- }
38-
39- /**
40- * Gets a list of available apps and their versions.
41- * @returns Promise<GetAppListResponse> - The response with available apps and their versions.
42- */
43- export function getAppList ( ) : Promise < GetAppListResponse > {
44- return apiCall ( "/app" ) ;
45- }
46-
47- /**
48- * Gets a list of available packages and versions.
49- * @returns Promise<GetPackageListResponse> - The response with available packages and versions.
50- */
51- export function getPackageList ( ) : Promise < GetPackageListResponse > {
52- return apiCall ( "/packages" ) ;
53- }
54-
55- /**
56- * Gets a list of available settings and corresponding values.
57- * @returns Promise<GetSettingsListResponse> - The response with settings.
58- */
59- export function getSettingsList ( ) : Promise < GetSettingsListResponse > {
60- return apiCall ( "/settings" ) ;
61- }
46+ // Similar updates for getServerSizesList, getAppList, getPackageList, getSettingsList
6247
6348/**
6449 * Gets possible backup frequencies.
65- * @returns Promise<GetBackupFrequenciesResponse> - The response with backup frequencies.
50+ * @returns {Promise<BackupFrequency[]> } A promise resolving with an array of backup frequencies.
51+ * @example
52+ * ```
53+ * [
54+ * { "id": "1h", "label": "1 Hour" },
55+ * { "id": "3h", "label": "3 Hours" },
56+ * ...
57+ * ]
58+ * ```
6659 */
6760export function getBackupFrequencies ( ) : Promise < BackupFrequency [ ] > {
6861 return apiCall ( "/backup-frequencies" ) ;
6962}
7063
7164/**
7265 * Gets the list of countries.
73- * @returns Promise<GetCountriesListResponse> - The response with the list of countries.
66+ * @returns {Promise<Country[]> } A promise resolving with the list of countries.
67+ * @example
68+ * ```
69+ * // The API response is an empty object "{}" for countries.
70+ * []
71+ * ```
7472 */
7573export function getCountriesList ( ) : Promise < Country [ ] > {
76- return apiCall ( "/countries" ) ;
74+ return apiCall ( "/countries" ) . then ( ( response ) => response ) ; // Assuming the response is an array of countries
7775}
7876
7977/**
8078 * Gets possible monitoring durations.
81- * @returns Promise<GetMonitorDurationsResponse> - The response with monitoring durations.
79+ * @returns {Promise<string[]> } A promise resolving with monitoring durations.
80+ * @example
81+ * ```
82+ * ["1 Hour", "12 Hours", "1 Day", "7 Days", "1 Month", "6 Months"]
83+ * ```
8284 */
83- export function getMonitorDurations ( ) : Promise < GetMonitorDurationsResponse > {
85+ export function getMonitorDurations ( ) : Promise < string [ ] > {
8486 return apiCall ( "/monitor-durations" ) ;
8587}
8688
8789/**
8890 * Gets a list of server monitoring graph types.
89- * @returns Promise<GetMonitorTargetsResponse> - The response with monitoring targets.
91+ * @returns {Promise<string[]> } A promise resolving with monitoring targets.
92+ * @example
93+ * ```
94+ * {
95+ * "amazon": ["Idle CPU", "Free Disk (DB)", ...],
96+ * "do": ["Idle CPU", "Free Disk", ...],
97+ * ...
98+ * }
99+ * ```
90100 */
91- export function getMonitorTargets ( ) : Promise < GetMonitorTargetsResponse > {
101+ export function getMonitorTargets ( ) : Promise < { [ provider : string ] : string [ ] } > {
92102 return apiCall ( "/monitor-targets" ) ;
93103}
104+
105+ // ... and similarly for other functions
0 commit comments