Skip to content

Commit cf97587

Browse files
committed
added core and list services
1 parent 0bb1733 commit cf97587

File tree

9 files changed

+493
-7
lines changed

9 files changed

+493
-7
lines changed

.changeset/curvy-tigers-drum.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"cloudways-js-client": patch
3+
---
4+
5+
added the core and list services to the package

build.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const { execSync } = require("child_process");
2+
const fs = require("fs");
3+
const path = require("path");
4+
5+
const servicesPath = path.join(__dirname, "services");
6+
const modules = fs.readdirSync(servicesPath);
7+
8+
modules.forEach((module) => {
9+
const modulePath = path.join(servicesPath, module);
10+
if (fs.statSync(modulePath).isDirectory()) {
11+
console.log(`Building module: ${module}`);
12+
execSync(
13+
`tsup ${path.join(
14+
modulePath,
15+
"index.ts"
16+
)} --format cjs,esm --dts --outDir ${path.join("dist", module)}`,
17+
{ stdio: "inherit" }
18+
);
19+
}
20+
});

index.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

package-lock.json

Lines changed: 93 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,20 @@
66
},
77
"version": "0.0.27",
88
"description": "A client library to power your applications with Cloudways API",
9-
"main": "dist/index.js",
10-
"module": "dist/index.mjs",
11-
"types": "dist/index.d.ts",
9+
"exports": {
10+
"./core": {
11+
"require": "./dist/core/index.js",
12+
"import": "./dist/core/index.mjs",
13+
"types": "./dist/core/index.d.ts"
14+
},
15+
"./lists": {
16+
"require": "./dist/lists/index.js",
17+
"import": "./dist/lists/index.mjs",
18+
"types": "./dist/lists/index.d.ts"
19+
}
20+
},
1221
"scripts": {
13-
"build": "tsup index.ts --format cjs,esm --dts",
22+
"build": "node build.js",
1423
"release": "pnpm run build && changeset publish",
1524
"lint": "tsc"
1625
},
@@ -28,5 +37,8 @@
2837
"@changesets/cli": "^2.27.1",
2938
"tsup": "^8.0.1",
3039
"typescript": "^5.3.3"
40+
},
41+
"dependencies": {
42+
"axios": "^1.6.3"
3143
}
3244
}

services/Lists/index.ts

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import { apiCall } from "../core";
2+
import type {
3+
BackupFrequency,
4+
Country,
5+
GetAppListResponse,
6+
GetMonitorDurationsResponse,
7+
GetMonitorTargetsResponse,
8+
GetPackageListResponse,
9+
GetProviderListResponse,
10+
GetRegionListResponse,
11+
GetServerSizesListResponse,
12+
GetSettingsListResponse,
13+
} from "./types";
14+
15+
/**
16+
* Gets a list of available cloud providers.
17+
* @returns Promise<GetProviderListResponse> - The response with cloud providers.
18+
*/
19+
export function getProviderList(): Promise<GetProviderListResponse> {
20+
return apiCall("/providers");
21+
}
22+
23+
/**
24+
* Gets a list of regions.
25+
* @returns Promise<GetRegionListResponse> - The response with regions.
26+
*/
27+
export function getRegionList(): Promise<GetRegionListResponse> {
28+
return apiCall("/regions");
29+
}
30+
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+
}
62+
63+
/**
64+
* Gets possible backup frequencies.
65+
* @returns Promise<GetBackupFrequenciesResponse> - The response with backup frequencies.
66+
*/
67+
export function getBackupFrequencies(): Promise<BackupFrequency[]> {
68+
return apiCall("/backup-frequencies");
69+
}
70+
71+
/**
72+
* Gets the list of countries.
73+
* @returns Promise<GetCountriesListResponse> - The response with the list of countries.
74+
*/
75+
export function getCountriesList(): Promise<Country[]> {
76+
return apiCall("/countries");
77+
}
78+
79+
/**
80+
* Gets possible monitoring durations.
81+
* @returns Promise<GetMonitorDurationsResponse> - The response with monitoring durations.
82+
*/
83+
export function getMonitorDurations(): Promise<GetMonitorDurationsResponse> {
84+
return apiCall("/monitor-durations");
85+
}
86+
87+
/**
88+
* Gets a list of server monitoring graph types.
89+
* @returns Promise<GetMonitorTargetsResponse> - The response with monitoring targets.
90+
*/
91+
export function getMonitorTargets(): Promise<GetMonitorTargetsResponse> {
92+
return apiCall("/monitor-targets");
93+
}

0 commit comments

Comments
 (0)