@roxyon/api-client 0.2.0 → 0.3.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.d.cts CHANGED
@@ -364,6 +364,49 @@ declare class AuthApi {
364
364
  logout(): Promise<void>;
365
365
  }
366
366
 
367
+ interface CreateDatabaseInput {
368
+ /** DB name suffix — the platform prefixes it with the subscription's own username (globally unique). */
369
+ name: string;
370
+ /** Subscription to attach it to. Omit when the account has exactly one. */
371
+ subscription?: string;
372
+ /** Omit to have the platform generate one. */
373
+ password?: string;
374
+ }
375
+ interface CreateDatabaseResult {
376
+ ok: boolean;
377
+ objectId: string;
378
+ name: string;
379
+ username: string;
380
+ /** Shown once — not retrievable afterwards. */
381
+ password?: string;
382
+ /** `<node-ip>:6033` — the ProxySQL endpoint to connect the app to. */
383
+ host?: string;
384
+ status: 'provisioning' | 'active' | 'failed';
385
+ error?: string;
386
+ }
387
+ interface DatabaseSummary {
388
+ objectId: string;
389
+ Name: string;
390
+ Username: string;
391
+ Status: string;
392
+ }
393
+ interface DeleteDatabaseResult {
394
+ ok: boolean;
395
+ objectId: string;
396
+ status: 'deleting' | 'deleted' | 'failed';
397
+ error?: string;
398
+ }
399
+ /** Databases (MySQL/MariaDB on the shared Galera cluster) attached to a subscription. */
400
+ declare class DatabasesApi {
401
+ private readonly client;
402
+ constructor(client: RoxyonClient);
403
+ list(subscriptionId: string): Promise<DatabaseSummary[]>;
404
+ /** `POST /databases/create` — provision a database + user; the reconciler does the rest. */
405
+ create(input: CreateDatabaseInput): Promise<CreateDatabaseResult>;
406
+ /** `POST /databases/delete` */
407
+ delete(databaseId: string): Promise<DeleteDatabaseResult>;
408
+ }
409
+
367
410
  interface Domain {
368
411
  objectId: string;
369
412
  Name: string;
@@ -375,6 +418,8 @@ interface CreateDomainInput {
375
418
  subscription?: string;
376
419
  /** `spa` → unmatched paths serve `/index.html`; default `static`. */
377
420
  siteType?: 'static' | 'spa';
421
+ /** PHP version for the vhost (e.g. `"8.3"`). Unknown/omitted falls back to the platform default. */
422
+ phpVersion?: string;
378
423
  }
379
424
  interface CreateDomainResult {
380
425
  ok: boolean;
@@ -399,6 +444,52 @@ declare class DomainsApi {
399
444
  create(input: CreateDomainInput): Promise<CreateDomainResult>;
400
445
  }
401
446
 
447
+ interface CreateEmailInput {
448
+ /** The part before `@`. */
449
+ localPart: string;
450
+ /** A hostname already on the account. */
451
+ domain: string;
452
+ /** Omit to have the platform generate one. */
453
+ password?: string;
454
+ /** Mailbox quota in MB. Default 1024. */
455
+ quota?: number;
456
+ forwardTo?: string;
457
+ saveCopy?: boolean;
458
+ }
459
+ interface CreateEmailResult {
460
+ ok: boolean;
461
+ objectId: string;
462
+ email: string;
463
+ /** Shown once — not retrievable afterwards. */
464
+ password?: string;
465
+ quota?: number;
466
+ status: 'provisioning' | 'active' | 'failed';
467
+ error?: string;
468
+ }
469
+ interface EmailSummary {
470
+ objectId: string;
471
+ Email: string;
472
+ LocalPart: string;
473
+ Status: string;
474
+ Quota?: number;
475
+ }
476
+ interface DeleteEmailResult {
477
+ ok: boolean;
478
+ objectId: string;
479
+ status: 'deleting' | 'deleted' | 'failed';
480
+ error?: string;
481
+ }
482
+ /** Mailboxes attached to a subscription's domains. */
483
+ declare class EmailApi {
484
+ private readonly client;
485
+ constructor(client: RoxyonClient);
486
+ list(subscriptionId: string): Promise<EmailSummary[]>;
487
+ /** `POST /emails/create` — provision a mailbox; the reconciler does the rest. */
488
+ create(input: CreateEmailInput): Promise<CreateEmailResult>;
489
+ /** `POST /emails/delete` */
490
+ delete(emailId: string): Promise<DeleteEmailResult>;
491
+ }
492
+
402
493
  interface StaticDeployResult {
403
494
  ok: boolean;
404
495
  host: string;
@@ -442,6 +533,30 @@ declare class SitesApi {
442
533
  readFile(host: string, folder: string, path: string): Promise<SiteFileContent>;
443
534
  }
444
535
 
536
+ interface ResetSshPasswordInput {
537
+ /** Subscription to reset. Omit when the account has exactly one. */
538
+ subscription?: string;
539
+ /** Omit to have the platform generate one meeting the strength rules. */
540
+ password?: string;
541
+ }
542
+ interface ResetSshPasswordResult {
543
+ ok: boolean;
544
+ subscription: string;
545
+ /** Shown once — the platform never stores or re-shows it. */
546
+ password: string;
547
+ status: 'pending' | 'active' | 'failed';
548
+ }
549
+ /**
550
+ * The shared shell password used for SSH, SFTP and the file manager on a
551
+ * subscription's container (SSHpiper maps the username to the container).
552
+ */
553
+ declare class SshApi {
554
+ private readonly client;
555
+ constructor(client: RoxyonClient);
556
+ /** `POST /ssh/password` */
557
+ resetPassword(input?: ResetSshPasswordInput): Promise<ResetSshPasswordResult>;
558
+ }
559
+
445
560
  interface Subscription {
446
561
  objectId: string;
447
562
  Name?: string;
@@ -577,8 +692,11 @@ declare class Roxyon {
577
692
  readonly domains: DomainsApi;
578
693
  readonly applications: ApplicationsApi;
579
694
  readonly sites: SitesApi;
695
+ readonly databases: DatabasesApi;
696
+ readonly email: EmailApi;
697
+ readonly ssh: SshApi;
580
698
  constructor(options?: RoxyonClientOptions | RoxyonClient);
581
699
  get sessionToken(): string | undefined;
582
700
  }
583
701
 
584
- export { AccountApi, type AccountApp, type AccountContext, type AccountDomain, type AccountSubscription, type Application, type ApplicationProcess, type ApplicationRoute, ApplicationsApi, AuthApi, type CreateApplicationInput, type CreateDomainInput, type CreateDomainResult, type CreateOnDeploy, type CreatedToken, DEFAULT_APP, DEFAULT_BAAS_URL, DEFAULT_CONSOLE_URL, type DeployKind, type DeployOptions, type DeployResult, type Domain, DomainsApi, LUMEN_BUILD, type LoginPrecheck, type LoginResult, type Privilege, RUNTIMES, type RequestOptions, Roxyon, RoxyonApiError, RoxyonClient, type RoxyonClientOptions, type RoxyonUser, type RuntimeName, type RuntimeSpec, type SessionGrant, type SiteFile, type SiteFileContent, SitesApi, type StaticDeployResult, type Subscription, SubscriptionsApi, type TokenScope, type TokenSummary, TokensApi, assertOk, envFromStored, formatEnv, isAuthError, parseEnv, rxError, toQueryString };
702
+ export { AccountApi, type AccountApp, type AccountContext, type AccountDomain, type AccountSubscription, type Application, type ApplicationProcess, type ApplicationRoute, ApplicationsApi, AuthApi, type CreateApplicationInput, type CreateDatabaseInput, type CreateDatabaseResult, type CreateDomainInput, type CreateDomainResult, type CreateEmailInput, type CreateEmailResult, type CreateOnDeploy, type CreatedToken, DEFAULT_APP, DEFAULT_BAAS_URL, DEFAULT_CONSOLE_URL, type DatabaseSummary, DatabasesApi, type DeleteDatabaseResult, type DeleteEmailResult, type DeployKind, type DeployOptions, type DeployResult, type Domain, DomainsApi, EmailApi, type EmailSummary, LUMEN_BUILD, type LoginPrecheck, type LoginResult, type Privilege, RUNTIMES, type RequestOptions, type ResetSshPasswordInput, type ResetSshPasswordResult, Roxyon, RoxyonApiError, RoxyonClient, type RoxyonClientOptions, type RoxyonUser, type RuntimeName, type RuntimeSpec, type SessionGrant, type SiteFile, type SiteFileContent, SitesApi, SshApi, type StaticDeployResult, type Subscription, SubscriptionsApi, type TokenScope, type TokenSummary, TokensApi, assertOk, envFromStored, formatEnv, isAuthError, parseEnv, rxError, toQueryString };
package/dist/index.d.ts CHANGED
@@ -364,6 +364,49 @@ declare class AuthApi {
364
364
  logout(): Promise<void>;
365
365
  }
366
366
 
367
+ interface CreateDatabaseInput {
368
+ /** DB name suffix — the platform prefixes it with the subscription's own username (globally unique). */
369
+ name: string;
370
+ /** Subscription to attach it to. Omit when the account has exactly one. */
371
+ subscription?: string;
372
+ /** Omit to have the platform generate one. */
373
+ password?: string;
374
+ }
375
+ interface CreateDatabaseResult {
376
+ ok: boolean;
377
+ objectId: string;
378
+ name: string;
379
+ username: string;
380
+ /** Shown once — not retrievable afterwards. */
381
+ password?: string;
382
+ /** `<node-ip>:6033` — the ProxySQL endpoint to connect the app to. */
383
+ host?: string;
384
+ status: 'provisioning' | 'active' | 'failed';
385
+ error?: string;
386
+ }
387
+ interface DatabaseSummary {
388
+ objectId: string;
389
+ Name: string;
390
+ Username: string;
391
+ Status: string;
392
+ }
393
+ interface DeleteDatabaseResult {
394
+ ok: boolean;
395
+ objectId: string;
396
+ status: 'deleting' | 'deleted' | 'failed';
397
+ error?: string;
398
+ }
399
+ /** Databases (MySQL/MariaDB on the shared Galera cluster) attached to a subscription. */
400
+ declare class DatabasesApi {
401
+ private readonly client;
402
+ constructor(client: RoxyonClient);
403
+ list(subscriptionId: string): Promise<DatabaseSummary[]>;
404
+ /** `POST /databases/create` — provision a database + user; the reconciler does the rest. */
405
+ create(input: CreateDatabaseInput): Promise<CreateDatabaseResult>;
406
+ /** `POST /databases/delete` */
407
+ delete(databaseId: string): Promise<DeleteDatabaseResult>;
408
+ }
409
+
367
410
  interface Domain {
368
411
  objectId: string;
369
412
  Name: string;
@@ -375,6 +418,8 @@ interface CreateDomainInput {
375
418
  subscription?: string;
376
419
  /** `spa` → unmatched paths serve `/index.html`; default `static`. */
377
420
  siteType?: 'static' | 'spa';
421
+ /** PHP version for the vhost (e.g. `"8.3"`). Unknown/omitted falls back to the platform default. */
422
+ phpVersion?: string;
378
423
  }
379
424
  interface CreateDomainResult {
380
425
  ok: boolean;
@@ -399,6 +444,52 @@ declare class DomainsApi {
399
444
  create(input: CreateDomainInput): Promise<CreateDomainResult>;
400
445
  }
401
446
 
447
+ interface CreateEmailInput {
448
+ /** The part before `@`. */
449
+ localPart: string;
450
+ /** A hostname already on the account. */
451
+ domain: string;
452
+ /** Omit to have the platform generate one. */
453
+ password?: string;
454
+ /** Mailbox quota in MB. Default 1024. */
455
+ quota?: number;
456
+ forwardTo?: string;
457
+ saveCopy?: boolean;
458
+ }
459
+ interface CreateEmailResult {
460
+ ok: boolean;
461
+ objectId: string;
462
+ email: string;
463
+ /** Shown once — not retrievable afterwards. */
464
+ password?: string;
465
+ quota?: number;
466
+ status: 'provisioning' | 'active' | 'failed';
467
+ error?: string;
468
+ }
469
+ interface EmailSummary {
470
+ objectId: string;
471
+ Email: string;
472
+ LocalPart: string;
473
+ Status: string;
474
+ Quota?: number;
475
+ }
476
+ interface DeleteEmailResult {
477
+ ok: boolean;
478
+ objectId: string;
479
+ status: 'deleting' | 'deleted' | 'failed';
480
+ error?: string;
481
+ }
482
+ /** Mailboxes attached to a subscription's domains. */
483
+ declare class EmailApi {
484
+ private readonly client;
485
+ constructor(client: RoxyonClient);
486
+ list(subscriptionId: string): Promise<EmailSummary[]>;
487
+ /** `POST /emails/create` — provision a mailbox; the reconciler does the rest. */
488
+ create(input: CreateEmailInput): Promise<CreateEmailResult>;
489
+ /** `POST /emails/delete` */
490
+ delete(emailId: string): Promise<DeleteEmailResult>;
491
+ }
492
+
402
493
  interface StaticDeployResult {
403
494
  ok: boolean;
404
495
  host: string;
@@ -442,6 +533,30 @@ declare class SitesApi {
442
533
  readFile(host: string, folder: string, path: string): Promise<SiteFileContent>;
443
534
  }
444
535
 
536
+ interface ResetSshPasswordInput {
537
+ /** Subscription to reset. Omit when the account has exactly one. */
538
+ subscription?: string;
539
+ /** Omit to have the platform generate one meeting the strength rules. */
540
+ password?: string;
541
+ }
542
+ interface ResetSshPasswordResult {
543
+ ok: boolean;
544
+ subscription: string;
545
+ /** Shown once — the platform never stores or re-shows it. */
546
+ password: string;
547
+ status: 'pending' | 'active' | 'failed';
548
+ }
549
+ /**
550
+ * The shared shell password used for SSH, SFTP and the file manager on a
551
+ * subscription's container (SSHpiper maps the username to the container).
552
+ */
553
+ declare class SshApi {
554
+ private readonly client;
555
+ constructor(client: RoxyonClient);
556
+ /** `POST /ssh/password` */
557
+ resetPassword(input?: ResetSshPasswordInput): Promise<ResetSshPasswordResult>;
558
+ }
559
+
445
560
  interface Subscription {
446
561
  objectId: string;
447
562
  Name?: string;
@@ -577,8 +692,11 @@ declare class Roxyon {
577
692
  readonly domains: DomainsApi;
578
693
  readonly applications: ApplicationsApi;
579
694
  readonly sites: SitesApi;
695
+ readonly databases: DatabasesApi;
696
+ readonly email: EmailApi;
697
+ readonly ssh: SshApi;
580
698
  constructor(options?: RoxyonClientOptions | RoxyonClient);
581
699
  get sessionToken(): string | undefined;
582
700
  }
583
701
 
584
- export { AccountApi, type AccountApp, type AccountContext, type AccountDomain, type AccountSubscription, type Application, type ApplicationProcess, type ApplicationRoute, ApplicationsApi, AuthApi, type CreateApplicationInput, type CreateDomainInput, type CreateDomainResult, type CreateOnDeploy, type CreatedToken, DEFAULT_APP, DEFAULT_BAAS_URL, DEFAULT_CONSOLE_URL, type DeployKind, type DeployOptions, type DeployResult, type Domain, DomainsApi, LUMEN_BUILD, type LoginPrecheck, type LoginResult, type Privilege, RUNTIMES, type RequestOptions, Roxyon, RoxyonApiError, RoxyonClient, type RoxyonClientOptions, type RoxyonUser, type RuntimeName, type RuntimeSpec, type SessionGrant, type SiteFile, type SiteFileContent, SitesApi, type StaticDeployResult, type Subscription, SubscriptionsApi, type TokenScope, type TokenSummary, TokensApi, assertOk, envFromStored, formatEnv, isAuthError, parseEnv, rxError, toQueryString };
702
+ export { AccountApi, type AccountApp, type AccountContext, type AccountDomain, type AccountSubscription, type Application, type ApplicationProcess, type ApplicationRoute, ApplicationsApi, AuthApi, type CreateApplicationInput, type CreateDatabaseInput, type CreateDatabaseResult, type CreateDomainInput, type CreateDomainResult, type CreateEmailInput, type CreateEmailResult, type CreateOnDeploy, type CreatedToken, DEFAULT_APP, DEFAULT_BAAS_URL, DEFAULT_CONSOLE_URL, type DatabaseSummary, DatabasesApi, type DeleteDatabaseResult, type DeleteEmailResult, type DeployKind, type DeployOptions, type DeployResult, type Domain, DomainsApi, EmailApi, type EmailSummary, LUMEN_BUILD, type LoginPrecheck, type LoginResult, type Privilege, RUNTIMES, type RequestOptions, type ResetSshPasswordInput, type ResetSshPasswordResult, Roxyon, RoxyonApiError, RoxyonClient, type RoxyonClientOptions, type RoxyonUser, type RuntimeName, type RuntimeSpec, type SessionGrant, type SiteFile, type SiteFileContent, SitesApi, SshApi, type StaticDeployResult, type Subscription, SubscriptionsApi, type TokenScope, type TokenSummary, TokensApi, assertOk, envFromStored, formatEnv, isAuthError, parseEnv, rxError, toQueryString };
package/dist/index.js CHANGED
@@ -575,6 +575,41 @@ var RoxyonClient = class {
575
575
  }
576
576
  };
577
577
 
578
+ // src/databases.ts
579
+ var DatabasesApi = class {
580
+ constructor(client) {
581
+ this.client = client;
582
+ }
583
+ client;
584
+ async list(subscriptionId) {
585
+ const r = await this.client.get("/Databases", {
586
+ fields: "objectId,Name,Username,Status",
587
+ limit: -1,
588
+ order: "-createdAt",
589
+ where: { Subscription: subscriptionId, eye: { in: "1,0" } }
590
+ });
591
+ return r.results ?? [];
592
+ }
593
+ /** `POST /databases/create` — provision a database + user; the reconciler does the rest. */
594
+ async create(input) {
595
+ const r = await this.client.console("POST", "/databases/create", {
596
+ body: input,
597
+ tolerateHttpError: true
598
+ });
599
+ if (!r?.ok) throw new RoxyonApiError(r?.error || "Could not create the database.", { body: r });
600
+ return r;
601
+ }
602
+ /** `POST /databases/delete` */
603
+ async delete(databaseId) {
604
+ const r = await this.client.console("POST", "/databases/delete", {
605
+ body: { database: databaseId },
606
+ tolerateHttpError: true
607
+ });
608
+ if (!r?.ok) throw new RoxyonApiError(r?.error || "Could not delete the database.", { body: r });
609
+ return r;
610
+ }
611
+ };
612
+
578
613
  // src/domains.ts
579
614
  var DomainsApi = class {
580
615
  constructor(client) {
@@ -605,6 +640,41 @@ var DomainsApi = class {
605
640
  }
606
641
  };
607
642
 
643
+ // src/email.ts
644
+ var EmailApi = class {
645
+ constructor(client) {
646
+ this.client = client;
647
+ }
648
+ client;
649
+ async list(subscriptionId) {
650
+ const r = await this.client.get("/Emails", {
651
+ fields: "objectId,Email,LocalPart,Status,Quota",
652
+ limit: -1,
653
+ order: "-createdAt",
654
+ where: { Subscription: subscriptionId, eye: { in: "1,0" } }
655
+ });
656
+ return r.results ?? [];
657
+ }
658
+ /** `POST /emails/create` — provision a mailbox; the reconciler does the rest. */
659
+ async create(input) {
660
+ const r = await this.client.console("POST", "/emails/create", {
661
+ body: input,
662
+ tolerateHttpError: true
663
+ });
664
+ if (!r?.ok) throw new RoxyonApiError(r?.error || "Could not create the mailbox.", { body: r });
665
+ return r;
666
+ }
667
+ /** `POST /emails/delete` */
668
+ async delete(emailId) {
669
+ const r = await this.client.console("POST", "/emails/delete", {
670
+ body: { email: emailId },
671
+ tolerateHttpError: true
672
+ });
673
+ if (!r?.ok) throw new RoxyonApiError(r?.error || "Could not delete the mailbox.", { body: r });
674
+ return r;
675
+ }
676
+ };
677
+
608
678
  // src/sites.ts
609
679
  var SitesApi = class {
610
680
  constructor(client) {
@@ -649,6 +719,30 @@ var SitesApi = class {
649
719
  }
650
720
  };
651
721
 
722
+ // src/ssh.ts
723
+ var SshApi = class {
724
+ constructor(client) {
725
+ this.client = client;
726
+ }
727
+ client;
728
+ /** `POST /ssh/password` */
729
+ async resetPassword(input = {}) {
730
+ const r = await this.client.console("POST", "/ssh/password", {
731
+ body: input,
732
+ tolerateHttpError: true
733
+ });
734
+ if (!r?.ok) {
735
+ throw new RoxyonApiError(
736
+ r?.error || "Could not reset the password.",
737
+ {
738
+ body: r
739
+ }
740
+ );
741
+ }
742
+ return r;
743
+ }
744
+ };
745
+
652
746
  // src/subscriptions.ts
653
747
  var SubscriptionsApi = class {
654
748
  constructor(client) {
@@ -824,6 +918,9 @@ var Roxyon = class {
824
918
  domains;
825
919
  applications;
826
920
  sites;
921
+ databases;
922
+ email;
923
+ ssh;
827
924
  constructor(options = {}) {
828
925
  this.client = options instanceof RoxyonClient ? options : new RoxyonClient(options);
829
926
  this.auth = new AuthApi(this.client);
@@ -833,6 +930,9 @@ var Roxyon = class {
833
930
  this.domains = new DomainsApi(this.client);
834
931
  this.applications = new ApplicationsApi(this.client);
835
932
  this.sites = new SitesApi(this.client);
933
+ this.databases = new DatabasesApi(this.client);
934
+ this.email = new EmailApi(this.client);
935
+ this.ssh = new SshApi(this.client);
836
936
  }
837
937
  get sessionToken() {
838
938
  return this.client.getSessionToken();
@@ -845,13 +945,16 @@ export {
845
945
  DEFAULT_APP,
846
946
  DEFAULT_BAAS_URL,
847
947
  DEFAULT_CONSOLE_URL,
948
+ DatabasesApi,
848
949
  DomainsApi,
950
+ EmailApi,
849
951
  LUMEN_BUILD,
850
952
  RUNTIMES,
851
953
  Roxyon,
852
954
  RoxyonApiError,
853
955
  RoxyonClient,
854
956
  SitesApi,
957
+ SshApi,
855
958
  SubscriptionsApi,
856
959
  TokensApi,
857
960
  assertOk,