virtualizorjs 1.0.4 → 2.0.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/dist/index.mjs ADDED
@@ -0,0 +1,262 @@
1
+ import http from 'http';
2
+ import https from 'https';
3
+ import crypto from 'crypto';
4
+
5
+ // src/http.ts
6
+ function generateSignature(apiKey, apiPass, params) {
7
+ const sorted = Object.keys(params).filter((k) => params[k] !== void 0).sort().map((k) => `${k}${params[k]}`).join("");
8
+ return crypto.createHash("sha256").update(apiKey + apiPass + sorted).digest("hex");
9
+ }
10
+ function buildQueryString(params, apiKey, apiPass) {
11
+ const clean = {};
12
+ for (const [key, value] of Object.entries(params)) {
13
+ if (value !== void 0) {
14
+ clean[key] = value;
15
+ }
16
+ }
17
+ const sig = generateSignature(apiKey, apiPass, clean);
18
+ const urlParams = new URLSearchParams();
19
+ urlParams.set("api", "json");
20
+ urlParams.set("api_key", apiKey);
21
+ urlParams.set("api_sig", sig);
22
+ for (const [key, value] of Object.entries(clean)) {
23
+ urlParams.set(key, String(value));
24
+ }
25
+ return `?${urlParams.toString()}`;
26
+ }
27
+
28
+ // src/http.ts
29
+ var VirtualizorApiError = class extends Error {
30
+ code;
31
+ constructor(message, code) {
32
+ super(message);
33
+ this.name = "VirtualizorApiError";
34
+ this.code = code;
35
+ }
36
+ };
37
+ var HttpClient = class {
38
+ constructor(config) {
39
+ this.config = config;
40
+ }
41
+ parseResponse(data) {
42
+ if (data.error && data.error.length > 0) {
43
+ const first = data.error[0];
44
+ if (first) {
45
+ throw new VirtualizorApiError(first.msg, first.code);
46
+ }
47
+ }
48
+ return data;
49
+ }
50
+ async request(act, queryParams = {}, bodyParams = {}) {
51
+ const allQueryParams = { act, ...queryParams };
52
+ const qs = buildQueryString(allQueryParams, this.config.apiKey, this.config.apiPass);
53
+ const path = `/index.php${qs}`;
54
+ const bodyString = Object.entries(bodyParams).filter(([, v]) => v !== void 0).map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`).join("&");
55
+ const data = await this.rawRequest(path, bodyString || void 0);
56
+ return this.parseResponse(data);
57
+ }
58
+ rawRequest(path, body) {
59
+ const transport = this.config.https ? https : http;
60
+ const options = {
61
+ host: this.config.host,
62
+ port: this.config.port,
63
+ path,
64
+ method: body ? "POST" : "GET",
65
+ headers: {
66
+ "Content-Type": "application/x-www-form-urlencoded",
67
+ ...body ? { "Content-Length": Buffer.byteLength(body) } : {}
68
+ },
69
+ ...this.config.https ? { agent: new https.Agent({ rejectUnauthorized: this.config.rejectUnauthorized }) } : {}
70
+ };
71
+ return new Promise((resolve, reject) => {
72
+ const req = transport.request(options, (res) => {
73
+ let raw = "";
74
+ res.on("data", (chunk) => {
75
+ raw += chunk.toString();
76
+ });
77
+ res.on("end", () => {
78
+ try {
79
+ resolve(JSON.parse(raw));
80
+ } catch {
81
+ reject(new Error(`Failed to parse response: ${raw.slice(0, 200)}`));
82
+ }
83
+ });
84
+ });
85
+ req.setTimeout(this.config.timeout, () => {
86
+ req.destroy(new Error(`Request timed out after ${this.config.timeout}ms`));
87
+ });
88
+ req.on("error", reject);
89
+ if (body) {
90
+ req.write(body);
91
+ }
92
+ req.end();
93
+ });
94
+ }
95
+ };
96
+
97
+ // src/resources/plans.ts
98
+ var PlansResource = class {
99
+ constructor(http2) {
100
+ this.http = http2;
101
+ }
102
+ async list() {
103
+ const res = await this.http.request("plans", {}, {});
104
+ return res.plans;
105
+ }
106
+ async create(params) {
107
+ return this.http.request("addplan", {}, params);
108
+ }
109
+ async delete(planId) {
110
+ return this.http.request("plans", {}, { delete: planId });
111
+ }
112
+ };
113
+
114
+ // src/resources/tasks.ts
115
+ var TasksResource = class {
116
+ constructor(http2) {
117
+ this.http = http2;
118
+ }
119
+ async get(taskId) {
120
+ const res = await this.http.request("tasks", { taskid: taskId }, {});
121
+ return res.tasks[taskId];
122
+ }
123
+ async wait(taskId, options = {}) {
124
+ const { pollIntervalMs = 2e3, timeoutMs = 12e4 } = options;
125
+ const deadline = Date.now() + timeoutMs;
126
+ while (Date.now() < deadline) {
127
+ const task = await this.get(taskId);
128
+ if (!task) throw new Error(`Task ${taskId} not found`);
129
+ if (task.status === "1" || task.status === "done") return task;
130
+ if (task.status === "error" || task.status === "-1") {
131
+ throw new Error(`Task ${taskId} failed`);
132
+ }
133
+ await new Promise((r) => setTimeout(r, pollIntervalMs));
134
+ }
135
+ throw new Error(`Task ${taskId} timed out after ${timeoutMs}ms`);
136
+ }
137
+ };
138
+
139
+ // src/resources/users.ts
140
+ var UsersResource = class {
141
+ constructor(http2) {
142
+ this.http = http2;
143
+ }
144
+ async list() {
145
+ const res = await this.http.request("users", {}, {});
146
+ return res.users;
147
+ }
148
+ async create(params) {
149
+ return this.http.request("adduser", {}, params);
150
+ }
151
+ async delete(uid) {
152
+ return this.http.request("users", {}, { delete: uid });
153
+ }
154
+ async suspend(uid) {
155
+ return this.http.request("users", {}, { suspend: uid });
156
+ }
157
+ async unsuspend(uid) {
158
+ return this.http.request("users", {}, { unsuspend: uid });
159
+ }
160
+ };
161
+
162
+ // src/resources/vps.ts
163
+ var VpsResource = class {
164
+ constructor(http2) {
165
+ this.http = http2;
166
+ }
167
+ async list(filters = {}) {
168
+ const res = await this.http.request("listvs", {}, filters);
169
+ return res.vs;
170
+ }
171
+ async get(vpsId) {
172
+ const res = await this.http.request("vs", { vpsid: vpsId }, {});
173
+ const vps = res.vs[vpsId];
174
+ if (!vps) throw new Error(`VPS ${vpsId} not found in response`);
175
+ return vps;
176
+ }
177
+ async create(params) {
178
+ return this.http.request("addvs", {}, params);
179
+ }
180
+ async delete(vpsId) {
181
+ return this.http.request("vs", { delete: vpsId }, {});
182
+ }
183
+ async start(vpsId) {
184
+ return this.http.request("vs", { vpsid: vpsId, action: "start" }, {});
185
+ }
186
+ async stop(vpsId) {
187
+ return this.http.request("vs", { vpsid: vpsId, action: "stop" }, {});
188
+ }
189
+ async restart(vpsId) {
190
+ return this.http.request("vs", { vpsid: vpsId, action: "restart" }, {});
191
+ }
192
+ async poweroff(vpsId) {
193
+ return this.http.request("vs", { vpsid: vpsId, action: "poweroff" }, {});
194
+ }
195
+ async suspend(vpsId) {
196
+ return this.http.request("vs", { suspend: vpsId }, {});
197
+ }
198
+ async unsuspend(vpsId) {
199
+ return this.http.request("vs", { unsuspend: vpsId }, {});
200
+ }
201
+ async rebuild(vpsId, params) {
202
+ return this.http.request("rebuild", {}, {
203
+ vpsid: vpsId,
204
+ reos: 1,
205
+ ...params
206
+ });
207
+ }
208
+ async clone(vpsId, params) {
209
+ return this.http.request("clone", {}, {
210
+ vpsid: vpsId,
211
+ ...params
212
+ });
213
+ }
214
+ async migrate(vpsId, params) {
215
+ return this.http.request("migrate", {}, {
216
+ vpsid: vpsId,
217
+ migrate: 1,
218
+ migrate_but: 1,
219
+ ...params
220
+ });
221
+ }
222
+ async status(vpsId) {
223
+ return this.http.request("vstatus", { vpsid: vpsId }, {});
224
+ }
225
+ async vnc(vpsId) {
226
+ return this.http.request("vnc", { vpsid: vpsId }, {});
227
+ }
228
+ async stats(vpsId) {
229
+ return this.http.request("vps_stats", {}, { vpsid: vpsId });
230
+ }
231
+ };
232
+
233
+ // src/client.ts
234
+ var VirtualizorClient = class {
235
+ vps;
236
+ users;
237
+ plans;
238
+ tasks;
239
+ constructor(config) {
240
+ const resolved = {
241
+ host: config.host,
242
+ apiKey: config.apiKey,
243
+ apiPass: config.apiPass ?? "",
244
+ port: config.port ?? 4085,
245
+ https: config.https ?? true,
246
+ rejectUnauthorized: config.rejectUnauthorized ?? false,
247
+ timeout: config.timeout ?? 3e4
248
+ };
249
+ const http2 = new HttpClient(resolved);
250
+ this.vps = new VpsResource(http2);
251
+ this.users = new UsersResource(http2);
252
+ this.plans = new PlansResource(http2);
253
+ this.tasks = new TasksResource(http2);
254
+ }
255
+ };
256
+ function createVirtualizorClient(config) {
257
+ return new VirtualizorClient(config);
258
+ }
259
+
260
+ export { VirtualizorApiError, VirtualizorClient, createVirtualizorClient };
261
+ //# sourceMappingURL=index.mjs.map
262
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/auth.ts","../src/http.ts","../src/resources/plans.ts","../src/resources/tasks.ts","../src/resources/users.ts","../src/resources/vps.ts","../src/client.ts"],"names":["http"],"mappings":";;;;;AAIA,SAAS,iBAAA,CAAkB,MAAA,EAAgB,OAAA,EAAiB,MAAA,EAAwB;AAClF,EAAA,MAAM,MAAA,GAAS,MAAA,CAAO,IAAA,CAAK,MAAM,CAAA,CAC9B,MAAA,CAAO,CAAC,CAAA,KAAM,MAAA,CAAO,CAAC,CAAA,KAAM,MAAS,CAAA,CACrC,IAAA,EAAK,CACL,GAAA,CAAI,CAAC,CAAA,KAAM,CAAA,EAAG,CAAC,CAAA,EAAG,MAAA,CAAO,CAAC,CAAC,CAAA,CAAE,CAAA,CAC7B,IAAA,CAAK,EAAE,CAAA;AACV,EAAA,OAAO,MAAA,CACJ,UAAA,CAAW,QAAQ,CAAA,CACnB,MAAA,CAAO,SAAS,OAAA,GAAU,MAAM,CAAA,CAChC,MAAA,CAAO,KAAK,CAAA;AACjB;AAEO,SAAS,gBAAA,CAAiB,MAAA,EAAgB,MAAA,EAAgB,OAAA,EAAyB;AACxF,EAAA,MAAM,QAAgB,EAAC;AACvB,EAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,MAAM,CAAA,EAAG;AACjD,IAAA,IAAI,UAAU,MAAA,EAAW;AACvB,MAAA,KAAA,CAAM,GAAG,CAAA,GAAI,KAAA;AAAA,IACf;AAAA,EACF;AAEA,EAAA,MAAM,GAAA,GAAM,iBAAA,CAAkB,MAAA,EAAQ,OAAA,EAAS,KAAK,CAAA;AAEpD,EAAA,MAAM,SAAA,GAAY,IAAI,eAAA,EAAgB;AACtC,EAAA,SAAA,CAAU,GAAA,CAAI,OAAO,MAAM,CAAA;AAC3B,EAAA,SAAA,CAAU,GAAA,CAAI,WAAW,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A;AAAA,EAET,YAAY,MAAA,EAA2B;AACrC,IAAA,MAAM,QAAA,GAA2B;AAAA,MAC/B,MAAM,MAAA,CAAO,IAAA;AAAA,MACb,QAAQ,MAAA,CAAO,MAAA;AAAA,MACf,OAAA,EAAS,OAAO,OAAA,IAAW,EAAA;AAAA,MAC3B,IAAA,EAAM,OAAO,IAAA,IAAQ,IAAA;AAAA,MACrB,KAAA,EAAO,OAAO,KAAA,IAAS,IAAA;AAAA,MACvB,kBAAA,EAAoB,OAAO,kBAAA,IAAsB,KAAA;AAAA,MACjD,OAAA,EAAS,OAAO,OAAA,IAAW;AAAA,KAC7B;AACA,IAAA,MAAMA,KAAAA,GAAO,IAAI,UAAA,CAAW,QAAQ,CAAA;AACpC,IAAA,IAAA,CAAK,GAAA,GAAM,IAAI,WAAA,CAAYA,KAAI,CAAA;AAC/B,IAAA,IAAA,CAAK,KAAA,GAAQ,IAAI,aAAA,CAAcA,KAAI,CAAA;AACnC,IAAA,IAAA,CAAK,KAAA,GAAQ,IAAI,aAAA,CAAcA,KAAI,CAAA;AACnC,IAAA,IAAA,CAAK,KAAA,GAAQ,IAAI,aAAA,CAAcA,KAAI,CAAA;AAAA,EACrC;AACF;AAEO,SAAS,wBAAwB,MAAA,EAA8C;AACpF,EAAA,OAAO,IAAI,kBAAkB,MAAM,CAAA;AACrC","file":"index.mjs","sourcesContent":["import crypto from 'node:crypto';\n\ntype Params = Record<string, string | number | undefined>;\n\nfunction generateSignature(apiKey: string, apiPass: string, params: Params): string {\n const sorted = Object.keys(params)\n .filter((k) => params[k] !== undefined)\n .sort()\n .map((k) => `${k}${params[k]}`)\n .join('');\n return crypto\n .createHash('sha256')\n .update(apiKey + apiPass + sorted)\n .digest('hex');\n}\n\nexport function buildQueryString(params: Params, apiKey: string, apiPass: string): string {\n const clean: Params = {};\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n clean[key] = value;\n }\n }\n\n const sig = generateSignature(apiKey, apiPass, clean);\n\n const urlParams = new URLSearchParams();\n urlParams.set('api', 'json');\n urlParams.set('api_key', apiKey);\n urlParams.set('api_sig', sig);\n\n for (const [key, value] of Object.entries(clean)) {\n urlParams.set(key, String(value));\n }\n\n return `?${urlParams.toString()}`;\n}\n","import http from 'node:http';\nimport https from 'node:https';\nimport { buildQueryString } from './auth.js';\nimport type { VirtualizorResponse } from './types/common.js';\nimport type { ResolvedConfig } from './types/config.js';\n\nexport class VirtualizorApiError extends Error {\n readonly code: number;\n\n constructor(message: string, code: number) {\n super(message);\n this.name = 'VirtualizorApiError';\n this.code = code;\n }\n}\n\ntype Params = Record<string, string | number | undefined>;\n\nexport class HttpClient {\n constructor(private readonly config: ResolvedConfig) {}\n\n parseResponse<T extends VirtualizorResponse>(data: T): T {\n if (data.error && data.error.length > 0) {\n const first = data.error[0];\n if (first) {\n throw new VirtualizorApiError(first.msg, first.code);\n }\n }\n return data;\n }\n\n async request<T extends VirtualizorResponse>(\n act: string,\n queryParams: Params = {},\n bodyParams: Params = {},\n ): Promise<T> {\n const allQueryParams: Params = { act, ...queryParams };\n const qs = buildQueryString(allQueryParams, this.config.apiKey, this.config.apiPass);\n\n const path = `/index.php${qs}`;\n\n const bodyString = Object.entries(bodyParams)\n .filter(([, v]) => v !== undefined)\n .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`)\n .join('&');\n\n const data = await this.rawRequest(path, bodyString || undefined);\n return this.parseResponse(data as T);\n }\n\n private rawRequest(path: string, body?: string): Promise<VirtualizorResponse> {\n const transport = this.config.https ? https : http;\n const options: https.RequestOptions = {\n host: this.config.host,\n port: this.config.port,\n path,\n method: body ? 'POST' : 'GET',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n ...(body ? { 'Content-Length': Buffer.byteLength(body) } : {}),\n },\n ...(this.config.https\n ? { agent: new https.Agent({ rejectUnauthorized: this.config.rejectUnauthorized }) }\n : {}),\n };\n\n return new Promise((resolve, reject) => {\n const req = transport.request(options, (res) => {\n let raw = '';\n res.on('data', (chunk: Buffer) => {\n raw += chunk.toString();\n });\n res.on('end', () => {\n try {\n resolve(JSON.parse(raw) as VirtualizorResponse);\n } catch {\n reject(new Error(`Failed to parse response: ${raw.slice(0, 200)}`));\n }\n });\n });\n\n req.setTimeout(this.config.timeout, () => {\n req.destroy(new Error(`Request timed out after ${this.config.timeout}ms`));\n });\n\n req.on('error', reject);\n\n if (body) {\n req.write(body);\n }\n\n req.end();\n });\n }\n}\n","import type { HttpClient } from '../http.js';\nimport type { AsyncTaskResult, VirtualizorResponse } from '../types/common.js';\nimport type { CreatePlanParams, Plan } from '../types/plans.js';\n\ntype Params = Record<string, string | number | undefined>;\n\ninterface ListPlansResponse extends VirtualizorResponse {\n plans: Record<string, Plan>;\n}\nexport class PlansResource {\n constructor(private readonly http: HttpClient) {}\n\n async list(): Promise<Record<string, Plan>> {\n const res = await this.http.request<ListPlansResponse>('plans', {}, {});\n return res.plans;\n }\n\n async create(params: CreatePlanParams): Promise<AsyncTaskResult> {\n return this.http.request<AsyncTaskResult>('addplan', {}, params as unknown as Params);\n }\n\n async delete(planId: string): Promise<AsyncTaskResult> {\n return this.http.request<AsyncTaskResult>('plans', {}, { delete: planId });\n }\n}\n","import type { HttpClient } from '../http.js';\nimport type { VirtualizorResponse } from '../types/common.js';\nimport type { Task } from '../types/tasks.js';\n\ninterface TasksResponse extends VirtualizorResponse {\n tasks: Record<string, Task>;\n}\n\nexport class TasksResource {\n constructor(private readonly http: HttpClient) {}\n\n async get(taskId: string): Promise<Task | undefined> {\n const res = await this.http.request<TasksResponse>('tasks', { taskid: taskId }, {});\n return res.tasks[taskId];\n }\n\n async wait(\n taskId: string,\n options: { pollIntervalMs?: number; timeoutMs?: number } = {},\n ): Promise<Task> {\n const { pollIntervalMs = 2000, timeoutMs = 120000 } = options;\n const deadline = Date.now() + timeoutMs;\n\n while (Date.now() < deadline) {\n const task = await this.get(taskId);\n if (!task) throw new Error(`Task ${taskId} not found`);\n if (task.status === '1' || task.status === 'done') return task;\n if (task.status === 'error' || task.status === '-1') {\n throw new Error(`Task ${taskId} failed`);\n }\n await new Promise((r) => setTimeout(r, pollIntervalMs));\n }\n\n throw new Error(`Task ${taskId} timed out after ${timeoutMs}ms`);\n }\n}\n","import type { HttpClient } from '../http.js';\nimport type { AsyncTaskResult, VirtualizorResponse } from '../types/common.js';\nimport type { CreateUserParams, User } from '../types/users.js';\n\ntype Params = Record<string, string | number | undefined>;\n\ninterface ListUsersResponse extends VirtualizorResponse {\n users: Record<string, User>;\n}\n\nexport class UsersResource {\n constructor(private readonly http: HttpClient) {}\n\n async list(): Promise<Record<string, User>> {\n const res = await this.http.request<ListUsersResponse>('users', {}, {});\n return res.users;\n }\n\n async create(params: CreateUserParams): Promise<AsyncTaskResult> {\n return this.http.request<AsyncTaskResult>('adduser', {}, params as unknown as Params);\n }\n\n async delete(uid: string): Promise<AsyncTaskResult> {\n return this.http.request<AsyncTaskResult>('users', {}, { delete: uid });\n }\n\n async suspend(uid: string): Promise<AsyncTaskResult> {\n return this.http.request<AsyncTaskResult>('users', {}, { suspend: uid });\n }\n\n async unsuspend(uid: string): Promise<AsyncTaskResult> {\n return this.http.request<AsyncTaskResult>('users', {}, { unsuspend: uid });\n }\n}\n","import type { HttpClient } from '../http.js';\nimport type { AsyncTaskResult, VirtualizorResponse } from '../types/common.js';\nimport type {\n CloneVPSParams,\n CreateVPSParams,\n ListVPSParams,\n MigrateVPSParams,\n RebuildVPSParams,\n VNCInfo,\n VPS,\n VPSStatsResponse,\n} from '../types/vps.js';\n\ntype Params = Record<string, string | number | undefined>;\n\ninterface ListVPSResponse extends VirtualizorResponse {\n vs: Record<string, VPS>;\n}\ninterface GetVPSResponse extends VirtualizorResponse {\n vs: Record<string, VPS>;\n}\n\nexport class VpsResource {\n constructor(private readonly http: HttpClient) {}\n\n async list(filters: ListVPSParams = {}): Promise<Record<string, VPS>> {\n const res = await this.http.request<ListVPSResponse>('listvs', {}, filters as Params);\n return res.vs;\n }\n\n async get(vpsId: string): Promise<VPS> {\n const res = await this.http.request<GetVPSResponse>('vs', { vpsid: vpsId }, {});\n const vps = res.vs[vpsId];\n if (!vps) throw new Error(`VPS ${vpsId} not found in response`);\n return vps;\n }\n\n async create(params: CreateVPSParams): Promise<AsyncTaskResult> {\n return this.http.request<AsyncTaskResult>('addvs', {}, params as unknown as Params);\n }\n\n async delete(vpsId: string): Promise<AsyncTaskResult> {\n return this.http.request<AsyncTaskResult>('vs', { delete: vpsId }, {});\n }\n\n async start(vpsId: string): Promise<AsyncTaskResult> {\n return this.http.request<AsyncTaskResult>('vs', { vpsid: vpsId, action: 'start' }, {});\n }\n\n async stop(vpsId: string): Promise<AsyncTaskResult> {\n return this.http.request<AsyncTaskResult>('vs', { vpsid: vpsId, action: 'stop' }, {});\n }\n\n async restart(vpsId: string): Promise<AsyncTaskResult> {\n return this.http.request<AsyncTaskResult>('vs', { vpsid: vpsId, action: 'restart' }, {});\n }\n\n async poweroff(vpsId: string): Promise<AsyncTaskResult> {\n return this.http.request<AsyncTaskResult>('vs', { vpsid: vpsId, action: 'poweroff' }, {});\n }\n\n async suspend(vpsId: string): Promise<AsyncTaskResult> {\n return this.http.request<AsyncTaskResult>('vs', { suspend: vpsId }, {});\n }\n\n async unsuspend(vpsId: string): Promise<AsyncTaskResult> {\n return this.http.request<AsyncTaskResult>('vs', { unsuspend: vpsId }, {});\n }\n\n async rebuild(vpsId: string, params: RebuildVPSParams): Promise<AsyncTaskResult> {\n return this.http.request<AsyncTaskResult>('rebuild', {}, {\n vpsid: vpsId,\n reos: 1,\n ...params,\n } as Params);\n }\n\n async clone(vpsId: string, params: CloneVPSParams): Promise<AsyncTaskResult> {\n return this.http.request<AsyncTaskResult>('clone', {}, {\n vpsid: vpsId,\n ...params,\n } as Params);\n }\n\n async migrate(vpsId: string, params: MigrateVPSParams): Promise<AsyncTaskResult> {\n return this.http.request<AsyncTaskResult>('migrate', {}, {\n vpsid: vpsId,\n migrate: 1,\n migrate_but: 1,\n ...params,\n } as Params);\n }\n\n async status(vpsId: string): Promise<unknown> {\n return this.http.request('vstatus', { vpsid: vpsId }, {});\n }\n\n async vnc(vpsId: string): Promise<VNCInfo> {\n return this.http.request<VNCInfo>('vnc', { vpsid: vpsId }, {});\n }\n\n async stats(vpsId: string): Promise<VPSStatsResponse> {\n return this.http.request<VPSStatsResponse>('vps_stats', {}, { vpsid: vpsId });\n }\n}\n","import { HttpClient } from './http.js';\nimport { PlansResource } from './resources/plans.js';\nimport { TasksResource } from './resources/tasks.js';\nimport { UsersResource } from './resources/users.js';\nimport { VpsResource } from './resources/vps.js';\nimport type { ResolvedConfig, VirtualizorConfig } from './types/config.js';\n\nexport class VirtualizorClient {\n readonly vps: VpsResource;\n readonly users: UsersResource;\n readonly plans: PlansResource;\n readonly tasks: TasksResource;\n\n constructor(config: VirtualizorConfig) {\n const resolved: ResolvedConfig = {\n host: config.host,\n apiKey: config.apiKey,\n apiPass: config.apiPass ?? '',\n port: config.port ?? 4085,\n https: config.https ?? true,\n rejectUnauthorized: config.rejectUnauthorized ?? false,\n timeout: config.timeout ?? 30000,\n };\n const http = new HttpClient(resolved);\n this.vps = new VpsResource(http);\n this.users = new UsersResource(http);\n this.plans = new PlansResource(http);\n this.tasks = new TasksResource(http);\n }\n}\n\nexport function createVirtualizorClient(config: VirtualizorConfig): VirtualizorClient {\n return new VirtualizorClient(config);\n}\n"]}
package/package.json CHANGED
@@ -1,49 +1,41 @@
1
1
  {
2
2
  "name": "virtualizorjs",
3
- "version": "1.0.4",
4
- "description": "VirtualizorJS simplifies the management of Virtualizor servers with a streamlined and developer-friendly API for Node.js. Perform actions such as creating, starting, stopping, and restarting virtual servers effortlessly. Ideal for seamless integration into your Node.js applications, providing a powerful toolkit for Virtualizor server management.",
5
- "main": "./src/VirtualizorClient.js",
6
- "scripts": {},
7
- "keywords": [
8
- "virtualizor",
9
- "api",
10
- "nodejs",
11
- "js",
12
- "sdk",
13
- "wrapper",
14
- "virtualizorjs",
15
- "virtualizor-js",
16
- "virtualizorjs-api",
17
- "virtualizorjs-wrapper",
18
- "virtualizorjs-sdk",
19
- "lightweight",
20
- "easy",
21
- "simple",
22
- "powerful",
23
- "fast",
24
- "quick",
25
- "react",
26
- "vue",
27
- "angular",
28
- "express",
29
- "node",
30
- "nextjs",
31
- "nuxtjs",
32
- "svelte",
33
- "electron",
34
- "server",
35
- "client",
36
- "library",
37
- "package",
38
- "module",
39
- "npm"
40
- ],
41
- "publishConfig": {
42
- "@kkMihai:registry": "https://npm.pkg.github.com"
3
+ "version": "2.0.0",
4
+ "description": "TypeScript SDK for the Virtualizor server management API. Create, start, stop, restart, rebuild, and manage VPS instances with a type-safe, developer-friendly client.",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": {
11
+ "types": "./dist/index.d.mts",
12
+ "default": "./dist/index.mjs"
13
+ },
14
+ "require": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.js"
17
+ }
18
+ }
43
19
  },
20
+ "scripts": {
21
+ "build": "tsup",
22
+ "dev": "tsup --watch",
23
+ "test": "bun test",
24
+ "test:watch": "bun test --watch",
25
+ "coverage": "bun test --coverage",
26
+ "typecheck": "tsc --noEmit",
27
+ "lint": "biome check src tests",
28
+ "lint:fix": "biome check --write src tests",
29
+ "format": "biome format --write src tests",
30
+ "release": "bun run build && bumpp && bun publish --access public",
31
+ "prepublishOnly": "bun run build && bun run typecheck",
32
+ "check-exports": "attw --pack .",
33
+ "prepare": "husky"
34
+ },
35
+ "files": ["dist", "README.md", "LICENSE"],
36
+ "keywords": ["virtualizor", "vps", "sdk", "api", "typescript", "nodejs", "bun"],
44
37
  "author": "kkMihai",
45
38
  "license": "MIT",
46
- "github": "https://github.com/kkMihai/virtualizorjs",
47
39
  "repository": {
48
40
  "type": "git",
49
41
  "url": "git+https://github.com/kkMihai/virtualizorjs.git"
@@ -51,9 +43,22 @@
51
43
  "bugs": {
52
44
  "url": "https://github.com/kkMihai/virtualizorjs/issues"
53
45
  },
54
- "wiki": "https://github.com/kkMihai/virtualizorjs/wiki",
55
46
  "homepage": "https://github.com/kkMihai/virtualizorjs#readme",
56
47
  "engines": {
57
- "node": ">=12.0.0"
58
- }
48
+ "bun": ">=1.0.0"
49
+ },
50
+ "devDependencies": {
51
+ "@arethetypeswrong/cli": "^0.17.0",
52
+ "@biomejs/biome": "^1.9.0",
53
+ "@commitlint/cli": "^19.0.0",
54
+ "@commitlint/config-conventional": "^19.0.0",
55
+ "@types/bun": "latest",
56
+ "bumpp": "^9.0.0",
57
+ "husky": "^9.0.0",
58
+ "tsup": "^8.0.0",
59
+ "typescript": "^5.5.0"
60
+ },
61
+ "trustedDependencies": [
62
+ "@biomejs/biome"
63
+ ]
59
64
  }
@@ -1,28 +0,0 @@
1
- ---
2
- name: Bug report
3
- about: Create a report to help us improve
4
- title: ''
5
- labels: ''
6
- assignees: ''
7
-
8
- ---
9
-
10
- **Describe the bug**
11
- A clear and concise description of what the bug is.
12
-
13
- **To Reproduce**
14
- Steps to reproduce the behavior:
15
-
16
- **Expected behavior**
17
- A clear and concise description of what you expected to happen.
18
-
19
- **Screenshots**
20
- If applicable, add screenshots to help explain your problem.
21
-
22
- **Desktop (please complete the following information):**
23
- - OS: [e.g. Windows 11]
24
- - Version [e.g. 22]
25
- - NodeJS Version: [e.g v18.18.0]
26
-
27
- **Additional context**
28
- Add any other context about the problem here.
@@ -1,20 +0,0 @@
1
- ---
2
- name: Feature request
3
- about: Suggest an idea for this project
4
- title: ''
5
- labels: ''
6
- assignees: ''
7
-
8
- ---
9
-
10
- **Is your feature request related to a problem? Please describe.**
11
- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
-
13
- **Describe the solution you'd like**
14
- A clear and concise description of what you want to happen.
15
-
16
- **Describe alternatives you've considered**
17
- A clear and concise description of any alternative solutions or features you've considered.
18
-
19
- **Additional context**
20
- Add any other context or screenshots about the feature request here.
@@ -1,36 +0,0 @@
1
- # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
- # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
-
4
- name: Node.js Package
5
-
6
- on:
7
- release:
8
- types: [created]
9
-
10
- jobs:
11
- build:
12
- runs-on: ubuntu-latest
13
- steps:
14
- - uses: actions/checkout@v3
15
- - uses: actions/setup-node@v3
16
- with:
17
- node-version: 16
18
- - run: npm ci
19
- - run: npm test
20
-
21
- publish-gpr:
22
- needs: build
23
- runs-on: ubuntu-latest
24
- permissions:
25
- contents: read
26
- packages: write
27
- steps:
28
- - uses: actions/checkout@v3
29
- - uses: actions/setup-node@v3
30
- with:
31
- node-version: 16
32
- registry-url: https://npm.pkg.github.com/
33
- - run: npm ci
34
- - run: npm publish
35
- env:
36
- NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
@@ -1,33 +0,0 @@
1
- name: Node.js Package
2
-
3
- on:
4
- release:
5
- types: [created]
6
-
7
- jobs:
8
- build:
9
- runs-on: ubuntu-latest
10
- steps:
11
- - uses: actions/checkout@v4
12
- - uses: actions/setup-node@v3
13
- with:
14
- node-version: 16
15
- - run: npm ci
16
- - run: npm test
17
-
18
- publish-gpr:
19
- needs: build
20
- runs-on: ubuntu-latest
21
- permissions:
22
- packages: write
23
- contents: read
24
- steps:
25
- - uses: actions/checkout@v4
26
- - uses: actions/setup-node@v3
27
- with:
28
- node-version: 16
29
- registry-url: https://npm.pkg.github.com/
30
- - run: npm ci
31
- - run: npm publish
32
- env:
33
- NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
@@ -1,128 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- We as members, contributors, and leaders pledge to make participation in our
6
- community a harassment-free experience for everyone, regardless of age, body
7
- size, visible or invisible disability, ethnicity, sex characteristics, gender
8
- identity and expression, level of experience, education, socio-economic status,
9
- nationality, personal appearance, race, religion, or sexual identity
10
- and orientation.
11
-
12
- We pledge to act and interact in ways that contribute to an open, welcoming,
13
- diverse, inclusive, and healthy community.
14
-
15
- ## Our Standards
16
-
17
- Examples of behavior that contributes to a positive environment for our
18
- community include:
19
-
20
- * Demonstrating empathy and kindness toward other people
21
- * Being respectful of differing opinions, viewpoints, and experiences
22
- * Giving and gracefully accepting constructive feedback
23
- * Accepting responsibility and apologizing to those affected by our mistakes,
24
- and learning from the experience
25
- * Focusing on what is best not just for us as individuals, but for the
26
- overall community
27
-
28
- Examples of unacceptable behavior include:
29
-
30
- * The use of sexualized language or imagery, and sexual attention or
31
- advances of any kind
32
- * Trolling, insulting or derogatory comments, and personal or political attacks
33
- * Public or private harassment
34
- * Publishing others' private information, such as a physical or email
35
- address, without their explicit permission
36
- * Other conduct which could reasonably be considered inappropriate in a
37
- professional setting
38
-
39
- ## Enforcement Responsibilities
40
-
41
- Community leaders are responsible for clarifying and enforcing our standards of
42
- acceptable behavior and will take appropriate and fair corrective action in
43
- response to any behavior that they deem inappropriate, threatening, offensive,
44
- or harmful.
45
-
46
- Community leaders have the right and responsibility to remove, edit, or reject
47
- comments, commits, code, wiki edits, issues, and other contributions that are
48
- not aligned to this Code of Conduct, and will communicate reasons for moderation
49
- decisions when appropriate.
50
-
51
- ## Scope
52
-
53
- This Code of Conduct applies within all community spaces, and also applies when
54
- an individual is officially representing the community in public spaces.
55
- Examples of representing our community include using an official e-mail address,
56
- posting via an official social media account, or acting as an appointed
57
- representative at an online or offline event.
58
-
59
- ## Enforcement
60
-
61
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
- reported to the community leaders responsible for enforcement at
63
- .
64
- All complaints will be reviewed and investigated promptly and fairly.
65
-
66
- All community leaders are obligated to respect the privacy and security of the
67
- reporter of any incident.
68
-
69
- ## Enforcement Guidelines
70
-
71
- Community leaders will follow these Community Impact Guidelines in determining
72
- the consequences for any action they deem in violation of this Code of Conduct:
73
-
74
- ### 1. Correction
75
-
76
- **Community Impact**: Use of inappropriate language or other behavior deemed
77
- unprofessional or unwelcome in the community.
78
-
79
- **Consequence**: A private, written warning from community leaders, providing
80
- clarity around the nature of the violation and an explanation of why the
81
- behavior was inappropriate. A public apology may be requested.
82
-
83
- ### 2. Warning
84
-
85
- **Community Impact**: A violation through a single incident or series
86
- of actions.
87
-
88
- **Consequence**: A warning with consequences for continued behavior. No
89
- interaction with the people involved, including unsolicited interaction with
90
- those enforcing the Code of Conduct, for a specified period of time. This
91
- includes avoiding interactions in community spaces as well as external channels
92
- like social media. Violating these terms may lead to a temporary or
93
- permanent ban.
94
-
95
- ### 3. Temporary Ban
96
-
97
- **Community Impact**: A serious violation of community standards, including
98
- sustained inappropriate behavior.
99
-
100
- **Consequence**: A temporary ban from any sort of interaction or public
101
- communication with the community for a specified period of time. No public or
102
- private interaction with the people involved, including unsolicited interaction
103
- with those enforcing the Code of Conduct, is allowed during this period.
104
- Violating these terms may lead to a permanent ban.
105
-
106
- ### 4. Permanent Ban
107
-
108
- **Community Impact**: Demonstrating a pattern of violation of community
109
- standards, including sustained inappropriate behavior, harassment of an
110
- individual, or aggression toward or disparagement of classes of individuals.
111
-
112
- **Consequence**: A permanent ban from any sort of public interaction within
113
- the community.
114
-
115
- ## Attribution
116
-
117
- This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
- version 2.0, available at
119
- https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120
-
121
- Community Impact Guidelines were inspired by [Mozilla's code of conduct
122
- enforcement ladder](https://github.com/mozilla/diversity).
123
-
124
- [homepage]: https://www.contributor-covenant.org
125
-
126
- For answers to common questions about this code of conduct, see the FAQ at
127
- https://www.contributor-covenant.org/faq. Translations are available at
128
- https://www.contributor-covenant.org/translations.