@roxyon/api-client 0.1.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/LICENSE +21 -0
- package/README.md +40 -0
- package/dist/index.cjs +856 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +543 -0
- package/dist/index.d.ts +543 -0
- package/dist/index.js +808 -0
- package/dist/index.js.map +1 -0
- package/package.json +43 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,543 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GET query serialisation for the BaaS, matching the `Obj2Par` helper in the
|
|
3
|
+
* browser SDK (`rx.js`): nested objects become PHP-style bracket keys
|
|
4
|
+
* (`where[User]=abc`, `where[Status][in]=a,b,c`).
|
|
5
|
+
*
|
|
6
|
+
* Two hard-won rules (see the `roxyon-api-write-failures` notes):
|
|
7
|
+
* - The `in` operator takes a **comma-joined string, not an array**. An array
|
|
8
|
+
* serialises to `where[X][in][0]=…` bracket notation the API does not read.
|
|
9
|
+
* Pass `{ in: ['a', 'b'] }` here and we join it for you.
|
|
10
|
+
* - A `select` subquery nested inside an `or` group crashes the API. Resolve
|
|
11
|
+
* ids in a first query, then `or: [..., { objectId: { in: 'a,b' } }]`.
|
|
12
|
+
*/
|
|
13
|
+
type QueryValue = string | number | boolean | null | undefined | QueryValue[] | {
|
|
14
|
+
[k: string]: QueryValue;
|
|
15
|
+
};
|
|
16
|
+
type QueryObject = Record<string, QueryValue>;
|
|
17
|
+
/** Serialise a query object to a `key=value&...` string (no leading `?`). */
|
|
18
|
+
declare function toQueryString(query: QueryObject | undefined): string;
|
|
19
|
+
|
|
20
|
+
interface RoxyonClientOptions {
|
|
21
|
+
/** BaaS application id. Defaults to the public console app. */
|
|
22
|
+
appId?: string;
|
|
23
|
+
/** Public JavaScript key, used to mint an anonymous token. */
|
|
24
|
+
javascriptKey?: string;
|
|
25
|
+
/** REST API key. Optional; grants full access — only for trusted server use. */
|
|
26
|
+
restKey?: string;
|
|
27
|
+
/** A user session token (from {@link AuthApi.login}). */
|
|
28
|
+
sessionToken?: string;
|
|
29
|
+
/** BaaS REST base, e.g. `https://www.beaapis.com/1`. */
|
|
30
|
+
baseUrl?: string;
|
|
31
|
+
/** Console base that serves the `/applications/*` endpoints. */
|
|
32
|
+
consoleUrl?: string;
|
|
33
|
+
/** Custom fetch (tests / proxies). */
|
|
34
|
+
fetch?: typeof fetch;
|
|
35
|
+
}
|
|
36
|
+
interface RequestOptions {
|
|
37
|
+
query?: QueryObject;
|
|
38
|
+
body?: unknown;
|
|
39
|
+
headers?: Record<string, string>;
|
|
40
|
+
/** Skip the Authorization/session header entirely (used for token minting). */
|
|
41
|
+
skipAuth?: boolean;
|
|
42
|
+
/** Send/parse the response even on a non-2xx status instead of throwing. */
|
|
43
|
+
tolerateHttpError?: boolean;
|
|
44
|
+
signal?: AbortSignal;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Low-level transport for the Roxyon BaaS and console app endpoints.
|
|
48
|
+
*
|
|
49
|
+
* Auth precedence per request: explicit `sessionToken` -> `restKey` ->
|
|
50
|
+
* a lazily-minted anonymous access token (public app credentials).
|
|
51
|
+
*/
|
|
52
|
+
declare class RoxyonClient {
|
|
53
|
+
readonly baseUrl: string;
|
|
54
|
+
readonly consoleUrl: string;
|
|
55
|
+
private readonly appId;
|
|
56
|
+
private readonly javascriptKey;
|
|
57
|
+
private readonly restKey?;
|
|
58
|
+
private readonly _fetch;
|
|
59
|
+
private sessionToken?;
|
|
60
|
+
private anon?;
|
|
61
|
+
constructor(opts?: RoxyonClientOptions);
|
|
62
|
+
getSessionToken(): string | undefined;
|
|
63
|
+
setSessionToken(token: string | undefined): void;
|
|
64
|
+
/** Mint (or reuse) an anonymous access token from the public app credentials. */
|
|
65
|
+
private anonToken;
|
|
66
|
+
/** A Personal Access Token (`roxp_…`) authenticates the console endpoints via
|
|
67
|
+
* `Authorization: Bearer`; it is not a BaaS session token. */
|
|
68
|
+
private get isPat();
|
|
69
|
+
private authHeaders;
|
|
70
|
+
/** A raw BaaS request. `path` is relative to {@link baseUrl} (leading `/`). */
|
|
71
|
+
request<T = unknown>(method: string, path: string, opts?: RequestOptions): Promise<T>;
|
|
72
|
+
/** A request against the console app endpoints ({@link consoleUrl}). */
|
|
73
|
+
console<T = unknown>(method: string, path: string, opts?: RequestOptions): Promise<T>;
|
|
74
|
+
private rawRequest;
|
|
75
|
+
get<T = unknown>(path: string, query?: QueryObject, opts?: RequestOptions): Promise<T>;
|
|
76
|
+
post<T = unknown>(path: string, body?: unknown, opts?: RequestOptions): Promise<T>;
|
|
77
|
+
put<T = unknown>(path: string, body?: unknown, opts?: RequestOptions): Promise<T>;
|
|
78
|
+
del<T = unknown>(path: string, body?: unknown, opts?: RequestOptions): Promise<T>;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
type TokenScope = 'deploy' | 'logs' | 'read';
|
|
82
|
+
interface TokenSummary {
|
|
83
|
+
id: string;
|
|
84
|
+
name: string;
|
|
85
|
+
prefix: string;
|
|
86
|
+
scopes: TokenScope[];
|
|
87
|
+
lastUsedAt: string | null;
|
|
88
|
+
expiresAt: string | null;
|
|
89
|
+
createdAt: string;
|
|
90
|
+
}
|
|
91
|
+
interface CreatedToken {
|
|
92
|
+
/** The full `roxp_…` secret — shown once. Use it as `ROXYON_TOKEN`. */
|
|
93
|
+
token: string;
|
|
94
|
+
name: string;
|
|
95
|
+
scopes: TokenScope[];
|
|
96
|
+
expiresAt: string | null;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Personal Access Tokens — for the CLI in CI and for the MCP server running
|
|
100
|
+
* headless. Managed only while signed in with a session (`roxyon login`); a PAT
|
|
101
|
+
* cannot mint or revoke another PAT.
|
|
102
|
+
*
|
|
103
|
+
* `GET/POST/DELETE /account/tokens` — console endpoints.
|
|
104
|
+
*/
|
|
105
|
+
declare class TokensApi {
|
|
106
|
+
private readonly client;
|
|
107
|
+
constructor(client: RoxyonClient);
|
|
108
|
+
list(): Promise<TokenSummary[]>;
|
|
109
|
+
create(name: string, opts?: {
|
|
110
|
+
scopes?: TokenScope[];
|
|
111
|
+
expiresInDays?: number;
|
|
112
|
+
}): Promise<CreatedToken>;
|
|
113
|
+
revoke(id: string): Promise<void>;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
interface AccountSubscription {
|
|
117
|
+
id: string;
|
|
118
|
+
name: string;
|
|
119
|
+
status: string;
|
|
120
|
+
node: string;
|
|
121
|
+
datacenter: string;
|
|
122
|
+
container: string;
|
|
123
|
+
}
|
|
124
|
+
interface AccountDomain {
|
|
125
|
+
id: string;
|
|
126
|
+
name: string;
|
|
127
|
+
subscription: string;
|
|
128
|
+
}
|
|
129
|
+
interface AccountContext {
|
|
130
|
+
user: {
|
|
131
|
+
id: string;
|
|
132
|
+
email: string;
|
|
133
|
+
};
|
|
134
|
+
scopes: (TokenScope | '*')[];
|
|
135
|
+
subscriptions: AccountSubscription[];
|
|
136
|
+
domains: AccountDomain[];
|
|
137
|
+
}
|
|
138
|
+
interface AccountApp {
|
|
139
|
+
id: string;
|
|
140
|
+
name: string;
|
|
141
|
+
status: string;
|
|
142
|
+
desiredState: string;
|
|
143
|
+
runtime: string;
|
|
144
|
+
configRevision: number;
|
|
145
|
+
appliedRevision: number;
|
|
146
|
+
lastError: string | null;
|
|
147
|
+
sourcePath: string;
|
|
148
|
+
repo: {
|
|
149
|
+
url: string;
|
|
150
|
+
branch: string;
|
|
151
|
+
} | null;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* `GET /account/context` — one call the CLI / MCP server use to plan a deploy:
|
|
155
|
+
* the signed-in user, their subscriptions (with node), and their domains.
|
|
156
|
+
* Resolvable by a session token OR a Personal Access Token, so a CI job with
|
|
157
|
+
* only a PAT never has to touch the BaaS.
|
|
158
|
+
*/
|
|
159
|
+
declare class AccountApi {
|
|
160
|
+
private readonly client;
|
|
161
|
+
private cache?;
|
|
162
|
+
constructor(client: RoxyonClient);
|
|
163
|
+
context(opts?: {
|
|
164
|
+
fresh?: boolean;
|
|
165
|
+
}): Promise<AccountContext>;
|
|
166
|
+
private fetch;
|
|
167
|
+
/** `GET /account/apps` — the account's applications (list, PAT-safe). */
|
|
168
|
+
apps(): Promise<AccountApp[]>;
|
|
169
|
+
/** One application by id, PAT-safe (filters {@link apps}). */
|
|
170
|
+
getApp(id: string): Promise<AccountApp | undefined>;
|
|
171
|
+
/** Pick the subscription to deploy against — the preferred one, else the only/first. */
|
|
172
|
+
resolveSubscription(preferred?: string): Promise<AccountSubscription>;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
interface Application {
|
|
176
|
+
objectId: string;
|
|
177
|
+
Name: string;
|
|
178
|
+
Status?: string;
|
|
179
|
+
DesiredState?: string;
|
|
180
|
+
SourcePath?: string;
|
|
181
|
+
Runtime?: string;
|
|
182
|
+
RuntimeVersion?: string;
|
|
183
|
+
Preset?: string;
|
|
184
|
+
ConfigRevision?: number;
|
|
185
|
+
AppliedRevision?: number;
|
|
186
|
+
LastError?: string;
|
|
187
|
+
Env?: string;
|
|
188
|
+
RepoUrl?: string;
|
|
189
|
+
Subscription?: string;
|
|
190
|
+
[k: string]: unknown;
|
|
191
|
+
}
|
|
192
|
+
interface ApplicationProcess {
|
|
193
|
+
objectId: string;
|
|
194
|
+
Application?: string;
|
|
195
|
+
Type?: string;
|
|
196
|
+
Command?: string;
|
|
197
|
+
Status?: string;
|
|
198
|
+
Port?: number;
|
|
199
|
+
}
|
|
200
|
+
interface ApplicationRoute {
|
|
201
|
+
objectId: string;
|
|
202
|
+
Application?: string;
|
|
203
|
+
Domain?: string;
|
|
204
|
+
Path?: string;
|
|
205
|
+
Enabled?: number | string;
|
|
206
|
+
}
|
|
207
|
+
interface DeployResult {
|
|
208
|
+
ok: boolean;
|
|
209
|
+
application: string;
|
|
210
|
+
created?: boolean;
|
|
211
|
+
configRevision?: number;
|
|
212
|
+
files?: number;
|
|
213
|
+
bytes?: number;
|
|
214
|
+
error?: string;
|
|
215
|
+
}
|
|
216
|
+
/** Params for creating an application on its first deploy (no id yet). */
|
|
217
|
+
interface CreateOnDeploy {
|
|
218
|
+
host: string;
|
|
219
|
+
folder?: string;
|
|
220
|
+
runtime: 'node' | 'python' | 'php';
|
|
221
|
+
runtimeVersion?: string;
|
|
222
|
+
preset?: string;
|
|
223
|
+
command?: string;
|
|
224
|
+
public?: boolean;
|
|
225
|
+
}
|
|
226
|
+
interface CreateApplicationInput {
|
|
227
|
+
subscription: string;
|
|
228
|
+
name: string;
|
|
229
|
+
/** Absolute source path: `/home/www/<host>/public_html/<folder>`. */
|
|
230
|
+
sourcePath: string;
|
|
231
|
+
runtime: string;
|
|
232
|
+
runtimeVersion: string;
|
|
233
|
+
preset: string;
|
|
234
|
+
/** The web process start command. */
|
|
235
|
+
command: string;
|
|
236
|
+
/** Route host (`Domains.objectId`). */
|
|
237
|
+
domainId: string;
|
|
238
|
+
/** `.env`-style object stored as JSON on `Applications.Env`. */
|
|
239
|
+
env?: Record<string, string>;
|
|
240
|
+
/** Make the app public (route serves the app instead of the host's files). */
|
|
241
|
+
public?: boolean;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* The Roxyon Applications system. Deployment is declarative: rows describe the
|
|
245
|
+
* desired state and every meaningful change bumps `ConfigRevision`; a
|
|
246
|
+
* server-side reconciler builds the source in an isolated release dir and
|
|
247
|
+
* (re)starts a systemd unit, writing back `Status` / `AppliedRevision` /
|
|
248
|
+
* `LastError`. Mirrors `applications.view` + `modals/app_form.view`.
|
|
249
|
+
*/
|
|
250
|
+
declare class ApplicationsApi {
|
|
251
|
+
private readonly client;
|
|
252
|
+
constructor(client: RoxyonClient);
|
|
253
|
+
list(subscriptionId: string): Promise<Application[]>;
|
|
254
|
+
get(id: string): Promise<Application | undefined>;
|
|
255
|
+
/** Create the application + its web process + a route, matching `createNew()`. */
|
|
256
|
+
create(input: CreateApplicationInput): Promise<{
|
|
257
|
+
application: string;
|
|
258
|
+
process: string;
|
|
259
|
+
route: string;
|
|
260
|
+
}>;
|
|
261
|
+
/** Read an application's environment. `GET /applications/env`. */
|
|
262
|
+
getEnv(applicationId: string): Promise<Record<string, string>>;
|
|
263
|
+
/**
|
|
264
|
+
* Merge `set` and delete `remove`, bumping `ConfigRevision`. `PORT`/`HOST` are
|
|
265
|
+
* ignored (platform-managed). `POST /applications/env`. Returns the new env.
|
|
266
|
+
*/
|
|
267
|
+
setEnv(applicationId: string, changes: {
|
|
268
|
+
set?: Record<string, string>;
|
|
269
|
+
remove?: string[];
|
|
270
|
+
}): Promise<{
|
|
271
|
+
env: Record<string, string>;
|
|
272
|
+
changed: string[];
|
|
273
|
+
configRevision: number;
|
|
274
|
+
}>;
|
|
275
|
+
/** Rebuild from the latest source and restart. `POST /applications/action`. */
|
|
276
|
+
deploy(applicationId: string): Promise<void>;
|
|
277
|
+
/** Bounce the process only — no rebuild. `POST /applications/action`. */
|
|
278
|
+
restart(applicationId: string): Promise<void>;
|
|
279
|
+
/**
|
|
280
|
+
* Tail the app's journal. `POST /applications/logs` returns one block per
|
|
281
|
+
* process (`{ type, unit, output }`); this flattens them to lines, each
|
|
282
|
+
* prefixed with the process type when there is more than one.
|
|
283
|
+
*/
|
|
284
|
+
logs(applicationId: string, lines?: number): Promise<string[]>;
|
|
285
|
+
/** Connect a git remote for push-to-deploy. `POST /applications/repo/connect`. */
|
|
286
|
+
repoConnect(applicationId: string, repoUrl: string, branch?: string): Promise<{
|
|
287
|
+
provider?: string;
|
|
288
|
+
deployKey?: string;
|
|
289
|
+
webhookUrl?: string;
|
|
290
|
+
secret?: string;
|
|
291
|
+
hint?: string;
|
|
292
|
+
}>;
|
|
293
|
+
/**
|
|
294
|
+
* Upload a gzipped tarball of the project source. The endpoint lands it in the
|
|
295
|
+
* application's `SourcePath` and bumps `ConfigRevision` (the reconciler then
|
|
296
|
+
* builds it in a release dir exactly as for a git deploy).
|
|
297
|
+
*
|
|
298
|
+
* `POST /applications/deploy` — NEW endpoint (see `backend/` in this repo).
|
|
299
|
+
*/
|
|
300
|
+
uploadSource(target: string | CreateOnDeploy, tarball: Uint8Array): Promise<DeployResult>;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
interface SessionGrant {
|
|
304
|
+
session_token: string;
|
|
305
|
+
refresh_token?: string;
|
|
306
|
+
expires_in?: number;
|
|
307
|
+
status?: string;
|
|
308
|
+
}
|
|
309
|
+
interface RoxyonUser {
|
|
310
|
+
objectId: string;
|
|
311
|
+
Email?: string;
|
|
312
|
+
Username?: string;
|
|
313
|
+
Name?: string;
|
|
314
|
+
Currency?: string;
|
|
315
|
+
Language?: string;
|
|
316
|
+
[k: string]: unknown;
|
|
317
|
+
}
|
|
318
|
+
interface LoginPrecheck {
|
|
319
|
+
ok?: boolean;
|
|
320
|
+
error?: string;
|
|
321
|
+
stepUpRequired?: boolean;
|
|
322
|
+
challengeId?: string;
|
|
323
|
+
}
|
|
324
|
+
interface LoginResult {
|
|
325
|
+
sessionToken: string;
|
|
326
|
+
refreshToken?: string;
|
|
327
|
+
expiresIn?: number;
|
|
328
|
+
/** True when an OTP code is still required — call {@link AuthApi.verifyOtp}. */
|
|
329
|
+
stepUpRequired?: boolean;
|
|
330
|
+
challengeId?: string;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Wraps the console's login flow:
|
|
334
|
+
* 1. `POST /_account/login-precheck` — validates credentials, decides whether
|
|
335
|
+
* an OTP step-up is required, and (when it is) returns a `challengeId`.
|
|
336
|
+
* 2a. no step-up -> `POST /Auth/login` finalises and returns a session token.
|
|
337
|
+
* 2b. step-up -> caller collects the code, then `POST /Auth/login/otp-verify`.
|
|
338
|
+
*
|
|
339
|
+
* Mirrors `signin.view` / `otp.view` in `console.roxyon.com`.
|
|
340
|
+
*/
|
|
341
|
+
declare class AuthApi {
|
|
342
|
+
private readonly client;
|
|
343
|
+
constructor(client: RoxyonClient);
|
|
344
|
+
/**
|
|
345
|
+
* Best-effort device/step-up precheck. `/_account/login-precheck` is a console
|
|
346
|
+
* cloud function that may be gated behind the REST key (not reachable from a
|
|
347
|
+
* public client) — in that case this resolves to `{}` and login falls back to
|
|
348
|
+
* `/Auth/login`, which is itself the security boundary and re-checks the
|
|
349
|
+
* device. Only a definitive `{ ok: false }` / `stepUpRequired` is acted on.
|
|
350
|
+
*/
|
|
351
|
+
precheck(email: string, password: string, metadata?: Record<string, string>): Promise<LoginPrecheck>;
|
|
352
|
+
/**
|
|
353
|
+
* Full login. Returns a session token on success, or `stepUpRequired` with a
|
|
354
|
+
* `challengeId` when an OTP code is needed next.
|
|
355
|
+
*/
|
|
356
|
+
login(email: string, password: string, metadata?: Record<string, string>): Promise<LoginResult>;
|
|
357
|
+
/** Complete an OTP step-up with the code the user received. */
|
|
358
|
+
verifyOtp(challengeId: string, code: string): Promise<LoginResult>;
|
|
359
|
+
/** Start an OTP-only sign-in (no password). Returns a `challengeId`. */
|
|
360
|
+
startOtp(email: string): Promise<{
|
|
361
|
+
challengeId: string;
|
|
362
|
+
}>;
|
|
363
|
+
/** The currently authenticated user. Requires a session token on the client. */
|
|
364
|
+
me(): Promise<RoxyonUser>;
|
|
365
|
+
logout(): Promise<void>;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
interface Domain {
|
|
369
|
+
objectId: string;
|
|
370
|
+
Name: string;
|
|
371
|
+
}
|
|
372
|
+
/** Domains (hosts) attached to a subscription — used to place an application. */
|
|
373
|
+
declare class DomainsApi {
|
|
374
|
+
private readonly client;
|
|
375
|
+
constructor(client: RoxyonClient);
|
|
376
|
+
list(subscriptionId: string): Promise<Domain[]>;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
interface StaticDeployResult {
|
|
380
|
+
ok: boolean;
|
|
381
|
+
host: string;
|
|
382
|
+
path: string;
|
|
383
|
+
files?: number;
|
|
384
|
+
error?: string;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Static-site deploy: upload built files (a LumenJS `--serverless` build, or any
|
|
388
|
+
* static output) into a host's document root
|
|
389
|
+
* (`/home/www/<host>/public_html[/<folder>]`), served directly by nginx. No
|
|
390
|
+
* Application row, no process.
|
|
391
|
+
*
|
|
392
|
+
* `POST /sites/deploy` — NEW endpoint (see `backend/` in this repo).
|
|
393
|
+
*/
|
|
394
|
+
declare class SitesApi {
|
|
395
|
+
private readonly client;
|
|
396
|
+
constructor(client: RoxyonClient);
|
|
397
|
+
deploy(host: string, folder: string, tarball: Uint8Array): Promise<StaticDeployResult>;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
interface Subscription {
|
|
401
|
+
objectId: string;
|
|
402
|
+
Name?: string;
|
|
403
|
+
Status?: string;
|
|
404
|
+
Username?: string;
|
|
405
|
+
/** Infra node the subscription's container lives on (internal). */
|
|
406
|
+
Node?: string;
|
|
407
|
+
Datacenter?: string;
|
|
408
|
+
[k: string]: unknown;
|
|
409
|
+
}
|
|
410
|
+
interface Privilege {
|
|
411
|
+
objectId: string;
|
|
412
|
+
Type?: string;
|
|
413
|
+
Subscription?: string;
|
|
414
|
+
_Subscription?: {
|
|
415
|
+
results: Subscription[];
|
|
416
|
+
};
|
|
417
|
+
[k: string]: unknown;
|
|
418
|
+
}
|
|
419
|
+
/** Access to the caller's subscriptions (via their Privileges rows). */
|
|
420
|
+
declare class SubscriptionsApi {
|
|
421
|
+
private readonly client;
|
|
422
|
+
constructor(client: RoxyonClient);
|
|
423
|
+
/** All subscriptions the signed-in user has a Privilege on. */
|
|
424
|
+
list(userId: string): Promise<Subscription[]>;
|
|
425
|
+
/**
|
|
426
|
+
* Resolve the subscription to act on. Prefers an exact `objectId` or `Name`
|
|
427
|
+
* match against `preferred`; otherwise the first active subscription; otherwise
|
|
428
|
+
* the first one. Throws when the account has none.
|
|
429
|
+
*/
|
|
430
|
+
resolve(userId: string, preferred?: string): Promise<Subscription>;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/** Returns the error message from a BaaS response, or `''` when the call worked. */
|
|
434
|
+
declare function rxError(r: unknown): string;
|
|
435
|
+
declare class RoxyonApiError extends Error {
|
|
436
|
+
readonly code?: number;
|
|
437
|
+
readonly type?: string;
|
|
438
|
+
readonly status?: number;
|
|
439
|
+
readonly body: unknown;
|
|
440
|
+
constructor(message: string, opts?: {
|
|
441
|
+
code?: number;
|
|
442
|
+
type?: string;
|
|
443
|
+
status?: number;
|
|
444
|
+
body?: unknown;
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
/** True when an error looks like "the session/token is gone", so the caller can re-auth. */
|
|
448
|
+
declare function isAuthError(err: unknown): boolean;
|
|
449
|
+
/** Throw a {@link RoxyonApiError} if `r` carries a BaaS error; otherwise return it typed. */
|
|
450
|
+
declare function assertOk<T>(r: T): T;
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* `.env`-style block <-> JSON object, ported verbatim from `appfEnvParse` /
|
|
454
|
+
* `appfEnvToLines` in `console.roxyon.com/.../modals/app_form.view` so the CLI
|
|
455
|
+
* and the console form agree byte-for-byte on what `Applications.Env` holds.
|
|
456
|
+
*
|
|
457
|
+
* The server re-sanitises again (`ApplicationRenderer::envPair`), so this only
|
|
458
|
+
* needs to be reasonable. `PORT` and `HOST` are set by the platform — callers
|
|
459
|
+
* should not write them.
|
|
460
|
+
*/
|
|
461
|
+
declare function parseEnv(text: string): Record<string, string>;
|
|
462
|
+
declare function formatEnv(obj: Record<string, string> | null | undefined): string;
|
|
463
|
+
/** Parse the JSON string stored on `Applications.Env`. */
|
|
464
|
+
declare function envFromStored(jsonStr: string | undefined): Record<string, string>;
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Runtime / version / framework catalog — a verbatim copy of the `RUNTIMES`
|
|
468
|
+
* table in `console.roxyon.com/.../modals/app_form.view`. These are the versions
|
|
469
|
+
* actually installed in the Cloud Hosting containers; offering an uninstalled
|
|
470
|
+
* one produces a deploy that fails at build time for a reason the user cannot
|
|
471
|
+
* act on.
|
|
472
|
+
*
|
|
473
|
+
* TODO(M4): the console form and this file should both import one shared JSON
|
|
474
|
+
* published at `roxyon.com/runtimes.json` so they never drift.
|
|
475
|
+
*/
|
|
476
|
+
type RuntimeName = 'lumen' | 'node' | 'python' | 'php';
|
|
477
|
+
interface RuntimeSpec {
|
|
478
|
+
versions: string[];
|
|
479
|
+
defaultVersion: string;
|
|
480
|
+
presets: Array<[value: string, label: string]>;
|
|
481
|
+
command: string;
|
|
482
|
+
}
|
|
483
|
+
declare const RUNTIMES: Record<Exclude<RuntimeName, 'lumen'>, RuntimeSpec>;
|
|
484
|
+
/**
|
|
485
|
+
* A LumenJS project (`runtime: "lumen"`) builds to static files with
|
|
486
|
+
* `lm build --serverless` and is served straight from the host's document root
|
|
487
|
+
* by nginx — no long-running process, no systemd unit, no Application row. It
|
|
488
|
+
* deploys through the "static" path (upload the built `dist/` to
|
|
489
|
+
* `/home/www/<host>/public_html[/<folder>]`).
|
|
490
|
+
*
|
|
491
|
+
* Node / Python / PHP projects deploy through the "app" path (the Applications
|
|
492
|
+
* system: upload source, bump ConfigRevision, reconciler builds + runs it).
|
|
493
|
+
*/
|
|
494
|
+
type DeployKind = 'static' | 'app';
|
|
495
|
+
declare const LUMEN_BUILD: {
|
|
496
|
+
readonly command: "lm build --serverless";
|
|
497
|
+
/** Directory `lm build --serverless` writes to, relative to the project root. */
|
|
498
|
+
readonly outDir: "dist";
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Default endpoints and the public application credentials the client uses to
|
|
503
|
+
* mint an anonymous token before a user logs in.
|
|
504
|
+
*
|
|
505
|
+
* `X-BEA-JavaScript-Key` is a **public** key (it ships in browser bundles by
|
|
506
|
+
* design — see `console.roxyon.com/src/index.js`). It is safe to embed here.
|
|
507
|
+
* The REST key is never embedded — user actions always run under a session
|
|
508
|
+
* token or a Personal Access Token.
|
|
509
|
+
*
|
|
510
|
+
* TODO(M1): provision a dedicated `roxyon-cli` BaaS application and swap these
|
|
511
|
+
* for its App-ID / JavaScript-Key so CLI traffic is attributable and rate-limited
|
|
512
|
+
* separately from the web console. Until then the client reuses the console's
|
|
513
|
+
* public pair, which is already exposed in shipped frontend code.
|
|
514
|
+
*/
|
|
515
|
+
declare const DEFAULT_BAAS_URL = "https://www.beaapis.com/1";
|
|
516
|
+
declare const DEFAULT_CONSOLE_URL = "https://console.roxyon.com";
|
|
517
|
+
declare const DEFAULT_APP: {
|
|
518
|
+
readonly appId: "jAtp2zHGU3FbnrQWrToALFakd_vbiY0ywihn4Hj54lw";
|
|
519
|
+
readonly javascriptKey: "w2Y9USRg0COtNe-fUqOaC1OOOlNCnV2BG8GZF80w4x8";
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* Convenience facade bundling every sub-API over one {@link RoxyonClient}.
|
|
524
|
+
*
|
|
525
|
+
* ```ts
|
|
526
|
+
* const roxyon = new Roxyon({ sessionToken }); // or a roxp_ PAT
|
|
527
|
+
* const ctx = await roxyon.account.context(); // user + subs + domains
|
|
528
|
+
* ```
|
|
529
|
+
*/
|
|
530
|
+
declare class Roxyon {
|
|
531
|
+
readonly client: RoxyonClient;
|
|
532
|
+
readonly auth: AuthApi;
|
|
533
|
+
readonly account: AccountApi;
|
|
534
|
+
readonly tokens: TokensApi;
|
|
535
|
+
readonly subscriptions: SubscriptionsApi;
|
|
536
|
+
readonly domains: DomainsApi;
|
|
537
|
+
readonly applications: ApplicationsApi;
|
|
538
|
+
readonly sites: SitesApi;
|
|
539
|
+
constructor(options?: RoxyonClientOptions | RoxyonClient);
|
|
540
|
+
get sessionToken(): string | undefined;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
export { AccountApi, type AccountApp, type AccountContext, type AccountDomain, type AccountSubscription, type Application, type ApplicationProcess, type ApplicationRoute, ApplicationsApi, AuthApi, type CreateApplicationInput, type CreateOnDeploy, type CreatedToken, DEFAULT_APP, DEFAULT_BAAS_URL, DEFAULT_CONSOLE_URL, type DeployKind, 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, SitesApi, type StaticDeployResult, type Subscription, SubscriptionsApi, type TokenScope, type TokenSummary, TokensApi, assertOk, envFromStored, formatEnv, isAuthError, parseEnv, rxError, toQueryString };
|