@roxyon/api-client 0.2.0 → 0.4.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.cjs +392 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +294 -1
- package/dist/index.d.ts +294 -1
- package/dist/index.js +381 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -59,6 +59,9 @@ declare class RoxyonClient {
|
|
|
59
59
|
private sessionToken?;
|
|
60
60
|
private anon?;
|
|
61
61
|
constructor(opts?: RoxyonClientOptions);
|
|
62
|
+
/** Same endpoints and app, no user credentials: for public reads (catalog, quotes)
|
|
63
|
+
* that must work for PAT callers too, whose token the BaaS does not accept. */
|
|
64
|
+
publicClient(): RoxyonClient;
|
|
62
65
|
getSessionToken(): string | undefined;
|
|
63
66
|
setSessionToken(token: string | undefined): void;
|
|
64
67
|
/** Mint (or reuse) an anonymous access token from the public app credentials. */
|
|
@@ -364,6 +367,150 @@ declare class AuthApi {
|
|
|
364
367
|
logout(): Promise<void>;
|
|
365
368
|
}
|
|
366
369
|
|
|
370
|
+
/** Billing cycles the checkout accepts (Pricing::CYCLE_MONTHS). */
|
|
371
|
+
declare const BILLING_CYCLES: readonly ["monthly", "quarterly", "yearly", "biennial"];
|
|
372
|
+
type BillingCycle = (typeof BILLING_CYCLES)[number];
|
|
373
|
+
interface CatalogProduct {
|
|
374
|
+
/** Plan objectId: what quotes and orders take. */
|
|
375
|
+
planId: string;
|
|
376
|
+
/** Plan code, e.g. `SCALE-S`. */
|
|
377
|
+
sku: string;
|
|
378
|
+
name: string;
|
|
379
|
+
/** Service type, e.g. `cloud.vps.scale`, `cloud.hosting.solo`. */
|
|
380
|
+
category: string;
|
|
381
|
+
vcpu?: number;
|
|
382
|
+
ramGb?: number;
|
|
383
|
+
diskGb?: number;
|
|
384
|
+
cpuType?: string;
|
|
385
|
+
/** Dedicated IPv4 addresses included (servers). */
|
|
386
|
+
ipv4Included?: number;
|
|
387
|
+
/** List prices in USD before tax, per cycle. Quote for the buyer's currency and tax. */
|
|
388
|
+
pricesUSD: Partial<Record<BillingCycle, number>>;
|
|
389
|
+
/** Setup fee in USD per cycle, when not zero. */
|
|
390
|
+
setupFeeUSD?: Partial<Record<BillingCycle, number>>;
|
|
391
|
+
/** `out` = cannot be ordered right now. */
|
|
392
|
+
stock: 'in' | 'out';
|
|
393
|
+
/** Feature table as the console shows it. */
|
|
394
|
+
features?: Record<string, unknown>;
|
|
395
|
+
}
|
|
396
|
+
interface QuoteInput {
|
|
397
|
+
planId: string;
|
|
398
|
+
cycle: BillingCycle;
|
|
399
|
+
/** ISO 4217, e.g. `SAR`. Default USD. */
|
|
400
|
+
currency?: string;
|
|
401
|
+
/** ISO 3166 alpha-2, decides tax (e.g. `SA` = 15% VAT). Empty = no tax line. */
|
|
402
|
+
country?: string;
|
|
403
|
+
}
|
|
404
|
+
interface Quote {
|
|
405
|
+
planId: string;
|
|
406
|
+
cycle: string;
|
|
407
|
+
currency: string;
|
|
408
|
+
lineItems: Array<{
|
|
409
|
+
label: string;
|
|
410
|
+
amount: string;
|
|
411
|
+
amountUSD: string;
|
|
412
|
+
}>;
|
|
413
|
+
subtotal: string;
|
|
414
|
+
taxRate: string;
|
|
415
|
+
taxLabel: string;
|
|
416
|
+
taxAmount: string;
|
|
417
|
+
discountAmount: string;
|
|
418
|
+
total: string;
|
|
419
|
+
fxRate: string;
|
|
420
|
+
baseAmountUSD: string;
|
|
421
|
+
}
|
|
422
|
+
interface BillingSubscription {
|
|
423
|
+
id: string;
|
|
424
|
+
name: string;
|
|
425
|
+
status: string;
|
|
426
|
+
plan: string;
|
|
427
|
+
sku: string;
|
|
428
|
+
cycle: string;
|
|
429
|
+
price: string;
|
|
430
|
+
currency: string;
|
|
431
|
+
nextBillingDate: string | null;
|
|
432
|
+
autoRenew: boolean;
|
|
433
|
+
serverState: string | null;
|
|
434
|
+
publicIp: string | null;
|
|
435
|
+
}
|
|
436
|
+
interface Invoice {
|
|
437
|
+
id: string;
|
|
438
|
+
number: string;
|
|
439
|
+
type: string;
|
|
440
|
+
status: string;
|
|
441
|
+
total: string;
|
|
442
|
+
currency: string;
|
|
443
|
+
dueDate: string | null;
|
|
444
|
+
subscription: string | null;
|
|
445
|
+
createdAt: string;
|
|
446
|
+
payUrl: string | null;
|
|
447
|
+
}
|
|
448
|
+
/** Invoice statuses a customer can still pay. */
|
|
449
|
+
declare const PAYABLE_STATUSES: readonly ["pending", "overdue", "failed"];
|
|
450
|
+
declare function isPayable(status: string): boolean;
|
|
451
|
+
/**
|
|
452
|
+
* Catalog + quotes (public, no sign-in) and the caller's own subscriptions + invoices
|
|
453
|
+
* (console, session or PAT). Read-only: nothing here creates orders or invoices.
|
|
454
|
+
*/
|
|
455
|
+
declare class BillingApi {
|
|
456
|
+
private readonly client;
|
|
457
|
+
private readonly pub;
|
|
458
|
+
constructor(client: RoxyonClient, pub?: RoxyonClient);
|
|
459
|
+
catalog(): Promise<CatalogProduct[]>;
|
|
460
|
+
/** What checkout would charge for a new subscription: the server's own pricing (GET /_payment/quote). */
|
|
461
|
+
quote(input: QuoteInput): Promise<Quote>;
|
|
462
|
+
/** The caller's own subscriptions (rows they own), newest first. */
|
|
463
|
+
subscriptions(): Promise<BillingSubscription[]>;
|
|
464
|
+
/** The caller's own invoices, newest first. */
|
|
465
|
+
invoices(opts?: {
|
|
466
|
+
status?: string;
|
|
467
|
+
limit?: number;
|
|
468
|
+
}): Promise<Invoice[]>;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
interface CreateDatabaseInput {
|
|
472
|
+
/** DB name suffix — the platform prefixes it with the subscription's own username (globally unique). */
|
|
473
|
+
name: string;
|
|
474
|
+
/** Subscription to attach it to. Omit when the account has exactly one. */
|
|
475
|
+
subscription?: string;
|
|
476
|
+
/** Omit to have the platform generate one. */
|
|
477
|
+
password?: string;
|
|
478
|
+
}
|
|
479
|
+
interface CreateDatabaseResult {
|
|
480
|
+
ok: boolean;
|
|
481
|
+
objectId: string;
|
|
482
|
+
name: string;
|
|
483
|
+
username: string;
|
|
484
|
+
/** Shown once — not retrievable afterwards. */
|
|
485
|
+
password?: string;
|
|
486
|
+
/** `<node-ip>:6033` — the ProxySQL endpoint to connect the app to. */
|
|
487
|
+
host?: string;
|
|
488
|
+
status: 'provisioning' | 'active' | 'failed';
|
|
489
|
+
error?: string;
|
|
490
|
+
}
|
|
491
|
+
interface DatabaseSummary {
|
|
492
|
+
objectId: string;
|
|
493
|
+
Name: string;
|
|
494
|
+
Username: string;
|
|
495
|
+
Status: string;
|
|
496
|
+
}
|
|
497
|
+
interface DeleteDatabaseResult {
|
|
498
|
+
ok: boolean;
|
|
499
|
+
objectId: string;
|
|
500
|
+
status: 'deleting' | 'deleted' | 'failed';
|
|
501
|
+
error?: string;
|
|
502
|
+
}
|
|
503
|
+
/** Databases (MySQL/MariaDB on the shared Galera cluster) attached to a subscription. */
|
|
504
|
+
declare class DatabasesApi {
|
|
505
|
+
private readonly client;
|
|
506
|
+
constructor(client: RoxyonClient);
|
|
507
|
+
list(subscriptionId: string): Promise<DatabaseSummary[]>;
|
|
508
|
+
/** `POST /databases/create` — provision a database + user; the reconciler does the rest. */
|
|
509
|
+
create(input: CreateDatabaseInput): Promise<CreateDatabaseResult>;
|
|
510
|
+
/** `POST /databases/delete` */
|
|
511
|
+
delete(databaseId: string): Promise<DeleteDatabaseResult>;
|
|
512
|
+
}
|
|
513
|
+
|
|
367
514
|
interface Domain {
|
|
368
515
|
objectId: string;
|
|
369
516
|
Name: string;
|
|
@@ -375,6 +522,8 @@ interface CreateDomainInput {
|
|
|
375
522
|
subscription?: string;
|
|
376
523
|
/** `spa` → unmatched paths serve `/index.html`; default `static`. */
|
|
377
524
|
siteType?: 'static' | 'spa';
|
|
525
|
+
/** PHP version for the vhost (e.g. `"8.3"`). Unknown/omitted falls back to the platform default. */
|
|
526
|
+
phpVersion?: string;
|
|
378
527
|
}
|
|
379
528
|
interface CreateDomainResult {
|
|
380
529
|
ok: boolean;
|
|
@@ -399,6 +548,52 @@ declare class DomainsApi {
|
|
|
399
548
|
create(input: CreateDomainInput): Promise<CreateDomainResult>;
|
|
400
549
|
}
|
|
401
550
|
|
|
551
|
+
interface CreateEmailInput {
|
|
552
|
+
/** The part before `@`. */
|
|
553
|
+
localPart: string;
|
|
554
|
+
/** A hostname already on the account. */
|
|
555
|
+
domain: string;
|
|
556
|
+
/** Omit to have the platform generate one. */
|
|
557
|
+
password?: string;
|
|
558
|
+
/** Mailbox quota in MB. Default 1024. */
|
|
559
|
+
quota?: number;
|
|
560
|
+
forwardTo?: string;
|
|
561
|
+
saveCopy?: boolean;
|
|
562
|
+
}
|
|
563
|
+
interface CreateEmailResult {
|
|
564
|
+
ok: boolean;
|
|
565
|
+
objectId: string;
|
|
566
|
+
email: string;
|
|
567
|
+
/** Shown once — not retrievable afterwards. */
|
|
568
|
+
password?: string;
|
|
569
|
+
quota?: number;
|
|
570
|
+
status: 'provisioning' | 'active' | 'failed';
|
|
571
|
+
error?: string;
|
|
572
|
+
}
|
|
573
|
+
interface EmailSummary {
|
|
574
|
+
objectId: string;
|
|
575
|
+
Email: string;
|
|
576
|
+
LocalPart: string;
|
|
577
|
+
Status: string;
|
|
578
|
+
Quota?: number;
|
|
579
|
+
}
|
|
580
|
+
interface DeleteEmailResult {
|
|
581
|
+
ok: boolean;
|
|
582
|
+
objectId: string;
|
|
583
|
+
status: 'deleting' | 'deleted' | 'failed';
|
|
584
|
+
error?: string;
|
|
585
|
+
}
|
|
586
|
+
/** Mailboxes attached to a subscription's domains. */
|
|
587
|
+
declare class EmailApi {
|
|
588
|
+
private readonly client;
|
|
589
|
+
constructor(client: RoxyonClient);
|
|
590
|
+
list(subscriptionId: string): Promise<EmailSummary[]>;
|
|
591
|
+
/** `POST /emails/create` — provision a mailbox; the reconciler does the rest. */
|
|
592
|
+
create(input: CreateEmailInput): Promise<CreateEmailResult>;
|
|
593
|
+
/** `POST /emails/delete` */
|
|
594
|
+
delete(emailId: string): Promise<DeleteEmailResult>;
|
|
595
|
+
}
|
|
596
|
+
|
|
402
597
|
interface StaticDeployResult {
|
|
403
598
|
ok: boolean;
|
|
404
599
|
host: string;
|
|
@@ -442,6 +637,30 @@ declare class SitesApi {
|
|
|
442
637
|
readFile(host: string, folder: string, path: string): Promise<SiteFileContent>;
|
|
443
638
|
}
|
|
444
639
|
|
|
640
|
+
interface ResetSshPasswordInput {
|
|
641
|
+
/** Subscription to reset. Omit when the account has exactly one. */
|
|
642
|
+
subscription?: string;
|
|
643
|
+
/** Omit to have the platform generate one meeting the strength rules. */
|
|
644
|
+
password?: string;
|
|
645
|
+
}
|
|
646
|
+
interface ResetSshPasswordResult {
|
|
647
|
+
ok: boolean;
|
|
648
|
+
subscription: string;
|
|
649
|
+
/** Shown once — the platform never stores or re-shows it. */
|
|
650
|
+
password: string;
|
|
651
|
+
status: 'pending' | 'active' | 'failed';
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* The shared shell password used for SSH, SFTP and the file manager on a
|
|
655
|
+
* subscription's container (SSHpiper maps the username to the container).
|
|
656
|
+
*/
|
|
657
|
+
declare class SshApi {
|
|
658
|
+
private readonly client;
|
|
659
|
+
constructor(client: RoxyonClient);
|
|
660
|
+
/** `POST /ssh/password` */
|
|
661
|
+
resetPassword(input?: ResetSshPasswordInput): Promise<ResetSshPasswordResult>;
|
|
662
|
+
}
|
|
663
|
+
|
|
445
664
|
interface Subscription {
|
|
446
665
|
objectId: string;
|
|
447
666
|
Name?: string;
|
|
@@ -471,6 +690,76 @@ declare class SubscriptionsApi {
|
|
|
471
690
|
resolve(userId: string, preferred?: string): Promise<Subscription>;
|
|
472
691
|
}
|
|
473
692
|
|
|
693
|
+
/** BaaS V2 base. V1 (`/1`) is frozen; app data tools speak V2 only. */
|
|
694
|
+
declare const DEFAULT_BAAS_V2_URL = "https://www.beaapis.com/2";
|
|
695
|
+
/** V2 caps one page at 200 rows. */
|
|
696
|
+
declare const BAAS_MAX_PAGE = 200;
|
|
697
|
+
/** V2 takes 1 to 50 requests per batch. */
|
|
698
|
+
declare const BAAS_MAX_BATCH = 50;
|
|
699
|
+
interface BaasDataOptions {
|
|
700
|
+
/** The app's secret key (`rxsk_…`): server scope, from the project's API keys in Roxyon Base. */
|
|
701
|
+
secretKey: string;
|
|
702
|
+
baseUrl?: string;
|
|
703
|
+
fetch?: typeof fetch;
|
|
704
|
+
}
|
|
705
|
+
type BaasRow = Record<string, unknown>;
|
|
706
|
+
interface BaasQuery {
|
|
707
|
+
/** e.g. `{ Status: 'active', Age: { gt: 18 } }`; `in` takes a comma-joined string. */
|
|
708
|
+
where?: Record<string, unknown>;
|
|
709
|
+
/** `*` and/or column names, comma separated. Defaults to `*`. */
|
|
710
|
+
fields?: string;
|
|
711
|
+
/** Comma list, `-` for descending, e.g. `-createdAt`. */
|
|
712
|
+
order?: string;
|
|
713
|
+
/** 1 to 200 (default 50). */
|
|
714
|
+
limit?: number;
|
|
715
|
+
skip?: number;
|
|
716
|
+
/** Also return the total number of matching rows. */
|
|
717
|
+
count?: boolean;
|
|
718
|
+
}
|
|
719
|
+
interface BaasBatchRequest {
|
|
720
|
+
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
721
|
+
/** `/Class` or `/Class/<id>`. */
|
|
722
|
+
path: string;
|
|
723
|
+
body?: Record<string, unknown>;
|
|
724
|
+
}
|
|
725
|
+
/** One batch answer: `ok:false` with `error`/`message`, or that request's own V2 answer. */
|
|
726
|
+
interface BaasBatchResult {
|
|
727
|
+
status: number;
|
|
728
|
+
ok?: boolean;
|
|
729
|
+
error?: string;
|
|
730
|
+
message?: string;
|
|
731
|
+
result?: BaasRow;
|
|
732
|
+
results?: BaasRow[];
|
|
733
|
+
count?: number;
|
|
734
|
+
id?: string;
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* Records of ONE app on BaaS V2, as that app's own backend (server scope, `X-RX-Secret-Key`).
|
|
738
|
+
* Server scope passes every class rule, so treat the key like a database password. V2 answers
|
|
739
|
+
* failures as `{ok:false, error, message}` with an HTTP status; every call throws on those.
|
|
740
|
+
* Schema changes are not reachable with a secret key (console API only).
|
|
741
|
+
*/
|
|
742
|
+
declare class BaasDataApi {
|
|
743
|
+
private readonly baseUrl;
|
|
744
|
+
private readonly secretKey;
|
|
745
|
+
private readonly _fetch;
|
|
746
|
+
constructor(opts: BaasDataOptions);
|
|
747
|
+
private call;
|
|
748
|
+
private static recordPath;
|
|
749
|
+
query(className: string, q?: BaasQuery): Promise<{
|
|
750
|
+
rows: BaasRow[];
|
|
751
|
+
count?: number;
|
|
752
|
+
}>;
|
|
753
|
+
get(className: string, objectId: string): Promise<BaasRow>;
|
|
754
|
+
/** Returns the created row as stored. */
|
|
755
|
+
create(className: string, data: BaasRow): Promise<BaasRow>;
|
|
756
|
+
update(className: string, objectId: string, data: BaasRow): Promise<BaasRow>;
|
|
757
|
+
/** The id goes in the URL path, never the body. */
|
|
758
|
+
delete(className: string, objectId: string): Promise<void>;
|
|
759
|
+
/** 1 to 50 record requests in one call; one failing doesn't stop the others. */
|
|
760
|
+
batch(requests: BaasBatchRequest[]): Promise<BaasBatchResult[]>;
|
|
761
|
+
}
|
|
762
|
+
|
|
474
763
|
/** Returns the error message from a BaaS response, or `''` when the call worked. */
|
|
475
764
|
declare function rxError(r: unknown): string;
|
|
476
765
|
declare class RoxyonApiError extends Error {
|
|
@@ -577,8 +866,12 @@ declare class Roxyon {
|
|
|
577
866
|
readonly domains: DomainsApi;
|
|
578
867
|
readonly applications: ApplicationsApi;
|
|
579
868
|
readonly sites: SitesApi;
|
|
869
|
+
readonly databases: DatabasesApi;
|
|
870
|
+
readonly email: EmailApi;
|
|
871
|
+
readonly ssh: SshApi;
|
|
872
|
+
readonly billing: BillingApi;
|
|
580
873
|
constructor(options?: RoxyonClientOptions | RoxyonClient);
|
|
581
874
|
get sessionToken(): string | undefined;
|
|
582
875
|
}
|
|
583
876
|
|
|
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 };
|
|
877
|
+
export { AccountApi, type AccountApp, type AccountContext, type AccountDomain, type AccountSubscription, type Application, type ApplicationProcess, type ApplicationRoute, ApplicationsApi, AuthApi, BAAS_MAX_BATCH, BAAS_MAX_PAGE, BILLING_CYCLES, type BaasBatchRequest, type BaasBatchResult, BaasDataApi, type BaasDataOptions, type BaasQuery, type BaasRow, BillingApi, type BillingCycle, type BillingSubscription, type CatalogProduct, type CreateApplicationInput, type CreateDatabaseInput, type CreateDatabaseResult, type CreateDomainInput, type CreateDomainResult, type CreateEmailInput, type CreateEmailResult, type CreateOnDeploy, type CreatedToken, DEFAULT_APP, DEFAULT_BAAS_URL, DEFAULT_BAAS_V2_URL, DEFAULT_CONSOLE_URL, type DatabaseSummary, DatabasesApi, type DeleteDatabaseResult, type DeleteEmailResult, type DeployKind, type DeployOptions, type DeployResult, type Domain, DomainsApi, EmailApi, type EmailSummary, type Invoice, LUMEN_BUILD, type LoginPrecheck, type LoginResult, PAYABLE_STATUSES, type Privilege, type Quote, type QuoteInput, 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, isPayable, parseEnv, rxError, toQueryString };
|
package/dist/index.d.ts
CHANGED
|
@@ -59,6 +59,9 @@ declare class RoxyonClient {
|
|
|
59
59
|
private sessionToken?;
|
|
60
60
|
private anon?;
|
|
61
61
|
constructor(opts?: RoxyonClientOptions);
|
|
62
|
+
/** Same endpoints and app, no user credentials: for public reads (catalog, quotes)
|
|
63
|
+
* that must work for PAT callers too, whose token the BaaS does not accept. */
|
|
64
|
+
publicClient(): RoxyonClient;
|
|
62
65
|
getSessionToken(): string | undefined;
|
|
63
66
|
setSessionToken(token: string | undefined): void;
|
|
64
67
|
/** Mint (or reuse) an anonymous access token from the public app credentials. */
|
|
@@ -364,6 +367,150 @@ declare class AuthApi {
|
|
|
364
367
|
logout(): Promise<void>;
|
|
365
368
|
}
|
|
366
369
|
|
|
370
|
+
/** Billing cycles the checkout accepts (Pricing::CYCLE_MONTHS). */
|
|
371
|
+
declare const BILLING_CYCLES: readonly ["monthly", "quarterly", "yearly", "biennial"];
|
|
372
|
+
type BillingCycle = (typeof BILLING_CYCLES)[number];
|
|
373
|
+
interface CatalogProduct {
|
|
374
|
+
/** Plan objectId: what quotes and orders take. */
|
|
375
|
+
planId: string;
|
|
376
|
+
/** Plan code, e.g. `SCALE-S`. */
|
|
377
|
+
sku: string;
|
|
378
|
+
name: string;
|
|
379
|
+
/** Service type, e.g. `cloud.vps.scale`, `cloud.hosting.solo`. */
|
|
380
|
+
category: string;
|
|
381
|
+
vcpu?: number;
|
|
382
|
+
ramGb?: number;
|
|
383
|
+
diskGb?: number;
|
|
384
|
+
cpuType?: string;
|
|
385
|
+
/** Dedicated IPv4 addresses included (servers). */
|
|
386
|
+
ipv4Included?: number;
|
|
387
|
+
/** List prices in USD before tax, per cycle. Quote for the buyer's currency and tax. */
|
|
388
|
+
pricesUSD: Partial<Record<BillingCycle, number>>;
|
|
389
|
+
/** Setup fee in USD per cycle, when not zero. */
|
|
390
|
+
setupFeeUSD?: Partial<Record<BillingCycle, number>>;
|
|
391
|
+
/** `out` = cannot be ordered right now. */
|
|
392
|
+
stock: 'in' | 'out';
|
|
393
|
+
/** Feature table as the console shows it. */
|
|
394
|
+
features?: Record<string, unknown>;
|
|
395
|
+
}
|
|
396
|
+
interface QuoteInput {
|
|
397
|
+
planId: string;
|
|
398
|
+
cycle: BillingCycle;
|
|
399
|
+
/** ISO 4217, e.g. `SAR`. Default USD. */
|
|
400
|
+
currency?: string;
|
|
401
|
+
/** ISO 3166 alpha-2, decides tax (e.g. `SA` = 15% VAT). Empty = no tax line. */
|
|
402
|
+
country?: string;
|
|
403
|
+
}
|
|
404
|
+
interface Quote {
|
|
405
|
+
planId: string;
|
|
406
|
+
cycle: string;
|
|
407
|
+
currency: string;
|
|
408
|
+
lineItems: Array<{
|
|
409
|
+
label: string;
|
|
410
|
+
amount: string;
|
|
411
|
+
amountUSD: string;
|
|
412
|
+
}>;
|
|
413
|
+
subtotal: string;
|
|
414
|
+
taxRate: string;
|
|
415
|
+
taxLabel: string;
|
|
416
|
+
taxAmount: string;
|
|
417
|
+
discountAmount: string;
|
|
418
|
+
total: string;
|
|
419
|
+
fxRate: string;
|
|
420
|
+
baseAmountUSD: string;
|
|
421
|
+
}
|
|
422
|
+
interface BillingSubscription {
|
|
423
|
+
id: string;
|
|
424
|
+
name: string;
|
|
425
|
+
status: string;
|
|
426
|
+
plan: string;
|
|
427
|
+
sku: string;
|
|
428
|
+
cycle: string;
|
|
429
|
+
price: string;
|
|
430
|
+
currency: string;
|
|
431
|
+
nextBillingDate: string | null;
|
|
432
|
+
autoRenew: boolean;
|
|
433
|
+
serverState: string | null;
|
|
434
|
+
publicIp: string | null;
|
|
435
|
+
}
|
|
436
|
+
interface Invoice {
|
|
437
|
+
id: string;
|
|
438
|
+
number: string;
|
|
439
|
+
type: string;
|
|
440
|
+
status: string;
|
|
441
|
+
total: string;
|
|
442
|
+
currency: string;
|
|
443
|
+
dueDate: string | null;
|
|
444
|
+
subscription: string | null;
|
|
445
|
+
createdAt: string;
|
|
446
|
+
payUrl: string | null;
|
|
447
|
+
}
|
|
448
|
+
/** Invoice statuses a customer can still pay. */
|
|
449
|
+
declare const PAYABLE_STATUSES: readonly ["pending", "overdue", "failed"];
|
|
450
|
+
declare function isPayable(status: string): boolean;
|
|
451
|
+
/**
|
|
452
|
+
* Catalog + quotes (public, no sign-in) and the caller's own subscriptions + invoices
|
|
453
|
+
* (console, session or PAT). Read-only: nothing here creates orders or invoices.
|
|
454
|
+
*/
|
|
455
|
+
declare class BillingApi {
|
|
456
|
+
private readonly client;
|
|
457
|
+
private readonly pub;
|
|
458
|
+
constructor(client: RoxyonClient, pub?: RoxyonClient);
|
|
459
|
+
catalog(): Promise<CatalogProduct[]>;
|
|
460
|
+
/** What checkout would charge for a new subscription: the server's own pricing (GET /_payment/quote). */
|
|
461
|
+
quote(input: QuoteInput): Promise<Quote>;
|
|
462
|
+
/** The caller's own subscriptions (rows they own), newest first. */
|
|
463
|
+
subscriptions(): Promise<BillingSubscription[]>;
|
|
464
|
+
/** The caller's own invoices, newest first. */
|
|
465
|
+
invoices(opts?: {
|
|
466
|
+
status?: string;
|
|
467
|
+
limit?: number;
|
|
468
|
+
}): Promise<Invoice[]>;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
interface CreateDatabaseInput {
|
|
472
|
+
/** DB name suffix — the platform prefixes it with the subscription's own username (globally unique). */
|
|
473
|
+
name: string;
|
|
474
|
+
/** Subscription to attach it to. Omit when the account has exactly one. */
|
|
475
|
+
subscription?: string;
|
|
476
|
+
/** Omit to have the platform generate one. */
|
|
477
|
+
password?: string;
|
|
478
|
+
}
|
|
479
|
+
interface CreateDatabaseResult {
|
|
480
|
+
ok: boolean;
|
|
481
|
+
objectId: string;
|
|
482
|
+
name: string;
|
|
483
|
+
username: string;
|
|
484
|
+
/** Shown once — not retrievable afterwards. */
|
|
485
|
+
password?: string;
|
|
486
|
+
/** `<node-ip>:6033` — the ProxySQL endpoint to connect the app to. */
|
|
487
|
+
host?: string;
|
|
488
|
+
status: 'provisioning' | 'active' | 'failed';
|
|
489
|
+
error?: string;
|
|
490
|
+
}
|
|
491
|
+
interface DatabaseSummary {
|
|
492
|
+
objectId: string;
|
|
493
|
+
Name: string;
|
|
494
|
+
Username: string;
|
|
495
|
+
Status: string;
|
|
496
|
+
}
|
|
497
|
+
interface DeleteDatabaseResult {
|
|
498
|
+
ok: boolean;
|
|
499
|
+
objectId: string;
|
|
500
|
+
status: 'deleting' | 'deleted' | 'failed';
|
|
501
|
+
error?: string;
|
|
502
|
+
}
|
|
503
|
+
/** Databases (MySQL/MariaDB on the shared Galera cluster) attached to a subscription. */
|
|
504
|
+
declare class DatabasesApi {
|
|
505
|
+
private readonly client;
|
|
506
|
+
constructor(client: RoxyonClient);
|
|
507
|
+
list(subscriptionId: string): Promise<DatabaseSummary[]>;
|
|
508
|
+
/** `POST /databases/create` — provision a database + user; the reconciler does the rest. */
|
|
509
|
+
create(input: CreateDatabaseInput): Promise<CreateDatabaseResult>;
|
|
510
|
+
/** `POST /databases/delete` */
|
|
511
|
+
delete(databaseId: string): Promise<DeleteDatabaseResult>;
|
|
512
|
+
}
|
|
513
|
+
|
|
367
514
|
interface Domain {
|
|
368
515
|
objectId: string;
|
|
369
516
|
Name: string;
|
|
@@ -375,6 +522,8 @@ interface CreateDomainInput {
|
|
|
375
522
|
subscription?: string;
|
|
376
523
|
/** `spa` → unmatched paths serve `/index.html`; default `static`. */
|
|
377
524
|
siteType?: 'static' | 'spa';
|
|
525
|
+
/** PHP version for the vhost (e.g. `"8.3"`). Unknown/omitted falls back to the platform default. */
|
|
526
|
+
phpVersion?: string;
|
|
378
527
|
}
|
|
379
528
|
interface CreateDomainResult {
|
|
380
529
|
ok: boolean;
|
|
@@ -399,6 +548,52 @@ declare class DomainsApi {
|
|
|
399
548
|
create(input: CreateDomainInput): Promise<CreateDomainResult>;
|
|
400
549
|
}
|
|
401
550
|
|
|
551
|
+
interface CreateEmailInput {
|
|
552
|
+
/** The part before `@`. */
|
|
553
|
+
localPart: string;
|
|
554
|
+
/** A hostname already on the account. */
|
|
555
|
+
domain: string;
|
|
556
|
+
/** Omit to have the platform generate one. */
|
|
557
|
+
password?: string;
|
|
558
|
+
/** Mailbox quota in MB. Default 1024. */
|
|
559
|
+
quota?: number;
|
|
560
|
+
forwardTo?: string;
|
|
561
|
+
saveCopy?: boolean;
|
|
562
|
+
}
|
|
563
|
+
interface CreateEmailResult {
|
|
564
|
+
ok: boolean;
|
|
565
|
+
objectId: string;
|
|
566
|
+
email: string;
|
|
567
|
+
/** Shown once — not retrievable afterwards. */
|
|
568
|
+
password?: string;
|
|
569
|
+
quota?: number;
|
|
570
|
+
status: 'provisioning' | 'active' | 'failed';
|
|
571
|
+
error?: string;
|
|
572
|
+
}
|
|
573
|
+
interface EmailSummary {
|
|
574
|
+
objectId: string;
|
|
575
|
+
Email: string;
|
|
576
|
+
LocalPart: string;
|
|
577
|
+
Status: string;
|
|
578
|
+
Quota?: number;
|
|
579
|
+
}
|
|
580
|
+
interface DeleteEmailResult {
|
|
581
|
+
ok: boolean;
|
|
582
|
+
objectId: string;
|
|
583
|
+
status: 'deleting' | 'deleted' | 'failed';
|
|
584
|
+
error?: string;
|
|
585
|
+
}
|
|
586
|
+
/** Mailboxes attached to a subscription's domains. */
|
|
587
|
+
declare class EmailApi {
|
|
588
|
+
private readonly client;
|
|
589
|
+
constructor(client: RoxyonClient);
|
|
590
|
+
list(subscriptionId: string): Promise<EmailSummary[]>;
|
|
591
|
+
/** `POST /emails/create` — provision a mailbox; the reconciler does the rest. */
|
|
592
|
+
create(input: CreateEmailInput): Promise<CreateEmailResult>;
|
|
593
|
+
/** `POST /emails/delete` */
|
|
594
|
+
delete(emailId: string): Promise<DeleteEmailResult>;
|
|
595
|
+
}
|
|
596
|
+
|
|
402
597
|
interface StaticDeployResult {
|
|
403
598
|
ok: boolean;
|
|
404
599
|
host: string;
|
|
@@ -442,6 +637,30 @@ declare class SitesApi {
|
|
|
442
637
|
readFile(host: string, folder: string, path: string): Promise<SiteFileContent>;
|
|
443
638
|
}
|
|
444
639
|
|
|
640
|
+
interface ResetSshPasswordInput {
|
|
641
|
+
/** Subscription to reset. Omit when the account has exactly one. */
|
|
642
|
+
subscription?: string;
|
|
643
|
+
/** Omit to have the platform generate one meeting the strength rules. */
|
|
644
|
+
password?: string;
|
|
645
|
+
}
|
|
646
|
+
interface ResetSshPasswordResult {
|
|
647
|
+
ok: boolean;
|
|
648
|
+
subscription: string;
|
|
649
|
+
/** Shown once — the platform never stores or re-shows it. */
|
|
650
|
+
password: string;
|
|
651
|
+
status: 'pending' | 'active' | 'failed';
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* The shared shell password used for SSH, SFTP and the file manager on a
|
|
655
|
+
* subscription's container (SSHpiper maps the username to the container).
|
|
656
|
+
*/
|
|
657
|
+
declare class SshApi {
|
|
658
|
+
private readonly client;
|
|
659
|
+
constructor(client: RoxyonClient);
|
|
660
|
+
/** `POST /ssh/password` */
|
|
661
|
+
resetPassword(input?: ResetSshPasswordInput): Promise<ResetSshPasswordResult>;
|
|
662
|
+
}
|
|
663
|
+
|
|
445
664
|
interface Subscription {
|
|
446
665
|
objectId: string;
|
|
447
666
|
Name?: string;
|
|
@@ -471,6 +690,76 @@ declare class SubscriptionsApi {
|
|
|
471
690
|
resolve(userId: string, preferred?: string): Promise<Subscription>;
|
|
472
691
|
}
|
|
473
692
|
|
|
693
|
+
/** BaaS V2 base. V1 (`/1`) is frozen; app data tools speak V2 only. */
|
|
694
|
+
declare const DEFAULT_BAAS_V2_URL = "https://www.beaapis.com/2";
|
|
695
|
+
/** V2 caps one page at 200 rows. */
|
|
696
|
+
declare const BAAS_MAX_PAGE = 200;
|
|
697
|
+
/** V2 takes 1 to 50 requests per batch. */
|
|
698
|
+
declare const BAAS_MAX_BATCH = 50;
|
|
699
|
+
interface BaasDataOptions {
|
|
700
|
+
/** The app's secret key (`rxsk_…`): server scope, from the project's API keys in Roxyon Base. */
|
|
701
|
+
secretKey: string;
|
|
702
|
+
baseUrl?: string;
|
|
703
|
+
fetch?: typeof fetch;
|
|
704
|
+
}
|
|
705
|
+
type BaasRow = Record<string, unknown>;
|
|
706
|
+
interface BaasQuery {
|
|
707
|
+
/** e.g. `{ Status: 'active', Age: { gt: 18 } }`; `in` takes a comma-joined string. */
|
|
708
|
+
where?: Record<string, unknown>;
|
|
709
|
+
/** `*` and/or column names, comma separated. Defaults to `*`. */
|
|
710
|
+
fields?: string;
|
|
711
|
+
/** Comma list, `-` for descending, e.g. `-createdAt`. */
|
|
712
|
+
order?: string;
|
|
713
|
+
/** 1 to 200 (default 50). */
|
|
714
|
+
limit?: number;
|
|
715
|
+
skip?: number;
|
|
716
|
+
/** Also return the total number of matching rows. */
|
|
717
|
+
count?: boolean;
|
|
718
|
+
}
|
|
719
|
+
interface BaasBatchRequest {
|
|
720
|
+
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
721
|
+
/** `/Class` or `/Class/<id>`. */
|
|
722
|
+
path: string;
|
|
723
|
+
body?: Record<string, unknown>;
|
|
724
|
+
}
|
|
725
|
+
/** One batch answer: `ok:false` with `error`/`message`, or that request's own V2 answer. */
|
|
726
|
+
interface BaasBatchResult {
|
|
727
|
+
status: number;
|
|
728
|
+
ok?: boolean;
|
|
729
|
+
error?: string;
|
|
730
|
+
message?: string;
|
|
731
|
+
result?: BaasRow;
|
|
732
|
+
results?: BaasRow[];
|
|
733
|
+
count?: number;
|
|
734
|
+
id?: string;
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* Records of ONE app on BaaS V2, as that app's own backend (server scope, `X-RX-Secret-Key`).
|
|
738
|
+
* Server scope passes every class rule, so treat the key like a database password. V2 answers
|
|
739
|
+
* failures as `{ok:false, error, message}` with an HTTP status; every call throws on those.
|
|
740
|
+
* Schema changes are not reachable with a secret key (console API only).
|
|
741
|
+
*/
|
|
742
|
+
declare class BaasDataApi {
|
|
743
|
+
private readonly baseUrl;
|
|
744
|
+
private readonly secretKey;
|
|
745
|
+
private readonly _fetch;
|
|
746
|
+
constructor(opts: BaasDataOptions);
|
|
747
|
+
private call;
|
|
748
|
+
private static recordPath;
|
|
749
|
+
query(className: string, q?: BaasQuery): Promise<{
|
|
750
|
+
rows: BaasRow[];
|
|
751
|
+
count?: number;
|
|
752
|
+
}>;
|
|
753
|
+
get(className: string, objectId: string): Promise<BaasRow>;
|
|
754
|
+
/** Returns the created row as stored. */
|
|
755
|
+
create(className: string, data: BaasRow): Promise<BaasRow>;
|
|
756
|
+
update(className: string, objectId: string, data: BaasRow): Promise<BaasRow>;
|
|
757
|
+
/** The id goes in the URL path, never the body. */
|
|
758
|
+
delete(className: string, objectId: string): Promise<void>;
|
|
759
|
+
/** 1 to 50 record requests in one call; one failing doesn't stop the others. */
|
|
760
|
+
batch(requests: BaasBatchRequest[]): Promise<BaasBatchResult[]>;
|
|
761
|
+
}
|
|
762
|
+
|
|
474
763
|
/** Returns the error message from a BaaS response, or `''` when the call worked. */
|
|
475
764
|
declare function rxError(r: unknown): string;
|
|
476
765
|
declare class RoxyonApiError extends Error {
|
|
@@ -577,8 +866,12 @@ declare class Roxyon {
|
|
|
577
866
|
readonly domains: DomainsApi;
|
|
578
867
|
readonly applications: ApplicationsApi;
|
|
579
868
|
readonly sites: SitesApi;
|
|
869
|
+
readonly databases: DatabasesApi;
|
|
870
|
+
readonly email: EmailApi;
|
|
871
|
+
readonly ssh: SshApi;
|
|
872
|
+
readonly billing: BillingApi;
|
|
580
873
|
constructor(options?: RoxyonClientOptions | RoxyonClient);
|
|
581
874
|
get sessionToken(): string | undefined;
|
|
582
875
|
}
|
|
583
876
|
|
|
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 };
|
|
877
|
+
export { AccountApi, type AccountApp, type AccountContext, type AccountDomain, type AccountSubscription, type Application, type ApplicationProcess, type ApplicationRoute, ApplicationsApi, AuthApi, BAAS_MAX_BATCH, BAAS_MAX_PAGE, BILLING_CYCLES, type BaasBatchRequest, type BaasBatchResult, BaasDataApi, type BaasDataOptions, type BaasQuery, type BaasRow, BillingApi, type BillingCycle, type BillingSubscription, type CatalogProduct, type CreateApplicationInput, type CreateDatabaseInput, type CreateDatabaseResult, type CreateDomainInput, type CreateDomainResult, type CreateEmailInput, type CreateEmailResult, type CreateOnDeploy, type CreatedToken, DEFAULT_APP, DEFAULT_BAAS_URL, DEFAULT_BAAS_V2_URL, DEFAULT_CONSOLE_URL, type DatabaseSummary, DatabasesApi, type DeleteDatabaseResult, type DeleteEmailResult, type DeployKind, type DeployOptions, type DeployResult, type Domain, DomainsApi, EmailApi, type EmailSummary, type Invoice, LUMEN_BUILD, type LoginPrecheck, type LoginResult, PAYABLE_STATUSES, type Privilege, type Quote, type QuoteInput, 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, isPayable, parseEnv, rxError, toQueryString };
|