virtualizorjs 2.2.0 → 2.2.1
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 +6 -9
- package/dist/index.d.mts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +10 -8
- package/dist/index.mjs +10 -8
- package/package.json +1 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -6,9 +6,6 @@
|
|
|
6
6
|
|
|
7
7
|
A **TypeScript-first** SDK for the [Virtualizor](https://www.virtualizor.com/) server management API. Manage VPS instances, users, and plans with a clean, namespaced interface and zero production dependencies.
|
|
8
8
|
|
|
9
|
-
> [!IMPORTANT]
|
|
10
|
-
> Since the Virtualizor API documentation is a mess (at least for me), I need help from YOU to report bugs, missing features or just to tell me that something is not clear. You can do that by opening an issue or a pull request.
|
|
11
|
-
|
|
12
9
|
## Installation
|
|
13
10
|
|
|
14
11
|
**npm:**
|
|
@@ -29,12 +26,12 @@ bun add virtualizorjs
|
|
|
29
26
|
import { createVirtualizorClient } from 'virtualizorjs';
|
|
30
27
|
|
|
31
28
|
const client = createVirtualizorClient({
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
host: process.env.VIRTUALIZOR_HOST!,
|
|
30
|
+
apiKey: process.env.VIRTUALIZOR_API_KEY!,
|
|
31
|
+
apiPass: process.env.VIRTUALIZOR_API_PASS!,
|
|
32
|
+
// Optional: port (default 4085), https (default true),
|
|
33
|
+
// rejectUnauthorized (default false), timeout (default 30000ms)
|
|
34
|
+
// Ports: 4085 (HTTPS), 4084 (HTTP)
|
|
38
35
|
});
|
|
39
36
|
```
|
|
40
37
|
|
package/dist/index.d.mts
CHANGED
|
@@ -58,10 +58,13 @@ declare const symbols: {
|
|
|
58
58
|
|
|
59
59
|
interface BoxOptions {
|
|
60
60
|
title?: string;
|
|
61
|
-
borderColor?: 'cyan' | 'yellow' | 'red' | 'green';
|
|
61
|
+
borderColor?: 'cyan' | 'yellow' | 'red' | 'green' | 'blue' | 'magenta';
|
|
62
62
|
padding?: number;
|
|
63
|
+
margin?: number;
|
|
63
64
|
}
|
|
64
65
|
declare function createBox(content: string, options?: BoxOptions): string;
|
|
66
|
+
declare function createUpdateBox(current: string, latest: string): string;
|
|
67
|
+
declare function createErrorBox(title: string, message: string, hint?: string): string;
|
|
65
68
|
|
|
66
69
|
declare function formatError(error: Error, verbose?: boolean): string;
|
|
67
70
|
|
|
@@ -471,4 +474,4 @@ declare function formatIps(ips: IpsInput, options: FormatIpsOptions & {
|
|
|
471
474
|
as: 'string';
|
|
472
475
|
}): string;
|
|
473
476
|
|
|
474
|
-
export { type AsyncTaskResult, type CloneVPSParams, ConsoleLogger, type CreatePlanParams, type CreateUserParams, type CreateVPSParams, type IpsInput, type ListVPSParams, type Logger, type MigrateVPSParams, type Plan, type RebuildVPSParams, type Task, type User, type VPS, type VirtType, VirtualizorApiError, VirtualizorClient, type VirtualizorConfig, colors, createBox, createVirtualizorClient, defaultLogger, formatError, formatIps, symbols };
|
|
477
|
+
export { type AsyncTaskResult, type CloneVPSParams, ConsoleLogger, type CreatePlanParams, type CreateUserParams, type CreateVPSParams, type IpsInput, type ListVPSParams, type Logger, type MigrateVPSParams, type Plan, type RebuildVPSParams, type Task, type User, type VPS, type VirtType, VirtualizorApiError, VirtualizorClient, type VirtualizorConfig, colors, createBox, createErrorBox, createUpdateBox, createVirtualizorClient, defaultLogger, formatError, formatIps, symbols };
|
package/dist/index.d.ts
CHANGED
|
@@ -58,10 +58,13 @@ declare const symbols: {
|
|
|
58
58
|
|
|
59
59
|
interface BoxOptions {
|
|
60
60
|
title?: string;
|
|
61
|
-
borderColor?: 'cyan' | 'yellow' | 'red' | 'green';
|
|
61
|
+
borderColor?: 'cyan' | 'yellow' | 'red' | 'green' | 'blue' | 'magenta';
|
|
62
62
|
padding?: number;
|
|
63
|
+
margin?: number;
|
|
63
64
|
}
|
|
64
65
|
declare function createBox(content: string, options?: BoxOptions): string;
|
|
66
|
+
declare function createUpdateBox(current: string, latest: string): string;
|
|
67
|
+
declare function createErrorBox(title: string, message: string, hint?: string): string;
|
|
65
68
|
|
|
66
69
|
declare function formatError(error: Error, verbose?: boolean): string;
|
|
67
70
|
|
|
@@ -471,4 +474,4 @@ declare function formatIps(ips: IpsInput, options: FormatIpsOptions & {
|
|
|
471
474
|
as: 'string';
|
|
472
475
|
}): string;
|
|
473
476
|
|
|
474
|
-
export { type AsyncTaskResult, type CloneVPSParams, ConsoleLogger, type CreatePlanParams, type CreateUserParams, type CreateVPSParams, type IpsInput, type ListVPSParams, type Logger, type MigrateVPSParams, type Plan, type RebuildVPSParams, type Task, type User, type VPS, type VirtType, VirtualizorApiError, VirtualizorClient, type VirtualizorConfig, colors, createBox, createVirtualizorClient, defaultLogger, formatError, formatIps, symbols };
|
|
477
|
+
export { type AsyncTaskResult, type CloneVPSParams, ConsoleLogger, type CreatePlanParams, type CreateUserParams, type CreateVPSParams, type IpsInput, type ListVPSParams, type Logger, type MigrateVPSParams, type Plan, type RebuildVPSParams, type Task, type User, type VPS, type VirtType, VirtualizorApiError, VirtualizorClient, type VirtualizorConfig, colors, createBox, createErrorBox, createUpdateBox, createVirtualizorClient, defaultLogger, formatError, formatIps, symbols };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
'use strict';var j=require('http')
|
|
1
|
+
'use strict';var j=require('http'),U=require('https');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var j__default=/*#__PURE__*/_interopDefault(j);var U__default=/*#__PURE__*/_interopDefault(U);var F=(s,t)=>()=>(t||s((t={exports:{}}).exports,t),t.exports);var M=F(($t,Q)=>{Q.exports={name:"virtualizorjs",version:"2.2.1",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.",main:"./dist/index.js",module:"./dist/index.mjs",types:"./dist/index.d.ts",exports:{".":{import:{types:"./dist/index.d.mts",default:"./dist/index.mjs"},require:{types:"./dist/index.d.ts",default:"./dist/index.js"}}},scripts:{build:"tsup",dev:"tsup --watch",test:"bun test","test:watch":"bun test --watch",coverage:"bun test --coverage",typecheck:"tsc --noEmit",lint:"biome check src tests","lint:fix":"biome check --write src tests",format:"biome format --write src tests",release:"bun run build && bumpp",prepublishOnly:"bun run build && bun run typecheck","check-exports":"attw --pack .",prepare:"husky"},files:["dist","README.md","LICENSE"],keywords:["virtualizor","vps","sdk","api","typescript","nodejs","bun"],author:"kkMihai",license:"MIT",repository:{type:"git",url:"git+https://github.com/kkMihai/virtualizorjs.git"},bugs:{url:"https://github.com/kkMihai/virtualizorjs/issues"},homepage:"https://github.com/kkMihai/virtualizorjs#readme",engines:{bun:">=1.3.0"},devDependencies:{"@arethetypeswrong/cli":"^0.17.0","@biomejs/biome":"^1.9.0","@commitlint/cli":"^19.0.0","@commitlint/config-conventional":"^19.0.0","@types/bun":"latest",bumpp:"^9.0.0",husky:"^9.0.0",tsup:"^8.0.0",typescript:"^5.5.0"},trustedDependencies:["@biomejs/biome"]};});var P={port:4085,https:true,rejectUnauthorized:false,timeout:3e4,debug:false},I={pollIntervalMs:2e3,timeoutMs:12e4};var n=class extends Error{code;details;constructor(t,e,o){super(t),this.name="VirtualizorApiError",this.code=e,this.details=o;}format(){return `[API Error ${this.code}] ${this.message}`}};function $(s,t,e){let o={};for(let[p,i]of Object.entries(s))i!==void 0&&(o[p]=i);let r=new URLSearchParams;r.set("api","json"),r.set("adminapikey",t),r.set("adminapipass",e);for(let[p,i]of Object.entries(o))r.set(p,String(i));return `?${r.toString()}`}var q=5e3,v=class{constructor(t){this.config=t;let e=t.https?U__default.default.Agent:j__default.default.Agent;this.agent=new e({keepAlive:true,maxSockets:50,maxFreeSockets:10,scheduling:"lifo",...t.https?{rejectUnauthorized:t.rejectUnauthorized}:{}}),this.logger=t.logger;}agent;logger;parseResponse(t){if(t.error&&t.error.length>0){let e=t.error[0];if(e)throw new n(e.msg,e.code)}return t}async request(t,e={},o={}){let r={act:t,...e},p=$(r,this.config.apiKey,this.config.apiPass);if(this.config.debug){let c=p.replace(/adminapikey=[^&]*/,"adminapikey=[REDACTED]").replace(/adminapipass=[^&]*/,"adminapipass=[REDACTED]");this.logger.debug(`Request: act=${t} path=/index.php${c}`);}let i=`/index.php${p}`,m=Object.entries(o).filter(([,c])=>c!==void 0).map(([c,R])=>`${encodeURIComponent(c)}=${encodeURIComponent(String(R))}`).join("&");try{let c=await this.rawRequest(i,m||void 0);return this.parseResponse(c)}catch(c){throw this.config.debug&&(c instanceof n?this.logger.error(`[Virtualizor] \u25CF Error: [API Error ${c.code}] ${c.message}`):this.logger.error(`[Virtualizor] \u25CF Error: ${c.message}`)),c}}validateJsonDepth(t,e=0){if(e>100)throw new n("JSON depth limit exceeded",-32e3);if(typeof t=="object"&&t!==null)if(Array.isArray(t))for(let r of t)this.validateJsonDepth(r,e+1);else for(let r of Object.values(t))this.validateJsonDepth(r,e+1);}destroy(){this.agent.destroy();}rawRequest(t,e){let o=this.config.https?U__default.default:j__default.default,r={host:this.config.host,port:this.config.port,path:t,method:e?"POST":"GET",headers:{"Content-Type":"application/x-www-form-urlencoded",...e?{"Content-Length":Buffer.byteLength(e)}:{}},agent:this.agent};return new Promise((p,i)=>{let m=o.request(r,u=>{let T=[];u.on("data",f=>{T.push(f);}),u.on("end",()=>{let f=Buffer.concat(T).toString("utf8");if(u.statusCode===302||u.statusCode===301){i(new n(`Redirect detected (status ${u.statusCode}). Authentication failed. Location: ${u.headers.location}`,u.statusCode));return}try{let d=JSON.parse(f);this.validateJsonDepth(d),p(d);}catch(d){this.config.debug&&(d instanceof n?this.logger.error(`[Virtualizor] \u25CF Error: [API Error ${d.code}] ${d.message}`):this.logger.error(`[Virtualizor] \u25CF Error: ${d.message}`)),i(new n(`Failed to parse response: ${d.message??"Invalid JSON"}`,-32700));}}),u.on("error",f=>{this.config.debug&&this.logger.error("[Virtualizor] \u25CF Error: Response stream error",f),i(new n(`Response stream error: ${f.message??"Unknown error"}`,-32e3));});}),c=setTimeout(()=>{m.destroy(new n(`Connection timeout after ${q}ms`,-32e3));},q),R=setTimeout(()=>{m.destroy(new n(`Request timed out after ${this.config.timeout}ms`,-32e3));},this.config.timeout);m.once("socket",u=>{u.connecting?u.once("connect",()=>clearTimeout(c)):clearTimeout(c);}),m.once("close",()=>{clearTimeout(c),clearTimeout(R);}),m.on("error",u=>{u instanceof n?i(u):i(new n(`Request error ${u}`,-32e3));}),e&&m.write(e),m.end();})}};var A=process.platform==="win32",G=process.env.NO_COLOR===void 0&&process.stdout.isTTY;function l(s,t){return G?`\x1B[${s}m${t}\x1B[0m`:t}var a={red:s=>l(31,s),green:s=>l(32,s),yellow:s=>l(33,s),blue:s=>l(34,s),magenta:s=>l(35,s),cyan:s=>l(36,s),white:s=>l(37,s),gray:s=>l(90,s),dim:s=>l(2,s),bold:s=>l(1,s),underline:s=>l(4,s),bgRed:s=>l(41,s),bgGreen:s=>l(42,s),bgYellow:s=>l(43,s),bgBlue:s=>l(44,s),bgCyan:s=>l(46,s)},g={success:A?"\u221A":"\u2714",error:A?"\xD7":"\u2716",warning:A?"\u203C":"\u26A0",info:A?"i":"\u2139",bullet:"\u25CF",arrow:"\u2192",chevron:"\u203A",pointer:"\u276F",star:"\u2605"},h={topLeft:"\u250C",topRight:"\u2510",bottomLeft:"\u2514",bottomRight:"\u2518",horizontal:"\u2500",vertical:"\u2502"};var k=class{constructor(t="Virtualizor"){this.prefix=t;}timestamp(){let e=new Date().toISOString().split("T")[1];return a.dim(e?e.slice(0,8):"00:00:00")}tag(){return a.cyan(`[${this.prefix}]`)}debug(t,...e){console.log(this.timestamp(),this.tag(),a.dim(g.bullet),a.dim(t),...e);}info(t,...e){console.log(this.timestamp(),this.tag(),a.blue(g.info),t,...e);}warn(t,...e){console.log(this.timestamp(),this.tag(),a.yellow(g.warning),a.yellow(t),...e);}error(t,e){console.error(this.timestamp(),this.tag(),a.red(g.error),a.red(t)),e?.stack&&console.error(a.dim(e.stack.split(`
|
|
2
2
|
`).slice(1,4).join(`
|
|
3
|
-
`)));}success(t,...
|
|
4
|
-
`),
|
|
5
|
-
`)
|
|
6
|
-
`)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
`)));}success(t,...e){console.log(this.timestamp(),this.tag(),a.green(g.success),a.green(t),...e);}},w=new k;function O(s,t={}){let{padding:e=1,margin:o=0,borderColor:r="cyan"}=t,p=s.split(`
|
|
4
|
+
`),m=Math.max(...p.map(y=>y.length))+e*2,c=a[r]??a.cyan,R=h.horizontal.repeat(m),u=`${h.topLeft}${R}${h.topRight}`,T=`${h.bottomLeft}${R}${h.bottomRight}`,f=p.map(y=>{let z=" ".repeat(e)+y+" ".repeat(e);return `${h.vertical}${z.padEnd(m)}${h.vertical}`}),d=[c(u),...f.map(y=>c(y)),c(T)].join(`
|
|
5
|
+
`);if(o>0){let y=" ".repeat(o);return d.split(`
|
|
6
|
+
`).map(z=>y+z).join(`
|
|
7
|
+
`)}return d}function b(s,t){let e=["\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557","\u2551 \u{1F680} UPDATE AVAILABLE \u{1F680} \u2551","\u2560\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563","\u2551 \u2551",`\u2551 Current version: ${s.padEnd(18)} \u2551`,`\u2551 Latest version: ${t.padEnd(17)} \u2551`,"\u2551 \u2551","\u2551 To update, run: \u2551","\u2551 npm install virtualizorjs@latest \u2551","\u2551 \u2551","\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D"].join(`
|
|
8
|
+
`);return a.yellow(e)}function N(s,t,e){let o=["\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557","\u2551 \u274C ERROR OCCURRED \u274C \u2551","\u2560\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563","\u2551 \u2551",`\u2551 ${s.padEnd(34)}\u2551`,"\u2551 \u2551",`\u2551 ${t.padEnd(34)}\u2551`,"\u2551 \u2551",e?`\u2551 \u{1F4A1} ${e.padEnd(29)}\u2551`:"",e?"\u2551 \u2551":"","\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D"].filter(r=>r!==void 0).join(`
|
|
9
|
+
`);return a.red(o)}function B(s,t=false){if(s instanceof n){let e=s.details&&t?`
|
|
10
|
+
${a.dim(JSON.stringify(s.details,null,2))}`:"";return `${g.error} ${a.red(`[API Error ${s.code}]`)} ${s.message}${e}`}return `${g.error} ${a.red(s.message)}`}var x=class{constructor(t){this.http=t;}async list(){return (await this.http.request("plans",{},{})).plans}async create(t){return this.http.request("addplan",{},t)}async delete(t){return this.http.request("plans",{},{delete:t})}};var V=class{constructor(t){this.http=t;}async get(t){return (await this.http.request("tasks",{taskid:t},{})).tasks[t]}async wait(t,e={}){let{pollIntervalMs:o=I.pollIntervalMs,timeoutMs:r=I.timeoutMs}=e,p=Date.now()+r;for(;Date.now()<p;){let i=await this.get(t);if(!i)throw new n("Task not found",404);if(i.status==="1"||i.status==="done")return i;if(i.status==="error"||i.status==="-1")throw new n("Task failed",500);await new Promise(m=>setTimeout(m,o));}throw new n(`Task timed out after ${r}ms`,408)}};var C=class{constructor(t){this.http=t;}async list(){return (await this.http.request("users",{},{})).users}async create(t){return this.http.request("adduser",{},t)}async delete(t){return this.http.request("users",{},{delete:t})}async suspend(t){return this.http.request("users",{},{suspend:t})}async unsuspend(t){return this.http.request("users",{},{unsuspend:t})}};var E={REBUILD_REOS_FLAG:1,MIGRATE_FLAG:1,MIGRATE_BUT_FLAG:1};var S=class{constructor(t){this.http=t;}async list(t={}){return (await this.http.request("vs",{},t)).vs??{}}async get(t){let e=await this.http.request("vs",{},t),o=Object.entries(e.vs??{});if(o.length===0)throw new n("VPS not found",404);let r=o[0];if(!r)throw new n("VPS not found",404);let[,p]=r;return p}async create(t){return this.http.request("addvs",{},t)}async delete(t){return this.http.request("vs",{delete:t},{})}async start(t){return this.http.request("vs",{vpsid:t,action:"start"},{})}async stop(t){return this.http.request("vs",{vpsid:t,action:"stop"},{})}async restart(t){return this.http.request("vs",{vpsid:t,action:"restart"},{})}async poweroff(t){return this.http.request("vs",{vpsid:t,action:"poweroff"},{})}async suspend(t){return this.http.request("vs",{suspend:t},{})}async unsuspend(t){return this.http.request("vs",{unsuspend:t},{})}async rebuild(t,e){return this.http.request("rebuild",{},{vpsid:t,reos:E.REBUILD_REOS_FLAG,...e})}async clone(t,e){return this.http.request("clone",{},{vpsid:t,...e})}async migrate(t,e){return this.http.request("migrate",{},{vpsid:t,migrate:E.MIGRATE_FLAG,migrate_but:E.MIGRATE_BUT_FLAG,...e})}async status(t){return this.http.request("vstatus",{vpsid:t},{})}async vnc(t){return this.http.request("vnc",{vpsid:t},{})}async stats(t){return this.http.request("vps_stats",{},{vpsid:t})}};var H="https://registry.npmjs.org/virtualizorjs/latest";async function J(s){let t=new AbortController,e=setTimeout(()=>t.abort(),s);try{let o=await fetch(H,{signal:t.signal});if(!o.ok)throw new Error(`HTTP ${o.status}`);return await o.json()}finally{clearTimeout(e);}}function K(s,t){let e=s.split(".").map(Number),o=t.split(".").map(Number);return (o[0]??0)>(e[0]??0)||(o[0]??0)===(e[0]??0)&&(o[1]??0)>(e[1]??0)||(o[0]??0)===(e[0]??0)&&(o[1]??0)===(e[1]??0)&&(o[2]??0)>(e[2]??0)}var _=false;async function D(s,t,e){if(!(_&&true)){_=true;try{let r=(await J(e?.timeout??2e3)).version;if(!K(s,r))return;t.warn(`Update available: ${s} \u2192 ${r}`),console.log(),console.log(b(s,r)),console.log();}catch{}}}var W=M().version,L=class{vps;users;plans;tasks;logger;constructor(t){let e=t.logger??w;this.logger=e;let o={host:t.host,apiKey:t.apiKey,apiPass:t.apiPass??"",port:t.port??P.port,https:t.https??P.https,rejectUnauthorized:t.rejectUnauthorized??P.rejectUnauthorized,timeout:t.timeout??P.timeout,debug:t.debug??P.debug,logger:e,disableUpdateCheck:t.disableUpdateCheck??false},r=new v(o);this.vps=new S(r),this.users=new C(r),this.plans=new x(r),this.tasks=new V(r),o.disableUpdateCheck||D(W,e).catch(()=>{});}};function Y(s){return new L(s)}function X(s,t){let e=t?.as??"array",o=t?.separator??", ";if(!s)return e==="array"?[]:"";let r=[];if(Array.isArray(s))r=s.filter(Boolean);else if(typeof s=="string"){let p=s.trim();p===""?r=[]:p.includes(",")?r=p.split(",").map(i=>i.trim()).filter(Boolean):/\s+/.test(p)?r=p.split(/\s+/).map(i=>i.trim()).filter(Boolean):r=[p];}else typeof s=="object"&&(r=Object.values(s).filter(Boolean));return e==="array"?r:r.join(o)}
|
|
11
|
+
exports.ConsoleLogger=k;exports.VirtualizorApiError=n;exports.VirtualizorClient=L;exports.colors=a;exports.createBox=O;exports.createErrorBox=N;exports.createUpdateBox=b;exports.createVirtualizorClient=Y;exports.defaultLogger=w;exports.formatError=B;exports.formatIps=X;exports.symbols=g;
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import j from'http';import
|
|
1
|
+
import j from'http';import U from'https';var F=(s,t)=>()=>(t||s((t={exports:{}}).exports,t),t.exports);var M=F(($t,Q)=>{Q.exports={name:"virtualizorjs",version:"2.2.1",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.",main:"./dist/index.js",module:"./dist/index.mjs",types:"./dist/index.d.ts",exports:{".":{import:{types:"./dist/index.d.mts",default:"./dist/index.mjs"},require:{types:"./dist/index.d.ts",default:"./dist/index.js"}}},scripts:{build:"tsup",dev:"tsup --watch",test:"bun test","test:watch":"bun test --watch",coverage:"bun test --coverage",typecheck:"tsc --noEmit",lint:"biome check src tests","lint:fix":"biome check --write src tests",format:"biome format --write src tests",release:"bun run build && bumpp",prepublishOnly:"bun run build && bun run typecheck","check-exports":"attw --pack .",prepare:"husky"},files:["dist","README.md","LICENSE"],keywords:["virtualizor","vps","sdk","api","typescript","nodejs","bun"],author:"kkMihai",license:"MIT",repository:{type:"git",url:"git+https://github.com/kkMihai/virtualizorjs.git"},bugs:{url:"https://github.com/kkMihai/virtualizorjs/issues"},homepage:"https://github.com/kkMihai/virtualizorjs#readme",engines:{bun:">=1.3.0"},devDependencies:{"@arethetypeswrong/cli":"^0.17.0","@biomejs/biome":"^1.9.0","@commitlint/cli":"^19.0.0","@commitlint/config-conventional":"^19.0.0","@types/bun":"latest",bumpp:"^9.0.0",husky:"^9.0.0",tsup:"^8.0.0",typescript:"^5.5.0"},trustedDependencies:["@biomejs/biome"]};});var P={port:4085,https:true,rejectUnauthorized:false,timeout:3e4,debug:false},I={pollIntervalMs:2e3,timeoutMs:12e4};var n=class extends Error{code;details;constructor(t,e,o){super(t),this.name="VirtualizorApiError",this.code=e,this.details=o;}format(){return `[API Error ${this.code}] ${this.message}`}};function $(s,t,e){let o={};for(let[p,i]of Object.entries(s))i!==void 0&&(o[p]=i);let r=new URLSearchParams;r.set("api","json"),r.set("adminapikey",t),r.set("adminapipass",e);for(let[p,i]of Object.entries(o))r.set(p,String(i));return `?${r.toString()}`}var q=5e3,v=class{constructor(t){this.config=t;let e=t.https?U.Agent:j.Agent;this.agent=new e({keepAlive:true,maxSockets:50,maxFreeSockets:10,scheduling:"lifo",...t.https?{rejectUnauthorized:t.rejectUnauthorized}:{}}),this.logger=t.logger;}agent;logger;parseResponse(t){if(t.error&&t.error.length>0){let e=t.error[0];if(e)throw new n(e.msg,e.code)}return t}async request(t,e={},o={}){let r={act:t,...e},p=$(r,this.config.apiKey,this.config.apiPass);if(this.config.debug){let c=p.replace(/adminapikey=[^&]*/,"adminapikey=[REDACTED]").replace(/adminapipass=[^&]*/,"adminapipass=[REDACTED]");this.logger.debug(`Request: act=${t} path=/index.php${c}`);}let i=`/index.php${p}`,m=Object.entries(o).filter(([,c])=>c!==void 0).map(([c,R])=>`${encodeURIComponent(c)}=${encodeURIComponent(String(R))}`).join("&");try{let c=await this.rawRequest(i,m||void 0);return this.parseResponse(c)}catch(c){throw this.config.debug&&(c instanceof n?this.logger.error(`[Virtualizor] \u25CF Error: [API Error ${c.code}] ${c.message}`):this.logger.error(`[Virtualizor] \u25CF Error: ${c.message}`)),c}}validateJsonDepth(t,e=0){if(e>100)throw new n("JSON depth limit exceeded",-32e3);if(typeof t=="object"&&t!==null)if(Array.isArray(t))for(let r of t)this.validateJsonDepth(r,e+1);else for(let r of Object.values(t))this.validateJsonDepth(r,e+1);}destroy(){this.agent.destroy();}rawRequest(t,e){let o=this.config.https?U:j,r={host:this.config.host,port:this.config.port,path:t,method:e?"POST":"GET",headers:{"Content-Type":"application/x-www-form-urlencoded",...e?{"Content-Length":Buffer.byteLength(e)}:{}},agent:this.agent};return new Promise((p,i)=>{let m=o.request(r,u=>{let T=[];u.on("data",f=>{T.push(f);}),u.on("end",()=>{let f=Buffer.concat(T).toString("utf8");if(u.statusCode===302||u.statusCode===301){i(new n(`Redirect detected (status ${u.statusCode}). Authentication failed. Location: ${u.headers.location}`,u.statusCode));return}try{let d=JSON.parse(f);this.validateJsonDepth(d),p(d);}catch(d){this.config.debug&&(d instanceof n?this.logger.error(`[Virtualizor] \u25CF Error: [API Error ${d.code}] ${d.message}`):this.logger.error(`[Virtualizor] \u25CF Error: ${d.message}`)),i(new n(`Failed to parse response: ${d.message??"Invalid JSON"}`,-32700));}}),u.on("error",f=>{this.config.debug&&this.logger.error("[Virtualizor] \u25CF Error: Response stream error",f),i(new n(`Response stream error: ${f.message??"Unknown error"}`,-32e3));});}),c=setTimeout(()=>{m.destroy(new n(`Connection timeout after ${q}ms`,-32e3));},q),R=setTimeout(()=>{m.destroy(new n(`Request timed out after ${this.config.timeout}ms`,-32e3));},this.config.timeout);m.once("socket",u=>{u.connecting?u.once("connect",()=>clearTimeout(c)):clearTimeout(c);}),m.once("close",()=>{clearTimeout(c),clearTimeout(R);}),m.on("error",u=>{u instanceof n?i(u):i(new n(`Request error ${u}`,-32e3));}),e&&m.write(e),m.end();})}};var A=process.platform==="win32",G=process.env.NO_COLOR===void 0&&process.stdout.isTTY;function l(s,t){return G?`\x1B[${s}m${t}\x1B[0m`:t}var a={red:s=>l(31,s),green:s=>l(32,s),yellow:s=>l(33,s),blue:s=>l(34,s),magenta:s=>l(35,s),cyan:s=>l(36,s),white:s=>l(37,s),gray:s=>l(90,s),dim:s=>l(2,s),bold:s=>l(1,s),underline:s=>l(4,s),bgRed:s=>l(41,s),bgGreen:s=>l(42,s),bgYellow:s=>l(43,s),bgBlue:s=>l(44,s),bgCyan:s=>l(46,s)},g={success:A?"\u221A":"\u2714",error:A?"\xD7":"\u2716",warning:A?"\u203C":"\u26A0",info:A?"i":"\u2139",bullet:"\u25CF",arrow:"\u2192",chevron:"\u203A",pointer:"\u276F",star:"\u2605"},h={topLeft:"\u250C",topRight:"\u2510",bottomLeft:"\u2514",bottomRight:"\u2518",horizontal:"\u2500",vertical:"\u2502"};var k=class{constructor(t="Virtualizor"){this.prefix=t;}timestamp(){let e=new Date().toISOString().split("T")[1];return a.dim(e?e.slice(0,8):"00:00:00")}tag(){return a.cyan(`[${this.prefix}]`)}debug(t,...e){console.log(this.timestamp(),this.tag(),a.dim(g.bullet),a.dim(t),...e);}info(t,...e){console.log(this.timestamp(),this.tag(),a.blue(g.info),t,...e);}warn(t,...e){console.log(this.timestamp(),this.tag(),a.yellow(g.warning),a.yellow(t),...e);}error(t,e){console.error(this.timestamp(),this.tag(),a.red(g.error),a.red(t)),e?.stack&&console.error(a.dim(e.stack.split(`
|
|
2
2
|
`).slice(1,4).join(`
|
|
3
|
-
`)));}success(t,...
|
|
4
|
-
`),
|
|
5
|
-
`)
|
|
6
|
-
`)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
`)));}success(t,...e){console.log(this.timestamp(),this.tag(),a.green(g.success),a.green(t),...e);}},w=new k;function O(s,t={}){let{padding:e=1,margin:o=0,borderColor:r="cyan"}=t,p=s.split(`
|
|
4
|
+
`),m=Math.max(...p.map(y=>y.length))+e*2,c=a[r]??a.cyan,R=h.horizontal.repeat(m),u=`${h.topLeft}${R}${h.topRight}`,T=`${h.bottomLeft}${R}${h.bottomRight}`,f=p.map(y=>{let z=" ".repeat(e)+y+" ".repeat(e);return `${h.vertical}${z.padEnd(m)}${h.vertical}`}),d=[c(u),...f.map(y=>c(y)),c(T)].join(`
|
|
5
|
+
`);if(o>0){let y=" ".repeat(o);return d.split(`
|
|
6
|
+
`).map(z=>y+z).join(`
|
|
7
|
+
`)}return d}function b(s,t){let e=["\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557","\u2551 \u{1F680} UPDATE AVAILABLE \u{1F680} \u2551","\u2560\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563","\u2551 \u2551",`\u2551 Current version: ${s.padEnd(18)} \u2551`,`\u2551 Latest version: ${t.padEnd(17)} \u2551`,"\u2551 \u2551","\u2551 To update, run: \u2551","\u2551 npm install virtualizorjs@latest \u2551","\u2551 \u2551","\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D"].join(`
|
|
8
|
+
`);return a.yellow(e)}function N(s,t,e){let o=["\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557","\u2551 \u274C ERROR OCCURRED \u274C \u2551","\u2560\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563","\u2551 \u2551",`\u2551 ${s.padEnd(34)}\u2551`,"\u2551 \u2551",`\u2551 ${t.padEnd(34)}\u2551`,"\u2551 \u2551",e?`\u2551 \u{1F4A1} ${e.padEnd(29)}\u2551`:"",e?"\u2551 \u2551":"","\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D"].filter(r=>r!==void 0).join(`
|
|
9
|
+
`);return a.red(o)}function B(s,t=false){if(s instanceof n){let e=s.details&&t?`
|
|
10
|
+
${a.dim(JSON.stringify(s.details,null,2))}`:"";return `${g.error} ${a.red(`[API Error ${s.code}]`)} ${s.message}${e}`}return `${g.error} ${a.red(s.message)}`}var x=class{constructor(t){this.http=t;}async list(){return (await this.http.request("plans",{},{})).plans}async create(t){return this.http.request("addplan",{},t)}async delete(t){return this.http.request("plans",{},{delete:t})}};var V=class{constructor(t){this.http=t;}async get(t){return (await this.http.request("tasks",{taskid:t},{})).tasks[t]}async wait(t,e={}){let{pollIntervalMs:o=I.pollIntervalMs,timeoutMs:r=I.timeoutMs}=e,p=Date.now()+r;for(;Date.now()<p;){let i=await this.get(t);if(!i)throw new n("Task not found",404);if(i.status==="1"||i.status==="done")return i;if(i.status==="error"||i.status==="-1")throw new n("Task failed",500);await new Promise(m=>setTimeout(m,o));}throw new n(`Task timed out after ${r}ms`,408)}};var C=class{constructor(t){this.http=t;}async list(){return (await this.http.request("users",{},{})).users}async create(t){return this.http.request("adduser",{},t)}async delete(t){return this.http.request("users",{},{delete:t})}async suspend(t){return this.http.request("users",{},{suspend:t})}async unsuspend(t){return this.http.request("users",{},{unsuspend:t})}};var E={REBUILD_REOS_FLAG:1,MIGRATE_FLAG:1,MIGRATE_BUT_FLAG:1};var S=class{constructor(t){this.http=t;}async list(t={}){return (await this.http.request("vs",{},t)).vs??{}}async get(t){let e=await this.http.request("vs",{},t),o=Object.entries(e.vs??{});if(o.length===0)throw new n("VPS not found",404);let r=o[0];if(!r)throw new n("VPS not found",404);let[,p]=r;return p}async create(t){return this.http.request("addvs",{},t)}async delete(t){return this.http.request("vs",{delete:t},{})}async start(t){return this.http.request("vs",{vpsid:t,action:"start"},{})}async stop(t){return this.http.request("vs",{vpsid:t,action:"stop"},{})}async restart(t){return this.http.request("vs",{vpsid:t,action:"restart"},{})}async poweroff(t){return this.http.request("vs",{vpsid:t,action:"poweroff"},{})}async suspend(t){return this.http.request("vs",{suspend:t},{})}async unsuspend(t){return this.http.request("vs",{unsuspend:t},{})}async rebuild(t,e){return this.http.request("rebuild",{},{vpsid:t,reos:E.REBUILD_REOS_FLAG,...e})}async clone(t,e){return this.http.request("clone",{},{vpsid:t,...e})}async migrate(t,e){return this.http.request("migrate",{},{vpsid:t,migrate:E.MIGRATE_FLAG,migrate_but:E.MIGRATE_BUT_FLAG,...e})}async status(t){return this.http.request("vstatus",{vpsid:t},{})}async vnc(t){return this.http.request("vnc",{vpsid:t},{})}async stats(t){return this.http.request("vps_stats",{},{vpsid:t})}};var H="https://registry.npmjs.org/virtualizorjs/latest";async function J(s){let t=new AbortController,e=setTimeout(()=>t.abort(),s);try{let o=await fetch(H,{signal:t.signal});if(!o.ok)throw new Error(`HTTP ${o.status}`);return await o.json()}finally{clearTimeout(e);}}function K(s,t){let e=s.split(".").map(Number),o=t.split(".").map(Number);return (o[0]??0)>(e[0]??0)||(o[0]??0)===(e[0]??0)&&(o[1]??0)>(e[1]??0)||(o[0]??0)===(e[0]??0)&&(o[1]??0)===(e[1]??0)&&(o[2]??0)>(e[2]??0)}var _=false;async function D(s,t,e){if(!(_&&true)){_=true;try{let r=(await J(e?.timeout??2e3)).version;if(!K(s,r))return;t.warn(`Update available: ${s} \u2192 ${r}`),console.log(),console.log(b(s,r)),console.log();}catch{}}}var W=M().version,L=class{vps;users;plans;tasks;logger;constructor(t){let e=t.logger??w;this.logger=e;let o={host:t.host,apiKey:t.apiKey,apiPass:t.apiPass??"",port:t.port??P.port,https:t.https??P.https,rejectUnauthorized:t.rejectUnauthorized??P.rejectUnauthorized,timeout:t.timeout??P.timeout,debug:t.debug??P.debug,logger:e,disableUpdateCheck:t.disableUpdateCheck??false},r=new v(o);this.vps=new S(r),this.users=new C(r),this.plans=new x(r),this.tasks=new V(r),o.disableUpdateCheck||D(W,e).catch(()=>{});}};function Y(s){return new L(s)}function X(s,t){let e=t?.as??"array",o=t?.separator??", ";if(!s)return e==="array"?[]:"";let r=[];if(Array.isArray(s))r=s.filter(Boolean);else if(typeof s=="string"){let p=s.trim();p===""?r=[]:p.includes(",")?r=p.split(",").map(i=>i.trim()).filter(Boolean):/\s+/.test(p)?r=p.split(/\s+/).map(i=>i.trim()).filter(Boolean):r=[p];}else typeof s=="object"&&(r=Object.values(s).filter(Boolean));return e==="array"?r:r.join(o)}
|
|
11
|
+
export{k as ConsoleLogger,n as VirtualizorApiError,L as VirtualizorClient,a as colors,O as createBox,N as createErrorBox,b as createUpdateBox,Y as createVirtualizorClient,w as defaultLogger,B as formatError,X as formatIps,g as symbols};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "virtualizorjs",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
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
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../package.json","../src/config/defaults.ts","../src/errors.ts","../src/auth.ts","../src/http.ts","../src/logger/formatting.ts","../src/logger/console-logger.ts","../src/logger/box.ts","../src/logger/error-formatter.ts","../src/resources/plans.ts","../src/resources/tasks.ts","../src/resources/users.ts","../src/constants/vps.ts","../src/resources/vps.ts","../src/utils/update-check.ts","../src/client.ts","../src/utils/format-ips.ts"],"names":["require_package","__commonJSMin","exports","module","DEFAULT_CONFIG","DEFAULT_TASK_POLLING","VirtualizorApiError","message","code","details","buildQueryString","params","apiKey","apiPass","clean","key","value","urlParams","CONNECTION_TIMEOUT","HttpClient","config","AgentClass","https","http","data","first","act","queryParams","bodyParams","allQueryParams","qs","redactedQs","path","bodyString","v","k","err","obj","depth","item","body","transport","options","resolve","reject","req","res","chunks","chunk","raw","parsed","connectionTimer","requestTimer","socket","isWindows","supportsColor","colorize","str","colors","symbols","boxChars","ConsoleLogger","prefix","timeString","args","error","defaultLogger","createBox","content","padding","borderColor","lines","innerWidth","l","colorFn","horizontal","top","bottom","paddedLines","line","padded","createUpdateBox","current","latest","formatError","verbose","PlansResource","planId","TasksResource","taskId","pollIntervalMs","timeoutMs","deadline","task","r","UsersResource","uid","VPS_CONSTANTS","VpsResource","filters","entries","vps","vpsId","REGISTRY_URL","fetchNpmRegistry","timeout","controller","timeoutId","response","isNewerVersion","c","updateChecked","checkForUpdates","currentVersion","logger","latestVersion","PACKAGE_VERSION","VirtualizorClient","resolved","createVirtualizorClient","formatIps","ips","as","separator","result","s"],"mappings":"qNAAA,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,KAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,OAAA,CAAA,EAAA,CAAA,EAAA,OAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,OAAA,CAAA,CAAA,IAAAA,CAAAA,CAAAC,CAAAA,CAAA,CAAAC,EAAAA,CAAAC,IAAA,CAAAA,CAAAA,CAAA,OAAA,CAAA,CACE,IAAA,CAAQ,eAAA,CACR,OAAA,CAAW,OAAA,CACX,WAAA,CAAe,yKACf,IAAA,CAAQ,iBAAA,CACR,MAAA,CAAU,kBAAA,CACV,KAAA,CAAS,mBAAA,CACT,OAAA,CAAW,CACT,IAAK,CACH,MAAA,CAAU,CACR,KAAA,CAAS,oBAAA,CACT,OAAA,CAAW,kBACb,CAAA,CACA,QAAW,CACT,KAAA,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AAS,CAACnE,CAAG,EAEjB,MAAW,OAAOgE,CAAAA,EAAQ,QAAA,GACxBG,CAAAA,CAAS,MAAA,CAAO,MAAA,CAAOH,CAAG,CAAA,CAAE,OAAO,OAAO,CAAA,CAAA,CAG5C,OAAOC,CAAAA,GAAO,OAAA,CAAUE,CAAAA,CAASA,CAAAA,CAAO,IAAA,CAAKD,CAAS,CACxD","file":"index.js","sourcesContent":["{\n \"name\": \"virtualizorjs\",\n \"version\": \"2.2.0\",\n \"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.\",\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"import\": {\n \"types\": \"./dist/index.d.mts\",\n \"default\": \"./dist/index.mjs\"\n },\n \"require\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n }\n }\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"test\": \"bun test\",\n \"test:watch\": \"bun test --watch\",\n \"coverage\": \"bun test --coverage\",\n \"typecheck\": \"tsc --noEmit\",\n \"lint\": \"biome check src tests\",\n \"lint:fix\": \"biome check --write src tests\",\n \"format\": \"biome format --write src tests\",\n \"release\": \"bun run build && bumpp\",\n \"prepublishOnly\": \"bun run build && bun run typecheck\",\n \"check-exports\": \"attw --pack .\",\n \"prepare\": \"husky\"\n },\n \"files\": [\"dist\", \"README.md\", \"LICENSE\"],\n \"keywords\": [\"virtualizor\", \"vps\", \"sdk\", \"api\", \"typescript\", \"nodejs\", \"bun\"],\n \"author\": \"kkMihai\",\n \"license\": \"MIT\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/kkMihai/virtualizorjs.git\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/kkMihai/virtualizorjs/issues\"\n},\n\"homepage\": \"https://github.com/kkMihai/virtualizorjs#readme\",\n\"engines\": {\n\"bun\": \">=1.3.0\"\n},\n\"devDependencies\": {\n \"@arethetypeswrong/cli\": \"^0.17.0\",\n \"@biomejs/biome\": \"^1.9.0\",\n \"@commitlint/cli\": \"^19.0.0\",\n \"@commitlint/config-conventional\": \"^19.0.0\",\n \"@types/bun\": \"latest\",\n \"bumpp\": \"^9.0.0\",\n \"husky\": \"^9.0.0\",\n \"tsup\": \"^8.0.0\",\n \"typescript\": \"^5.5.0\"\n},\n\"trustedDependencies\": [\n \"@biomejs/biome\"\n]\n}\n","export const DEFAULT_CONFIG = {\n port: 4085,\n https: true,\n rejectUnauthorized: false,\n timeout: 30000,\n debug: false,\n} as const;\n\nexport const DEFAULT_TASK_POLLING = {\n pollIntervalMs: 2000,\n timeoutMs: 120000,\n} as const;\n","export class VirtualizorApiError extends Error {\n readonly code: number;\n readonly details: Record<string, unknown> | undefined;\n\n constructor(message: string, code: number, details?: Record<string, unknown>) {\n super(message);\n this.name = 'VirtualizorApiError';\n this.code = code;\n this.details = details;\n }\n\n format(): string {\n return `[API Error ${this.code}] ${this.message}`;\n }\n}\n","import type { ApiParams } from './types/common.js';\n\nexport function buildQueryString(params: ApiParams, apiKey: string, apiPass: string): string {\n const clean: ApiParams = {};\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n clean[key] = value;\n }\n }\n\n const urlParams = new URLSearchParams();\n urlParams.set('api', 'json');\n urlParams.set('adminapikey', apiKey);\n urlParams.set('adminapipass', apiPass);\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 { VirtualizorApiError } from './errors.js';\nimport type { Logger } from './logger';\nimport type { ApiParams, VirtualizorResponse } from './types/common.js';\nimport type { ResolvedConfig } from './types/config.js';\n\nconst CONNECTION_TIMEOUT = 5000;\n\nexport class HttpClient {\n private readonly agent: http.Agent | https.Agent;\n private readonly logger: Logger;\n\n constructor(private readonly config: ResolvedConfig) {\n const AgentClass = config.https ? https.Agent : http.Agent;\n this.agent = new AgentClass({\n keepAlive: true,\n maxSockets: 50,\n maxFreeSockets: 10,\n scheduling: 'lifo',\n ...(config.https ? { rejectUnauthorized: config.rejectUnauthorized } : {}),\n });\n this.logger = config.logger;\n }\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: ApiParams = {},\n bodyParams: ApiParams = {},\n ): Promise<T> {\n const allQueryParams: ApiParams = { act, ...queryParams };\n const qs = buildQueryString(allQueryParams, this.config.apiKey, this.config.apiPass);\n\n if (this.config.debug) {\n const redactedQs = qs\n .replace(/adminapikey=[^&]*/, 'adminapikey=[REDACTED]')\n .replace(/adminapipass=[^&]*/, 'adminapipass=[REDACTED]');\n this.logger.debug(`Request: act=${act} path=/index.php${redactedQs}`);\n }\n\n const path = `/index.php${qs}`;\n\n const bodyString = Object.entries(bodyParams as Record<string, unknown>)\n .filter(([, v]) => v !== undefined)\n .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`)\n .join('&');\n\n try {\n const data = await this.rawRequest(path, bodyString || undefined);\n return this.parseResponse(data as T);\n } catch (err) {\n // Log the error when debug is enabled\n if (this.config.debug) {\n if (err instanceof VirtualizorApiError) {\n this.logger.error(`[Virtualizor] ● Error: [API Error ${err.code}] ${err.message}`);\n } else {\n this.logger.error(`[Virtualizor] ● Error: ${(err as Error).message}`);\n }\n }\n // Re-throw the error so callers can still handle it\n throw err;\n }\n }\n\n private validateJsonDepth(obj: unknown, depth = 0): void {\n const MAX_DEPTH = 100;\n if (depth > MAX_DEPTH) {\n throw new VirtualizorApiError('JSON depth limit exceeded', -32000);\n }\n if (typeof obj === 'object' && obj !== null) {\n if (Array.isArray(obj)) {\n for (const item of obj) {\n this.validateJsonDepth(item, depth + 1);\n }\n } else {\n for (const value of Object.values(obj as Record<string, unknown>)) {\n this.validateJsonDepth(value, depth + 1);\n }\n }\n }\n }\n\n destroy(): void {\n this.agent.destroy();\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 agent: this.agent,\n };\n\n return new Promise((resolve, reject) => {\n const req = transport.request(options, (res) => {\n const chunks: Buffer[] = [];\n\n res.on('data', (chunk: Buffer) => {\n chunks.push(chunk);\n });\n\n res.on('end', () => {\n const raw = Buffer.concat(chunks).toString('utf8');\n\n if (res.statusCode === 302 || res.statusCode === 301) {\n reject(\n new VirtualizorApiError(\n `Redirect detected (status ${res.statusCode}). Authentication failed. Location: ${res.headers.location}`,\n res.statusCode,\n ),\n );\n return;\n }\n\n try {\n const parsed = JSON.parse(raw);\n this.validateJsonDepth(parsed);\n resolve(parsed as VirtualizorResponse);\n } catch (err) {\n // Log the error when debug is enabled\n if (this.config.debug) {\n if (err instanceof VirtualizorApiError) {\n this.logger.error(`[Virtualizor] ● Error: [API Error ${err.code}] ${err.message}`);\n } else {\n this.logger.error(`[Virtualizor] ● Error: ${(err as Error).message}`);\n }\n }\n // Re-throw the error so callers can still handle it\n reject(\n new VirtualizorApiError(\n `Failed to parse response: ${(err as Error).message ?? 'Invalid JSON'}`,\n -32700,\n ),\n );\n }\n });\n\n res.on('error', (err) => {\n // Log the error when debug is enabled\n if (this.config.debug) {\n this.logger.error('[Virtualizor] ● Error: Response stream error', err as Error);\n }\n reject(\n new VirtualizorApiError(\n `Response stream error: ${(err as Error).message ?? 'Unknown error'}`,\n -32000,\n ),\n );\n });\n });\n\n const connectionTimer = setTimeout(() => {\n req.destroy(\n new VirtualizorApiError(`Connection timeout after ${CONNECTION_TIMEOUT}ms`, -32000),\n );\n }, CONNECTION_TIMEOUT);\n\n const requestTimer = setTimeout(() => {\n req.destroy(\n new VirtualizorApiError(`Request timed out after ${this.config.timeout}ms`, -32000),\n );\n }, this.config.timeout);\n\n req.once('socket', (socket) => {\n if (socket.connecting) {\n socket.once('connect', () => clearTimeout(connectionTimer));\n } else {\n clearTimeout(connectionTimer);\n }\n });\n\n req.once('close', () => {\n clearTimeout(connectionTimer);\n clearTimeout(requestTimer);\n });\n\n req.on('error', (err) => {\n if (err instanceof VirtualizorApiError) {\n reject(err);\n } else {\n reject(new VirtualizorApiError(`Request error ${err}`, -32000));\n }\n });\n\n if (body) {\n req.write(body);\n }\n\n req.end();\n });\n }\n}\n","const isWindows = process.platform === 'win32';\nconst supportsColor = process.env.NO_COLOR === undefined && process.stdout.isTTY;\n\nfunction colorize(code: number, str: string): string {\n return supportsColor ? `\\x1b[${code}m${str}\\x1b[0m` : str;\n}\n\nexport const colors = {\n red: (str: string) => colorize(31, str),\n green: (str: string) => colorize(32, str),\n yellow: (str: string) => colorize(33, str),\n blue: (str: string) => colorize(34, str),\n magenta: (str: string) => colorize(35, str),\n cyan: (str: string) => colorize(36, str),\n white: (str: string) => colorize(37, str),\n gray: (str: string) => colorize(90, str),\n dim: (str: string) => colorize(2, str),\n bold: (str: string) => colorize(1, str),\n underline: (str: string) => colorize(4, str),\n bgRed: (str: string) => colorize(41, str),\n bgGreen: (str: string) => colorize(42, str),\n bgYellow: (str: string) => colorize(43, str),\n bgBlue: (str: string) => colorize(44, str),\n bgCyan: (str: string) => colorize(46, str),\n};\n\nexport const symbols = {\n success: isWindows ? '√' : '✔',\n error: isWindows ? '×' : '✖',\n warning: isWindows ? '‼' : '⚠',\n info: isWindows ? 'i' : 'ℹ',\n bullet: '●',\n arrow: '→',\n chevron: '›',\n pointer: '❯',\n star: '★',\n};\n\nexport const boxChars = {\n topLeft: '┌',\n topRight: '┐',\n bottomLeft: '└',\n bottomRight: '┘',\n horizontal: '─',\n vertical: '│',\n};\n","import { colors, symbols } from './formatting.js';\nimport type { Logger } from './types.js';\n\nexport class ConsoleLogger implements Logger {\n constructor(private readonly prefix = 'Virtualizor') {}\n\n private timestamp(): string {\n const now = new Date();\n const timeString = now.toISOString().split('T')[1];\n return colors.dim(timeString ? timeString.slice(0, 8) : '00:00:00');\n }\n\n private tag(): string {\n return colors.cyan(`[${this.prefix}]`);\n }\n\n debug(message: string, ...args: unknown[]): void {\n console.log(\n this.timestamp(),\n this.tag(),\n colors.dim(symbols.bullet),\n colors.dim(message),\n ...args,\n );\n }\n\n info(message: string, ...args: unknown[]): void {\n console.log(this.timestamp(), this.tag(), colors.blue(symbols.info), message, ...args);\n }\n\n warn(message: string, ...args: unknown[]): void {\n console.log(\n this.timestamp(),\n this.tag(),\n colors.yellow(symbols.warning),\n colors.yellow(message),\n ...args,\n );\n }\n\n error(message: string, error?: Error): void {\n console.error(this.timestamp(), this.tag(), colors.red(symbols.error), colors.red(message));\n if (error?.stack) {\n console.error(colors.dim(error.stack.split('\\n').slice(1, 4).join('\\n')));\n }\n }\n\n success(message: string, ...args: unknown[]): void {\n console.log(\n this.timestamp(),\n this.tag(),\n colors.green(symbols.success),\n colors.green(message),\n ...args,\n );\n }\n}\n\nexport const defaultLogger = new ConsoleLogger();\n","import { boxChars, colors } from './formatting.js';\n\ninterface BoxOptions {\n title?: string;\n borderColor?: 'cyan' | 'yellow' | 'red' | 'green';\n padding?: number;\n}\n\nexport function createBox(content: string, options: BoxOptions = {}): string {\n const { padding = 1, borderColor = 'cyan' } = options;\n const lines = content.split('\\n');\n const maxLineWidth = Math.max(...lines.map((l) => l.length));\n const innerWidth = maxLineWidth + padding * 2;\n\n const colorFn = colors[borderColor] ?? colors.cyan;\n\n const horizontal = boxChars.horizontal.repeat(innerWidth);\n const top = `${boxChars.topLeft}${horizontal}${boxChars.topRight}`;\n const bottom = `${boxChars.bottomLeft}${horizontal}${boxChars.bottomRight}`;\n\n const paddedLines = lines.map((line) => {\n const padded = ' '.repeat(padding) + line + ' '.repeat(padding);\n return `${boxChars.vertical}${padded.padEnd(innerWidth)}${boxChars.vertical}`;\n });\n\n return [colorFn(top), ...paddedLines.map((l) => colorFn(l)), colorFn(bottom)].join('\\n');\n}\n\nexport function createUpdateBox(current: string, latest: string): string {\n const content = [\n 'New version available!',\n '',\n `Current: ${current}`,\n `Latest: ${latest}`,\n '',\n 'Run: npm install virtualizorjs@latest',\n ].join('\\n');\n\n return createBox(content, { borderColor: 'yellow' });\n}\n\nexport function createErrorBox(title: string, message: string, hint?: string): string {\n const lines = [title, '', message];\n if (hint) {\n lines.push('', hint);\n }\n return createBox(lines.join('\\n'), { borderColor: 'red' });\n}\n","import { VirtualizorApiError } from '../errors.js';\nimport { colors, symbols } from './formatting.js';\n\nexport function formatError(error: Error, verbose = false): string {\n if (error instanceof VirtualizorApiError) {\n const details =\n error.details && verbose ? `\\n${colors.dim(JSON.stringify(error.details, null, 2))}` : '';\n return `${symbols.error} ${colors.red(`[API Error ${error.code}]`)} ${error.message}${details}`;\n }\n\n return `${symbols.error} ${colors.red(error.message)}`;\n}\n","import type { HttpClient } from '../http.js';\nimport type { ApiParams } from '../types/common.js';\nimport type { AsyncTaskResult, VirtualizorResponse } from '../types/common.js';\nimport type { CreatePlanParams, Plan } from '../types/plans.js';\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);\n }\n\n async delete(planId: string): Promise<AsyncTaskResult> {\n return this.http.request<AsyncTaskResult>('plans', {}, { delete: planId });\n }\n}\n","import { DEFAULT_TASK_POLLING } from '../config/defaults.js';\nimport { VirtualizorApiError } from '../errors.js';\nimport 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 {\n pollIntervalMs = DEFAULT_TASK_POLLING.pollIntervalMs,\n timeoutMs = DEFAULT_TASK_POLLING.timeoutMs,\n } = 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 VirtualizorApiError('Task not found', 404);\n if (task.status === '1' || task.status === 'done') return task;\n if (task.status === 'error' || task.status === '-1') {\n throw new VirtualizorApiError('Task failed', 500);\n }\n await new Promise((r) => setTimeout(r, pollIntervalMs));\n }\n\n throw new VirtualizorApiError(`Task timed out after ${timeoutMs}ms`, 408);\n }\n}\n","import type { HttpClient } from '../http.js';\nimport type { ApiParams } from '../types/common.js';\nimport type { AsyncTaskResult, VirtualizorResponse } from '../types/common.js';\nimport type { CreateUserParams, User } from '../types/users.js';\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);\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","// VPS operation constants\nexport const VPS_CONSTANTS = {\n // Rebuild operation requires reos=1 flag\n REBUILD_REOS_FLAG: 1,\n // Migrate operation requires migrate=1 flag\n MIGRATE_FLAG: 1,\n // Migrate operation requires migrate_but=1 flag\n MIGRATE_BUT_FLAG: 1,\n} as const;\n","import { VPS_CONSTANTS } from '../constants/vps.js';\nimport { VirtualizorApiError } from '../errors.js';\nimport 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\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>('vs', {}, filters);\n return res.vs ?? {};\n }\n\n async get(filters: ListVPSParams): Promise<VPS> {\n const res = await this.http.request<GetVPSResponse>('vs', {}, filters);\n const entries = Object.entries(res.vs ?? {});\n if (entries.length === 0) {\n throw new VirtualizorApiError('VPS not found', 404);\n }\n const first = entries[0];\n if (!first) {\n throw new VirtualizorApiError('VPS not found', 404);\n }\n const [, vps] = first;\n return vps;\n }\n\n async create(params: CreateVPSParams): Promise<AsyncTaskResult> {\n return this.http.request<AsyncTaskResult>('addvs', {}, 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>(\n 'rebuild',\n {},\n {\n vpsid: vpsId,\n reos: VPS_CONSTANTS.REBUILD_REOS_FLAG,\n ...params,\n },\n );\n }\n\n async clone(vpsId: string, params: CloneVPSParams): Promise<AsyncTaskResult> {\n return this.http.request<AsyncTaskResult>(\n 'clone',\n {},\n {\n vpsid: vpsId,\n ...params,\n },\n );\n }\n\n async migrate(vpsId: string, params: MigrateVPSParams): Promise<AsyncTaskResult> {\n return this.http.request<AsyncTaskResult>(\n 'migrate',\n {},\n {\n vpsid: vpsId,\n migrate: VPS_CONSTANTS.MIGRATE_FLAG,\n migrate_but: VPS_CONSTANTS.MIGRATE_BUT_FLAG,\n ...params,\n },\n );\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 { type Logger, createUpdateBox } from '../logger';\n\nconst REGISTRY_URL = 'https://registry.npmjs.org/virtualizorjs/latest';\n\ninterface NpmRegistryResponse {\n version: string;\n}\n\nasync function fetchNpmRegistry(timeout: number): Promise<NpmRegistryResponse> {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), timeout);\n\n try {\n const response = await fetch(REGISTRY_URL, { signal: controller.signal });\n if (!response.ok) {\n throw new Error(`HTTP ${response.status}`);\n }\n return (await response.json()) as Promise<NpmRegistryResponse>;\n } finally {\n clearTimeout(timeoutId);\n }\n}\n\nfunction isNewerVersion(current: string, latest: string): boolean {\n const c = current.split('.').map(Number);\n const l = latest.split('.').map(Number);\n return (\n (l[0] ?? 0) > (c[0] ?? 0) ||\n ((l[0] ?? 0) === (c[0] ?? 0) && (l[1] ?? 0) > (c[1] ?? 0)) ||\n ((l[0] ?? 0) === (c[0] ?? 0) && (l[1] ?? 0) === (c[1] ?? 0) && (l[2] ?? 0) > (c[2] ?? 0))\n );\n}\n\nlet updateChecked = false;\n\nexport async function checkForUpdates(\n currentVersion: string,\n logger: Logger,\n options?: { timeout?: number; force?: boolean },\n): Promise<void> {\n if (updateChecked && !options?.force) return;\n updateChecked = true;\n\n try {\n const response = await fetchNpmRegistry(options?.timeout ?? 2000);\n const latestVersion = response.version;\n\n if (!isNewerVersion(currentVersion, latestVersion)) return;\n\n logger.warn(`Update available: ${currentVersion} → ${latestVersion}`);\n console.log();\n console.log(createUpdateBox(currentVersion, latestVersion));\n console.log();\n } catch {\n // Silently fail\n }\n}\n","import { DEFAULT_CONFIG } from './config/defaults.js';\nimport { VirtualizorApiError } from './errors.js';\nimport { HttpClient } from './http.js';\nimport { type Logger, defaultLogger } from './logger';\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';\nimport { checkForUpdates } from './utils/update-check';\n\nconst PACKAGE_VERSION = require('../package.json').version as string;\n\nexport class VirtualizorClient {\n readonly vps: VpsResource;\n readonly users: UsersResource;\n readonly plans: PlansResource;\n readonly tasks: TasksResource;\n readonly logger: Logger;\n\n constructor(config: VirtualizorConfig) {\n const logger = config.logger ?? defaultLogger;\n this.logger = logger;\n\n const resolved: ResolvedConfig = {\n host: config.host,\n apiKey: config.apiKey,\n apiPass: config.apiPass ?? '',\n port: config.port ?? DEFAULT_CONFIG.port,\n https: config.https ?? DEFAULT_CONFIG.https,\n rejectUnauthorized: config.rejectUnauthorized ?? DEFAULT_CONFIG.rejectUnauthorized,\n timeout: config.timeout ?? DEFAULT_CONFIG.timeout,\n debug: config.debug ?? DEFAULT_CONFIG.debug,\n logger,\n disableUpdateCheck: config.disableUpdateCheck ?? false,\n };\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 if (!resolved.disableUpdateCheck) {\n checkForUpdates(PACKAGE_VERSION, logger).catch(() => {});\n }\n }\n}\n\nexport function createVirtualizorClient(config: VirtualizorConfig): VirtualizorClient {\n return new VirtualizorClient(config);\n}\n\nexport { VirtualizorApiError };\n","export type IpsInput = string[] | Record<string, string> | string | undefined | null;\n\nexport type FormatIpsOptions = {\n /**\n * Choose the return type. Defaults to 'array'.\n * - 'array' returns string[]\n * - 'string' returns a joined string using `separator`\n */\n as?: 'array' | 'string';\n /** Separator used when returning a string. Defaults to ', '. */\n separator?: string;\n};\n\n/**\n * formatIps\n * - Default behavior: return an array of IP strings (string[])\n * - If options.as === 'string' it returns a joined string using options.separator\n */\nexport function formatIps(ips: IpsInput): string[];\nexport function formatIps(ips: IpsInput, options: FormatIpsOptions & { as: 'string' }): string;\nexport function formatIps(ips: IpsInput, options?: FormatIpsOptions): string | string[] {\n const as = options?.as ?? 'array';\n const separator = options?.separator ?? ', ';\n\n if (!ips) {\n return as === 'array' ? [] : '';\n }\n\n let result: string[] = [];\n\n if (Array.isArray(ips)) {\n result = ips.filter(Boolean);\n } else if (typeof ips === 'string') {\n const str = ips.trim();\n if (str === '') {\n result = [];\n } else if (str.includes(',')) {\n result = str\n .split(',')\n .map((s) => s.trim())\n .filter(Boolean);\n } else if (/\\s+/.test(str)) {\n result = str\n .split(/\\s+/)\n .map((s) => s.trim())\n .filter(Boolean);\n } else {\n result = [str];\n }\n } else if (typeof ips === 'object') {\n result = Object.values(ips).filter(Boolean);\n }\n\n return as === 'array' ? result : result.join(separator);\n}\n"]}
|
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../package.json","../src/config/defaults.ts","../src/errors.ts","../src/auth.ts","../src/http.ts","../src/logger/formatting.ts","../src/logger/console-logger.ts","../src/logger/box.ts","../src/logger/error-formatter.ts","../src/resources/plans.ts","../src/resources/tasks.ts","../src/resources/users.ts","../src/constants/vps.ts","../src/resources/vps.ts","../src/utils/update-check.ts","../src/client.ts","../src/utils/format-ips.ts"],"names":["require_package","__commonJSMin","exports","module","DEFAULT_CONFIG","DEFAULT_TASK_POLLING","VirtualizorApiError","message","code","details","buildQueryString","params","apiKey","apiPass","clean","key","value","urlParams","CONNECTION_TIMEOUT","HttpClient","config","AgentClass","https","http","data","first","act","queryParams","bodyParams","allQueryParams","qs","redactedQs","path","bodyString","v","k","err","obj","depth","item","body","transport","options","resolve","reject","req","res","chunks","chunk","raw","parsed","connectionTimer","requestTimer","socket","isWindows","supportsColor","colorize","str","colors","symbols","boxChars","ConsoleLogger","prefix","timeString","args","error","defaultLogger","createBox","content","padding","borderColor","lines","innerWidth","l","colorFn","horizontal","top","bottom","paddedLines","line","padded","createUpdateBox","current","latest","formatError","verbose","PlansResource","planId","TasksResource","taskId","pollIntervalMs","timeoutMs","deadline","task","r","UsersResource","uid","VPS_CONSTANTS","VpsResource","filters","entries","vps","vpsId","REGISTRY_URL","fetchNpmRegistry","timeout","controller","timeoutId","response","isNewerVersion","c","updateChecked","checkForUpdates","currentVersion","logger","latestVersion","PACKAGE_VERSION","Virtualiz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AAAA,CAAI,MAAA,CAAO,OAAO,CAAA,CAAA,KAAA,GAClB,OAAOA,CAAAA,EAAQ,QAAA,CAAU,CAClC,IAAMhE,CAAAA,CAAMgE,CAAAA,CAAI,IAAA,EAAK,CACjBhE,CAAAA,GAAQ,EAAA,CACVmE,CAAAA,CAAS,EAAC,CACDnE,CAAAA,CAAI,QAAA,CAAS,GAAG,CAAA,CACzBmE,CAAAA,CAASnE,CAAAA,CACN,MAAM,GAAG,CAAA,CACT,GAAA,CAAKoE,CAAAA,EAAMA,CAAAA,CAAE,IAAA,EAAM,CAAA,CACnB,MAAA,CAAO,OAAO,CAAA,CACR,KAAA,CAAM,IAAA,CAAKpE,CAAG,CAAA,CACvBmE,CAAAA,CAASnE,EACN,KAAA,CAAM,KAAK,CAAA,CACX,GAAA,CAAKoE,CAAAA,EAAMA,CAAAA,CAAE,IAAA,EAAM,CAAA,CACnB,MAAA,CAAO,OAAO,CAAA,CAEjBD,CAAAA,CAAS,CAACnE,CAAG,EAEjB,MAAW,OAAOgE,CAAAA,EAAQ,QAAA,GACxBG,CAAAA,CAAS,MAAA,CAAO,MAAA,CAAOH,CAAG,CAAA,CAAE,OAAO,OAAO,CAAA,CAAA,CAG5C,OAAOC,CAAAA,GAAO,OAAA,CAAUE,CAAAA,CAASA,CAAAA,CAAO,IAAA,CAAKD,CAAS,CACxD","file":"index.mjs","sourcesContent":["{\n \"name\": \"virtualizorjs\",\n \"version\": \"2.2.0\",\n \"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.\",\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"import\": {\n \"types\": \"./dist/index.d.mts\",\n \"default\": \"./dist/index.mjs\"\n },\n \"require\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n }\n }\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"test\": \"bun test\",\n \"test:watch\": \"bun test --watch\",\n \"coverage\": \"bun test --coverage\",\n \"typecheck\": \"tsc --noEmit\",\n \"lint\": \"biome check src tests\",\n \"lint:fix\": \"biome check --write src tests\",\n \"format\": \"biome format --write src tests\",\n \"release\": \"bun run build && bumpp\",\n \"prepublishOnly\": \"bun run build && bun run typecheck\",\n \"check-exports\": \"attw --pack .\",\n \"prepare\": \"husky\"\n },\n \"files\": [\"dist\", \"README.md\", \"LICENSE\"],\n \"keywords\": [\"virtualizor\", \"vps\", \"sdk\", \"api\", \"typescript\", \"nodejs\", \"bun\"],\n \"author\": \"kkMihai\",\n \"license\": \"MIT\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/kkMihai/virtualizorjs.git\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/kkMihai/virtualizorjs/issues\"\n},\n\"homepage\": \"https://github.com/kkMihai/virtualizorjs#readme\",\n\"engines\": {\n\"bun\": \">=1.3.0\"\n},\n\"devDependencies\": {\n \"@arethetypeswrong/cli\": \"^0.17.0\",\n \"@biomejs/biome\": \"^1.9.0\",\n \"@commitlint/cli\": \"^19.0.0\",\n \"@commitlint/config-conventional\": \"^19.0.0\",\n \"@types/bun\": \"latest\",\n \"bumpp\": \"^9.0.0\",\n \"husky\": \"^9.0.0\",\n \"tsup\": \"^8.0.0\",\n \"typescript\": \"^5.5.0\"\n},\n\"trustedDependencies\": [\n \"@biomejs/biome\"\n]\n}\n","export const DEFAULT_CONFIG = {\n port: 4085,\n https: true,\n rejectUnauthorized: false,\n timeout: 30000,\n debug: false,\n} as const;\n\nexport const DEFAULT_TASK_POLLING = {\n pollIntervalMs: 2000,\n timeoutMs: 120000,\n} as const;\n","export class VirtualizorApiError extends Error {\n readonly code: number;\n readonly details: Record<string, unknown> | undefined;\n\n constructor(message: string, code: number, details?: Record<string, unknown>) {\n super(message);\n this.name = 'VirtualizorApiError';\n this.code = code;\n this.details = details;\n }\n\n format(): string {\n return `[API Error ${this.code}] ${this.message}`;\n }\n}\n","import type { ApiParams } from './types/common.js';\n\nexport function buildQueryString(params: ApiParams, apiKey: string, apiPass: string): string {\n const clean: ApiParams = {};\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n clean[key] = value;\n }\n }\n\n const urlParams = new URLSearchParams();\n urlParams.set('api', 'json');\n urlParams.set('adminapikey', apiKey);\n urlParams.set('adminapipass', apiPass);\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 { VirtualizorApiError } from './errors.js';\nimport type { Logger } from './logger';\nimport type { ApiParams, VirtualizorResponse } from './types/common.js';\nimport type { ResolvedConfig } from './types/config.js';\n\nconst CONNECTION_TIMEOUT = 5000;\n\nexport class HttpClient {\n private readonly agent: http.Agent | https.Agent;\n private readonly logger: Logger;\n\n constructor(private readonly config: ResolvedConfig) {\n const AgentClass = config.https ? https.Agent : http.Agent;\n this.agent = new AgentClass({\n keepAlive: true,\n maxSockets: 50,\n maxFreeSockets: 10,\n scheduling: 'lifo',\n ...(config.https ? { rejectUnauthorized: config.rejectUnauthorized } : {}),\n });\n this.logger = config.logger;\n }\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: ApiParams = {},\n bodyParams: ApiParams = {},\n ): Promise<T> {\n const allQueryParams: ApiParams = { act, ...queryParams };\n const qs = buildQueryString(allQueryParams, this.config.apiKey, this.config.apiPass);\n\n if (this.config.debug) {\n const redactedQs = qs\n .replace(/adminapikey=[^&]*/, 'adminapikey=[REDACTED]')\n .replace(/adminapipass=[^&]*/, 'adminapipass=[REDACTED]');\n this.logger.debug(`Request: act=${act} path=/index.php${redactedQs}`);\n }\n\n const path = `/index.php${qs}`;\n\n const bodyString = Object.entries(bodyParams as Record<string, unknown>)\n .filter(([, v]) => v !== undefined)\n .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`)\n .join('&');\n\n try {\n const data = await this.rawRequest(path, bodyString || undefined);\n return this.parseResponse(data as T);\n } catch (err) {\n // Log the error when debug is enabled\n if (this.config.debug) {\n if (err instanceof VirtualizorApiError) {\n this.logger.error(`[Virtualizor] ● Error: [API Error ${err.code}] ${err.message}`);\n } else {\n this.logger.error(`[Virtualizor] ● Error: ${(err as Error).message}`);\n }\n }\n // Re-throw the error so callers can still handle it\n throw err;\n }\n }\n\n private validateJsonDepth(obj: unknown, depth = 0): void {\n const MAX_DEPTH = 100;\n if (depth > MAX_DEPTH) {\n throw new VirtualizorApiError('JSON depth limit exceeded', -32000);\n }\n if (typeof obj === 'object' && obj !== null) {\n if (Array.isArray(obj)) {\n for (const item of obj) {\n this.validateJsonDepth(item, depth + 1);\n }\n } else {\n for (const value of Object.values(obj as Record<string, unknown>)) {\n this.validateJsonDepth(value, depth + 1);\n }\n }\n }\n }\n\n destroy(): void {\n this.agent.destroy();\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 agent: this.agent,\n };\n\n return new Promise((resolve, reject) => {\n const req = transport.request(options, (res) => {\n const chunks: Buffer[] = [];\n\n res.on('data', (chunk: Buffer) => {\n chunks.push(chunk);\n });\n\n res.on('end', () => {\n const raw = Buffer.concat(chunks).toString('utf8');\n\n if (res.statusCode === 302 || res.statusCode === 301) {\n reject(\n new VirtualizorApiError(\n `Redirect detected (status ${res.statusCode}). Authentication failed. Location: ${res.headers.location}`,\n res.statusCode,\n ),\n );\n return;\n }\n\n try {\n const parsed = JSON.parse(raw);\n this.validateJsonDepth(parsed);\n resolve(parsed as VirtualizorResponse);\n } catch (err) {\n // Log the error when debug is enabled\n if (this.config.debug) {\n if (err instanceof VirtualizorApiError) {\n this.logger.error(`[Virtualizor] ● Error: [API Error ${err.code}] ${err.message}`);\n } else {\n this.logger.error(`[Virtualizor] ● Error: ${(err as Error).message}`);\n }\n }\n // Re-throw the error so callers can still handle it\n reject(\n new VirtualizorApiError(\n `Failed to parse response: ${(err as Error).message ?? 'Invalid JSON'}`,\n -32700,\n ),\n );\n }\n });\n\n res.on('error', (err) => {\n // Log the error when debug is enabled\n if (this.config.debug) {\n this.logger.error('[Virtualizor] ● Error: Response stream error', err as Error);\n }\n reject(\n new VirtualizorApiError(\n `Response stream error: ${(err as Error).message ?? 'Unknown error'}`,\n -32000,\n ),\n );\n });\n });\n\n const connectionTimer = setTimeout(() => {\n req.destroy(\n new VirtualizorApiError(`Connection timeout after ${CONNECTION_TIMEOUT}ms`, -32000),\n );\n }, CONNECTION_TIMEOUT);\n\n const requestTimer = setTimeout(() => {\n req.destroy(\n new VirtualizorApiError(`Request timed out after ${this.config.timeout}ms`, -32000),\n );\n }, this.config.timeout);\n\n req.once('socket', (socket) => {\n if (socket.connecting) {\n socket.once('connect', () => clearTimeout(connectionTimer));\n } else {\n clearTimeout(connectionTimer);\n }\n });\n\n req.once('close', () => {\n clearTimeout(connectionTimer);\n clearTimeout(requestTimer);\n });\n\n req.on('error', (err) => {\n if (err instanceof VirtualizorApiError) {\n reject(err);\n } else {\n reject(new VirtualizorApiError(`Request error ${err}`, -32000));\n }\n });\n\n if (body) {\n req.write(body);\n }\n\n req.end();\n });\n }\n}\n","const isWindows = process.platform === 'win32';\nconst supportsColor = process.env.NO_COLOR === undefined && process.stdout.isTTY;\n\nfunction colorize(code: number, str: string): string {\n return supportsColor ? `\\x1b[${code}m${str}\\x1b[0m` : str;\n}\n\nexport const colors = {\n red: (str: string) => colorize(31, str),\n green: (str: string) => colorize(32, str),\n yellow: (str: string) => colorize(33, str),\n blue: (str: string) => colorize(34, str),\n magenta: (str: string) => colorize(35, str),\n cyan: (str: string) => colorize(36, str),\n white: (str: string) => colorize(37, str),\n gray: (str: string) => colorize(90, str),\n dim: (str: string) => colorize(2, str),\n bold: (str: string) => colorize(1, str),\n underline: (str: string) => colorize(4, str),\n bgRed: (str: string) => colorize(41, str),\n bgGreen: (str: string) => colorize(42, str),\n bgYellow: (str: string) => colorize(43, str),\n bgBlue: (str: string) => colorize(44, str),\n bgCyan: (str: string) => colorize(46, str),\n};\n\nexport const symbols = {\n success: isWindows ? '√' : '✔',\n error: isWindows ? '×' : '✖',\n warning: isWindows ? '‼' : '⚠',\n info: isWindows ? 'i' : 'ℹ',\n bullet: '●',\n arrow: '→',\n chevron: '›',\n pointer: '❯',\n star: '★',\n};\n\nexport const boxChars = {\n topLeft: '┌',\n topRight: '┐',\n bottomLeft: '└',\n bottomRight: '┘',\n horizontal: '─',\n vertical: '│',\n};\n","import { colors, symbols } from './formatting.js';\nimport type { Logger } from './types.js';\n\nexport class ConsoleLogger implements Logger {\n constructor(private readonly prefix = 'Virtualizor') {}\n\n private timestamp(): string {\n const now = new Date();\n const timeString = now.toISOString().split('T')[1];\n return colors.dim(timeString ? timeString.slice(0, 8) : '00:00:00');\n }\n\n private tag(): string {\n return colors.cyan(`[${this.prefix}]`);\n }\n\n debug(message: string, ...args: unknown[]): void {\n console.log(\n this.timestamp(),\n this.tag(),\n colors.dim(symbols.bullet),\n colors.dim(message),\n ...args,\n );\n }\n\n info(message: string, ...args: unknown[]): void {\n console.log(this.timestamp(), this.tag(), colors.blue(symbols.info), message, ...args);\n }\n\n warn(message: string, ...args: unknown[]): void {\n console.log(\n this.timestamp(),\n this.tag(),\n colors.yellow(symbols.warning),\n colors.yellow(message),\n ...args,\n );\n }\n\n error(message: string, error?: Error): void {\n console.error(this.timestamp(), this.tag(), colors.red(symbols.error), colors.red(message));\n if (error?.stack) {\n console.error(colors.dim(error.stack.split('\\n').slice(1, 4).join('\\n')));\n }\n }\n\n success(message: string, ...args: unknown[]): void {\n console.log(\n this.timestamp(),\n this.tag(),\n colors.green(symbols.success),\n colors.green(message),\n ...args,\n );\n }\n}\n\nexport const defaultLogger = new ConsoleLogger();\n","import { boxChars, colors } from './formatting.js';\n\ninterface BoxOptions {\n title?: string;\n borderColor?: 'cyan' | 'yellow' | 'red' | 'green';\n padding?: number;\n}\n\nexport function createBox(content: string, options: BoxOptions = {}): string {\n const { padding = 1, borderColor = 'cyan' } = options;\n const lines = content.split('\\n');\n const maxLineWidth = Math.max(...lines.map((l) => l.length));\n const innerWidth = maxLineWidth + padding * 2;\n\n const colorFn = colors[borderColor] ?? colors.cyan;\n\n const horizontal = boxChars.horizontal.repeat(innerWidth);\n const top = `${boxChars.topLeft}${horizontal}${boxChars.topRight}`;\n const bottom = `${boxChars.bottomLeft}${horizontal}${boxChars.bottomRight}`;\n\n const paddedLines = lines.map((line) => {\n const padded = ' '.repeat(padding) + line + ' '.repeat(padding);\n return `${boxChars.vertical}${padded.padEnd(innerWidth)}${boxChars.vertical}`;\n });\n\n return [colorFn(top), ...paddedLines.map((l) => colorFn(l)), colorFn(bottom)].join('\\n');\n}\n\nexport function createUpdateBox(current: string, latest: string): string {\n const content = [\n 'New version available!',\n '',\n `Current: ${current}`,\n `Latest: ${latest}`,\n '',\n 'Run: npm install virtualizorjs@latest',\n ].join('\\n');\n\n return createBox(content, { borderColor: 'yellow' });\n}\n\nexport function createErrorBox(title: string, message: string, hint?: string): string {\n const lines = [title, '', message];\n if (hint) {\n lines.push('', hint);\n }\n return createBox(lines.join('\\n'), { borderColor: 'red' });\n}\n","import { VirtualizorApiError } from '../errors.js';\nimport { colors, symbols } from './formatting.js';\n\nexport function formatError(error: Error, verbose = false): string {\n if (error instanceof VirtualizorApiError) {\n const details =\n error.details && verbose ? `\\n${colors.dim(JSON.stringify(error.details, null, 2))}` : '';\n return `${symbols.error} ${colors.red(`[API Error ${error.code}]`)} ${error.message}${details}`;\n }\n\n return `${symbols.error} ${colors.red(error.message)}`;\n}\n","import type { HttpClient } from '../http.js';\nimport type { ApiParams } from '../types/common.js';\nimport type { AsyncTaskResult, VirtualizorResponse } from '../types/common.js';\nimport type { CreatePlanParams, Plan } from '../types/plans.js';\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);\n }\n\n async delete(planId: string): Promise<AsyncTaskResult> {\n return this.http.request<AsyncTaskResult>('plans', {}, { delete: planId });\n }\n}\n","import { DEFAULT_TASK_POLLING } from '../config/defaults.js';\nimport { VirtualizorApiError } from '../errors.js';\nimport 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 {\n pollIntervalMs = DEFAULT_TASK_POLLING.pollIntervalMs,\n timeoutMs = DEFAULT_TASK_POLLING.timeoutMs,\n } = 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 VirtualizorApiError('Task not found', 404);\n if (task.status === '1' || task.status === 'done') return task;\n if (task.status === 'error' || task.status === '-1') {\n throw new VirtualizorApiError('Task failed', 500);\n }\n await new Promise((r) => setTimeout(r, pollIntervalMs));\n }\n\n throw new VirtualizorApiError(`Task timed out after ${timeoutMs}ms`, 408);\n }\n}\n","import type { HttpClient } from '../http.js';\nimport type { ApiParams } from '../types/common.js';\nimport type { AsyncTaskResult, VirtualizorResponse } from '../types/common.js';\nimport type { CreateUserParams, User } from '../types/users.js';\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);\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","// VPS operation constants\nexport const VPS_CONSTANTS = {\n // Rebuild operation requires reos=1 flag\n REBUILD_REOS_FLAG: 1,\n // Migrate operation requires migrate=1 flag\n MIGRATE_FLAG: 1,\n // Migrate operation requires migrate_but=1 flag\n MIGRATE_BUT_FLAG: 1,\n} as const;\n","import { VPS_CONSTANTS } from '../constants/vps.js';\nimport { VirtualizorApiError } from '../errors.js';\nimport 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\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>('vs', {}, filters);\n return res.vs ?? {};\n }\n\n async get(filters: ListVPSParams): Promise<VPS> {\n const res = await this.http.request<GetVPSResponse>('vs', {}, filters);\n const entries = Object.entries(res.vs ?? {});\n if (entries.length === 0) {\n throw new VirtualizorApiError('VPS not found', 404);\n }\n const first = entries[0];\n if (!first) {\n throw new VirtualizorApiError('VPS not found', 404);\n }\n const [, vps] = first;\n return vps;\n }\n\n async create(params: CreateVPSParams): Promise<AsyncTaskResult> {\n return this.http.request<AsyncTaskResult>('addvs', {}, 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>(\n 'rebuild',\n {},\n {\n vpsid: vpsId,\n reos: VPS_CONSTANTS.REBUILD_REOS_FLAG,\n ...params,\n },\n );\n }\n\n async clone(vpsId: string, params: CloneVPSParams): Promise<AsyncTaskResult> {\n return this.http.request<AsyncTaskResult>(\n 'clone',\n {},\n {\n vpsid: vpsId,\n ...params,\n },\n );\n }\n\n async migrate(vpsId: string, params: MigrateVPSParams): Promise<AsyncTaskResult> {\n return this.http.request<AsyncTaskResult>(\n 'migrate',\n {},\n {\n vpsid: vpsId,\n migrate: VPS_CONSTANTS.MIGRATE_FLAG,\n migrate_but: VPS_CONSTANTS.MIGRATE_BUT_FLAG,\n ...params,\n },\n );\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 { type Logger, createUpdateBox } from '../logger';\n\nconst REGISTRY_URL = 'https://registry.npmjs.org/virtualizorjs/latest';\n\ninterface NpmRegistryResponse {\n version: string;\n}\n\nasync function fetchNpmRegistry(timeout: number): Promise<NpmRegistryResponse> {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), timeout);\n\n try {\n const response = await fetch(REGISTRY_URL, { signal: controller.signal });\n if (!response.ok) {\n throw new Error(`HTTP ${response.status}`);\n }\n return (await response.json()) as Promise<NpmRegistryResponse>;\n } finally {\n clearTimeout(timeoutId);\n }\n}\n\nfunction isNewerVersion(current: string, latest: string): boolean {\n const c = current.split('.').map(Number);\n const l = latest.split('.').map(Number);\n return (\n (l[0] ?? 0) > (c[0] ?? 0) ||\n ((l[0] ?? 0) === (c[0] ?? 0) && (l[1] ?? 0) > (c[1] ?? 0)) ||\n ((l[0] ?? 0) === (c[0] ?? 0) && (l[1] ?? 0) === (c[1] ?? 0) && (l[2] ?? 0) > (c[2] ?? 0))\n );\n}\n\nlet updateChecked = false;\n\nexport async function checkForUpdates(\n currentVersion: string,\n logger: Logger,\n options?: { timeout?: number; force?: boolean },\n): Promise<void> {\n if (updateChecked && !options?.force) return;\n updateChecked = true;\n\n try {\n const response = await fetchNpmRegistry(options?.timeout ?? 2000);\n const latestVersion = response.version;\n\n if (!isNewerVersion(currentVersion, latestVersion)) return;\n\n logger.warn(`Update available: ${currentVersion} → ${latestVersion}`);\n console.log();\n console.log(createUpdateBox(currentVersion, latestVersion));\n console.log();\n } catch {\n // Silently fail\n }\n}\n","import { DEFAULT_CONFIG } from './config/defaults.js';\nimport { VirtualizorApiError } from './errors.js';\nimport { HttpClient } from './http.js';\nimport { type Logger, defaultLogger } from './logger';\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';\nimport { checkForUpdates } from './utils/update-check';\n\nconst PACKAGE_VERSION = require('../package.json').version as string;\n\nexport class VirtualizorClient {\n readonly vps: VpsResource;\n readonly users: UsersResource;\n readonly plans: PlansResource;\n readonly tasks: TasksResource;\n readonly logger: Logger;\n\n constructor(config: VirtualizorConfig) {\n const logger = config.logger ?? defaultLogger;\n this.logger = logger;\n\n const resolved: ResolvedConfig = {\n host: config.host,\n apiKey: config.apiKey,\n apiPass: config.apiPass ?? '',\n port: config.port ?? DEFAULT_CONFIG.port,\n https: config.https ?? DEFAULT_CONFIG.https,\n rejectUnauthorized: config.rejectUnauthorized ?? DEFAULT_CONFIG.rejectUnauthorized,\n timeout: config.timeout ?? DEFAULT_CONFIG.timeout,\n debug: config.debug ?? DEFAULT_CONFIG.debug,\n logger,\n disableUpdateCheck: config.disableUpdateCheck ?? false,\n };\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 if (!resolved.disableUpdateCheck) {\n checkForUpdates(PACKAGE_VERSION, logger).catch(() => {});\n }\n }\n}\n\nexport function createVirtualizorClient(config: VirtualizorConfig): VirtualizorClient {\n return new VirtualizorClient(config);\n}\n\nexport { VirtualizorApiError };\n","export type IpsInput = string[] | Record<string, string> | string | undefined | null;\n\nexport type FormatIpsOptions = {\n /**\n * Choose the return type. Defaults to 'array'.\n * - 'array' returns string[]\n * - 'string' returns a joined string using `separator`\n */\n as?: 'array' | 'string';\n /** Separator used when returning a string. Defaults to ', '. */\n separator?: string;\n};\n\n/**\n * formatIps\n * - Default behavior: return an array of IP strings (string[])\n * - If options.as === 'string' it returns a joined string using options.separator\n */\nexport function formatIps(ips: IpsInput): string[];\nexport function formatIps(ips: IpsInput, options: FormatIpsOptions & { as: 'string' }): string;\nexport function formatIps(ips: IpsInput, options?: FormatIpsOptions): string | string[] {\n const as = options?.as ?? 'array';\n const separator = options?.separator ?? ', ';\n\n if (!ips) {\n return as === 'array' ? [] : '';\n }\n\n let result: string[] = [];\n\n if (Array.isArray(ips)) {\n result = ips.filter(Boolean);\n } else if (typeof ips === 'string') {\n const str = ips.trim();\n if (str === '') {\n result = [];\n } else if (str.includes(',')) {\n result = str\n .split(',')\n .map((s) => s.trim())\n .filter(Boolean);\n } else if (/\\s+/.test(str)) {\n result = str\n .split(/\\s+/)\n .map((s) => s.trim())\n .filter(Boolean);\n } else {\n result = [str];\n }\n } else if (typeof ips === 'object') {\n result = Object.values(ips).filter(Boolean);\n }\n\n return as === 'array' ? result : result.join(separator);\n}\n"]}
|