@lizard-build/sdk 0.1.39 → 0.1.41
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 +58 -254
- package/dist/index.d.mts +559 -306
- package/dist/index.d.ts +559 -306
- package/dist/index.js +629 -285
- package/dist/index.mjs +625 -285
- package/package.json +9 -6
package/dist/index.d.mts
CHANGED
|
@@ -8,10 +8,383 @@ declare class ConnectionConfig {
|
|
|
8
8
|
readonly apiKey: string;
|
|
9
9
|
readonly apiUrl: string;
|
|
10
10
|
readonly timeoutMs: number;
|
|
11
|
+
readonly requestTimeoutMs: number;
|
|
11
12
|
constructor(opts?: ConnectionOpts);
|
|
12
13
|
get headers(): Record<string, string>;
|
|
13
14
|
}
|
|
14
15
|
|
|
16
|
+
interface StreamEvent {
|
|
17
|
+
event: string;
|
|
18
|
+
data: string;
|
|
19
|
+
id?: string;
|
|
20
|
+
}
|
|
21
|
+
/** HTTP transport. Calls never retry mutations or payments. */
|
|
22
|
+
declare class PlatformClient {
|
|
23
|
+
readonly config: ConnectionConfig;
|
|
24
|
+
constructor(opts: ConnectionOpts);
|
|
25
|
+
private json;
|
|
26
|
+
request<T>(method: string, path: string, body?: unknown): Promise<T>;
|
|
27
|
+
get<T>(path: string): Promise<T>;
|
|
28
|
+
post<T>(path: string, body?: unknown): Promise<T>;
|
|
29
|
+
put<T>(path: string, body: unknown): Promise<T>;
|
|
30
|
+
patch<T>(path: string, body: unknown): Promise<T>;
|
|
31
|
+
delete<T = void>(path: string, body?: unknown): Promise<T>;
|
|
32
|
+
applyConfig<T>(projectId: string, body: unknown): Promise<T>;
|
|
33
|
+
sendBytes<T>(method: string, path: string, body: Blob | Uint8Array | string, contentType?: string): Promise<T>;
|
|
34
|
+
postForm<T>(path: string, form: FormData): Promise<T>;
|
|
35
|
+
/** Preserves named events, multiline data and UTF-8 split across chunks. */
|
|
36
|
+
events(path: string, opts?: {
|
|
37
|
+
method?: string;
|
|
38
|
+
body?: unknown;
|
|
39
|
+
signal?: AbortSignal;
|
|
40
|
+
}): AsyncGenerator<StreamEvent>;
|
|
41
|
+
streamSse(path: string): AsyncGenerator<string>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
declare class StorageAPI {
|
|
45
|
+
private readonly client;
|
|
46
|
+
constructor(client: PlatformClient);
|
|
47
|
+
list(projectId: string, addonId: string, opts?: {
|
|
48
|
+
bucket?: string;
|
|
49
|
+
prefix?: string;
|
|
50
|
+
}): Promise<unknown>;
|
|
51
|
+
upload(projectId: string, addonId: string, opts: {
|
|
52
|
+
key: string;
|
|
53
|
+
source: Blob | Uint8Array | string;
|
|
54
|
+
bucket?: string;
|
|
55
|
+
contentType?: string;
|
|
56
|
+
}): Promise<{
|
|
57
|
+
key: string;
|
|
58
|
+
etag: string;
|
|
59
|
+
size: number;
|
|
60
|
+
url: string | null;
|
|
61
|
+
}>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
type AddonType = 'postgres' | 'mysql' | 'mongodb' | 'mongo' | 'redis' | 's3';
|
|
65
|
+
interface Addon {
|
|
66
|
+
id: string;
|
|
67
|
+
name: string;
|
|
68
|
+
type: AddonType;
|
|
69
|
+
projectId: string;
|
|
70
|
+
status: 'none' | 'running' | 'crashed' | 'stopped';
|
|
71
|
+
deployStatus: string;
|
|
72
|
+
version?: string;
|
|
73
|
+
/** Exposed connection variables (e.g. DATABASE_URL, REDIS_URL). */
|
|
74
|
+
env?: Record<string, string>;
|
|
75
|
+
}
|
|
76
|
+
interface CreateAddonOpts {
|
|
77
|
+
projectId: string;
|
|
78
|
+
type: AddonType;
|
|
79
|
+
name?: string;
|
|
80
|
+
version?: string;
|
|
81
|
+
region?: string;
|
|
82
|
+
/** vCPU count */
|
|
83
|
+
vcpu?: number;
|
|
84
|
+
/** Memory in MB */
|
|
85
|
+
memoryMb?: number;
|
|
86
|
+
/** Storage in GB */
|
|
87
|
+
storageGb?: number;
|
|
88
|
+
}
|
|
89
|
+
declare class AddonsAPI {
|
|
90
|
+
private readonly client;
|
|
91
|
+
constructor(client: PlatformClient);
|
|
92
|
+
/** List all addons in a project. */
|
|
93
|
+
list(opts: {
|
|
94
|
+
projectId: string;
|
|
95
|
+
}): Promise<Addon[]>;
|
|
96
|
+
/** Get an addon by ID. */
|
|
97
|
+
get(projectId: string, addonId: string): Promise<Addon>;
|
|
98
|
+
/**
|
|
99
|
+
* Create a new managed addon (database, cache, or object store).
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* const pg = await lizard.addons.create({ projectId, type: 'postgres' })
|
|
104
|
+
* // Inject into a service:
|
|
105
|
+
* await lizard.secrets.set({ serviceId: svcId, key: 'DATABASE_URL', value: `${{${pg.name}.DATABASE_URL}}` })
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
create(opts: CreateAddonOpts): Promise<Addon>;
|
|
109
|
+
/** Delete an addon. */
|
|
110
|
+
delete(projectId: string, addonId: string): Promise<void>;
|
|
111
|
+
/** Resize an addon (CPU / memory / storage). */
|
|
112
|
+
resize(projectId: string, addonId: string, opts: {
|
|
113
|
+
vcpu?: number;
|
|
114
|
+
memoryMb?: number;
|
|
115
|
+
storageGb?: number;
|
|
116
|
+
}): Promise<Addon>;
|
|
117
|
+
/** Restart an addon. */
|
|
118
|
+
redeploy(projectId: string, addonId: string): Promise<void>;
|
|
119
|
+
rename(projectId: string, addonId: string, name: string): Promise<unknown>;
|
|
120
|
+
secrets(projectId: string, addonId: string): Promise<Array<{
|
|
121
|
+
key: string;
|
|
122
|
+
value: string;
|
|
123
|
+
}>>;
|
|
124
|
+
logs(projectId: string, addonId: string): Promise<unknown>;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
interface Project {
|
|
128
|
+
id: string;
|
|
129
|
+
name: string;
|
|
130
|
+
slug: string;
|
|
131
|
+
workspaceId: string;
|
|
132
|
+
createdAt?: string;
|
|
133
|
+
}
|
|
134
|
+
interface CreateProjectOpts {
|
|
135
|
+
workspaceId: string;
|
|
136
|
+
name: string;
|
|
137
|
+
}
|
|
138
|
+
declare class ProjectsAPI {
|
|
139
|
+
private readonly client;
|
|
140
|
+
constructor(client: PlatformClient);
|
|
141
|
+
/** List all projects the API key can access. */
|
|
142
|
+
list(opts?: {
|
|
143
|
+
workspaceId?: string;
|
|
144
|
+
}): Promise<Project[]>;
|
|
145
|
+
/** Get a project by ID. */
|
|
146
|
+
get(id: string): Promise<Project>;
|
|
147
|
+
/** Create a new project. */
|
|
148
|
+
create(opts: CreateProjectOpts): Promise<Project>;
|
|
149
|
+
/** Update a project's name. */
|
|
150
|
+
update(id: string, opts: {
|
|
151
|
+
name?: string;
|
|
152
|
+
}): Promise<Project>;
|
|
153
|
+
/** Delete a project. */
|
|
154
|
+
delete(id: string): Promise<void>;
|
|
155
|
+
apply(id: string, config: ProjectConfig): Promise<ConfigResult>;
|
|
156
|
+
services(id: string): Promise<{
|
|
157
|
+
apps: Service[];
|
|
158
|
+
addons: Addon[];
|
|
159
|
+
}>;
|
|
160
|
+
volumeLimits(id: string): Promise<Record<string, unknown>>;
|
|
161
|
+
logs(id: string, opts?: {
|
|
162
|
+
service?: string;
|
|
163
|
+
level?: string;
|
|
164
|
+
limit?: number;
|
|
165
|
+
since?: string;
|
|
166
|
+
until?: string;
|
|
167
|
+
}): Promise<LogLine[]>;
|
|
168
|
+
streamLogs(id: string, signal?: AbortSignal): AsyncGenerator<StreamEvent, any, any>;
|
|
169
|
+
}
|
|
170
|
+
interface ProjectConfig {
|
|
171
|
+
revision?: number;
|
|
172
|
+
services?: Array<ServiceUpdate & {
|
|
173
|
+
id?: string;
|
|
174
|
+
name?: string;
|
|
175
|
+
}>;
|
|
176
|
+
addons?: Array<{
|
|
177
|
+
id?: string;
|
|
178
|
+
name?: string;
|
|
179
|
+
instanceName?: string;
|
|
180
|
+
type?: string;
|
|
181
|
+
limits?: {
|
|
182
|
+
vcpu?: number;
|
|
183
|
+
memoryMb?: number;
|
|
184
|
+
};
|
|
185
|
+
storageSize?: string;
|
|
186
|
+
config?: Record<string, unknown>;
|
|
187
|
+
}>;
|
|
188
|
+
secrets?: {
|
|
189
|
+
shared?: Record<string, string | null>;
|
|
190
|
+
services?: Record<string, Record<string, string | null>>;
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
interface ConfigResult {
|
|
194
|
+
revision: number;
|
|
195
|
+
services: unknown[];
|
|
196
|
+
addons: unknown[];
|
|
197
|
+
sideEffectFailures?: unknown[];
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
interface Service {
|
|
201
|
+
id: string;
|
|
202
|
+
name: string;
|
|
203
|
+
projectId: string;
|
|
204
|
+
status: 'none' | 'running' | 'crashed' | 'stopped';
|
|
205
|
+
deployStatus: 'idle' | 'building' | 'deploying' | 'restarting' | 'failed' | 'deleting';
|
|
206
|
+
domain?: string;
|
|
207
|
+
region?: string;
|
|
208
|
+
sourceType?: 'github' | 'upload' | 'docker';
|
|
209
|
+
repoUrl?: string;
|
|
210
|
+
branch?: string;
|
|
211
|
+
startCommand?: string;
|
|
212
|
+
buildCommand?: string;
|
|
213
|
+
containerPort?: number;
|
|
214
|
+
}
|
|
215
|
+
interface CreateServiceOpts {
|
|
216
|
+
projectId: string;
|
|
217
|
+
name: string;
|
|
218
|
+
sourceType?: 'github' | 'upload' | 'docker';
|
|
219
|
+
repoUrl?: string;
|
|
220
|
+
branch?: string;
|
|
221
|
+
startCommand?: string;
|
|
222
|
+
buildCommand?: string;
|
|
223
|
+
containerPort?: number;
|
|
224
|
+
region?: string;
|
|
225
|
+
preDeployCommand?: string;
|
|
226
|
+
dockerfilePath?: string;
|
|
227
|
+
rootDirectory?: string;
|
|
228
|
+
envVars?: Record<string, string>;
|
|
229
|
+
skipInitialDeploy?: boolean;
|
|
230
|
+
cpuLimit?: string;
|
|
231
|
+
memoryLimit?: string;
|
|
232
|
+
/** Set to 0 for worker mode (no HTTP listener). */
|
|
233
|
+
port?: number;
|
|
234
|
+
}
|
|
235
|
+
interface ScaleOpts {
|
|
236
|
+
replicas?: number;
|
|
237
|
+
cpuMillis?: number;
|
|
238
|
+
memoryMi?: number;
|
|
239
|
+
storageMi?: number;
|
|
240
|
+
}
|
|
241
|
+
interface LogLine {
|
|
242
|
+
level: 'info' | 'error' | 'warn' | 'debug';
|
|
243
|
+
message: string;
|
|
244
|
+
ts: number;
|
|
245
|
+
service?: string;
|
|
246
|
+
replica?: string;
|
|
247
|
+
}
|
|
248
|
+
interface DeployEvent {
|
|
249
|
+
event: 'log' | 'done' | 'error' | 'deployed' | 'failed' | 'deploying';
|
|
250
|
+
line?: string;
|
|
251
|
+
message?: string;
|
|
252
|
+
status?: string;
|
|
253
|
+
url?: string | null;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Handle for a running deploy — stream its logs or await completion.
|
|
257
|
+
*
|
|
258
|
+
* @example
|
|
259
|
+
* ```ts
|
|
260
|
+
* const deploy = await lizard.services.upload({ projectId, source: fs.readFileSync('app.tar.gz') })
|
|
261
|
+
* for await (const line of deploy.logs()) console.log(line)
|
|
262
|
+
* const result = await deploy.wait()
|
|
263
|
+
* console.log('deployed to', result.url)
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
266
|
+
declare class DeployHandle {
|
|
267
|
+
private readonly _serviceId;
|
|
268
|
+
private readonly _buildId;
|
|
269
|
+
private readonly _client;
|
|
270
|
+
constructor(client: PlatformClient, serviceId: string, buildId?: string);
|
|
271
|
+
get serviceId(): string;
|
|
272
|
+
/** Stream build log messages until the server closes the build stream. */
|
|
273
|
+
logs(): AsyncGenerator<string>;
|
|
274
|
+
/**
|
|
275
|
+
* Poll until the deploy reaches a terminal state.
|
|
276
|
+
* @returns `{ url, status }` on success; throws `LizardError` on failure.
|
|
277
|
+
*/
|
|
278
|
+
wait(opts?: {
|
|
279
|
+
timeoutMs?: number;
|
|
280
|
+
pollMs?: number;
|
|
281
|
+
}): Promise<{
|
|
282
|
+
url: string | null;
|
|
283
|
+
status: string;
|
|
284
|
+
}>;
|
|
285
|
+
}
|
|
286
|
+
declare class ServicesAPI {
|
|
287
|
+
private readonly client;
|
|
288
|
+
constructor(client: PlatformClient);
|
|
289
|
+
/** List all services in a project. */
|
|
290
|
+
list(opts: {
|
|
291
|
+
projectId: string;
|
|
292
|
+
}): Promise<Service[]>;
|
|
293
|
+
/** Get a service by ID. */
|
|
294
|
+
get(id: string): Promise<Service>;
|
|
295
|
+
/**
|
|
296
|
+
* Create a service and start a deploy from a git repo.
|
|
297
|
+
* Returns a DeployHandle to track progress.
|
|
298
|
+
*/
|
|
299
|
+
deploy(opts: CreateServiceOpts & {
|
|
300
|
+
waitForDeploy?: boolean;
|
|
301
|
+
}): Promise<DeployHandle>;
|
|
302
|
+
/**
|
|
303
|
+
* Upload a tarball and deploy it.
|
|
304
|
+
*
|
|
305
|
+
* @param opts.source - A `Buffer`, `Blob`, or `Uint8Array` of a `.tar.gz` file.
|
|
306
|
+
*/
|
|
307
|
+
upload(opts: {
|
|
308
|
+
projectId: string;
|
|
309
|
+
name?: string;
|
|
310
|
+
serviceId?: string;
|
|
311
|
+
source: Blob | Uint8Array | string;
|
|
312
|
+
startCommand?: string;
|
|
313
|
+
buildCommand?: string;
|
|
314
|
+
preDeployCommand?: string;
|
|
315
|
+
port?: number;
|
|
316
|
+
region?: string;
|
|
317
|
+
}): Promise<DeployHandle>;
|
|
318
|
+
/** Trigger a redeploy (rebuild from current source). */
|
|
319
|
+
redeploy(id: string): Promise<DeployHandle>;
|
|
320
|
+
/** Restart a service without rebuilding. */
|
|
321
|
+
restart(id: string): Promise<void>;
|
|
322
|
+
/** Scale a service. */
|
|
323
|
+
scale(id: string, opts: ScaleOpts): Promise<void>;
|
|
324
|
+
/**
|
|
325
|
+
* Get recent log lines. For a live tail, use the WebSocket API instead.
|
|
326
|
+
*
|
|
327
|
+
* @param opts.limit - Max lines to return (default 200, max 1000).
|
|
328
|
+
*/
|
|
329
|
+
logs(id: string, opts?: {
|
|
330
|
+
limit?: number;
|
|
331
|
+
since?: string;
|
|
332
|
+
}): Promise<LogLine[]>;
|
|
333
|
+
/** Execute a command; collect SSE output and require an exit event. */
|
|
334
|
+
exec(id: string, cmd: string, opts?: {
|
|
335
|
+
timeoutMs?: number;
|
|
336
|
+
}): Promise<{
|
|
337
|
+
stdout: string;
|
|
338
|
+
stderr: string;
|
|
339
|
+
exitCode: number;
|
|
340
|
+
}>;
|
|
341
|
+
update(id: string, opts: ServiceUpdate, controls?: {
|
|
342
|
+
revision?: number;
|
|
343
|
+
force?: boolean;
|
|
344
|
+
}): Promise<ConfigResult>;
|
|
345
|
+
events(id: string, buildId?: string): Promise<unknown[]>;
|
|
346
|
+
pods(id: string): Promise<{
|
|
347
|
+
pods: unknown[];
|
|
348
|
+
}>;
|
|
349
|
+
history(id: string, opts?: {
|
|
350
|
+
limit?: number;
|
|
351
|
+
before?: string;
|
|
352
|
+
level?: string;
|
|
353
|
+
}): Promise<unknown>;
|
|
354
|
+
streamLogs(id: string, signal?: AbortSignal): AsyncGenerator<StreamEvent, any, any>;
|
|
355
|
+
buildLogs(buildId: string, signal?: AbortSignal): AsyncGenerator<StreamEvent, any, any>;
|
|
356
|
+
/** Delete a service. */
|
|
357
|
+
delete(id: string): Promise<void>;
|
|
358
|
+
}
|
|
359
|
+
interface ServiceUpdate {
|
|
360
|
+
name?: string;
|
|
361
|
+
branch?: string;
|
|
362
|
+
repoUrl?: string;
|
|
363
|
+
sourceType?: 'github' | 'upload' | 'docker';
|
|
364
|
+
buildCommand?: string | null;
|
|
365
|
+
startCommand?: string | null;
|
|
366
|
+
preDeployCommand?: string | null;
|
|
367
|
+
dockerfilePath?: string | null;
|
|
368
|
+
rootDirectory?: string | null;
|
|
369
|
+
watchPatterns?: string[];
|
|
370
|
+
containerPort?: number;
|
|
371
|
+
cpuLimit?: string;
|
|
372
|
+
memoryLimit?: string;
|
|
373
|
+
desiredReplicas?: number;
|
|
374
|
+
context?: string;
|
|
375
|
+
autoDeploy?: boolean;
|
|
376
|
+
vpnEnabled?: boolean;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
declare class GitHubAPI {
|
|
380
|
+
private readonly client;
|
|
381
|
+
constructor(client: PlatformClient);
|
|
382
|
+
status(): Promise<unknown>;
|
|
383
|
+
/** Complete the GitHub App installation in a browser using the caller's account. */
|
|
384
|
+
installUrl(): string;
|
|
385
|
+
checkout(serviceId: string, branch: string): Promise<DeployHandle>;
|
|
386
|
+
}
|
|
387
|
+
|
|
15
388
|
/** A process this sandbox is currently running. */
|
|
16
389
|
interface ProcessInfo {
|
|
17
390
|
pid: number;
|
|
@@ -22,7 +395,7 @@ interface ProcessInfo {
|
|
|
22
395
|
/** Signals accepted by {@link Process.kill}. */
|
|
23
396
|
type ProcessSignal = 'SIGTERM' | 'SIGKILL' | 'SIGINT' | 'SIGHUP' | 'SIGQUIT' | 'SIGUSR1' | 'SIGUSR2';
|
|
24
397
|
/**
|
|
25
|
-
* The result of a process execution inside a Lizard
|
|
398
|
+
* The result of a process execution inside a Lizard sandbox.
|
|
26
399
|
*/
|
|
27
400
|
interface ProcessResult {
|
|
28
401
|
stdout: string;
|
|
@@ -45,7 +418,7 @@ interface ProcessOpts {
|
|
|
45
418
|
onPid?: (pid: number) => void;
|
|
46
419
|
}
|
|
47
420
|
/**
|
|
48
|
-
* Runs processes inside a Lizard sandbox
|
|
421
|
+
* Runs processes inside a Lizard sandbox.
|
|
49
422
|
*
|
|
50
423
|
* Access via `sandbox.process`.
|
|
51
424
|
*/
|
|
@@ -54,12 +427,12 @@ declare class Process {
|
|
|
54
427
|
private readonly config;
|
|
55
428
|
constructor(sandboxId: string, config: ConnectionConfig);
|
|
56
429
|
/**
|
|
57
|
-
* Execute a command inside the
|
|
430
|
+
* Execute a command inside the sandbox and wait for it to complete.
|
|
58
431
|
*
|
|
59
432
|
* The command runs in a shell inside the Lizard sandbox and returns
|
|
60
433
|
* stdout, stderr, and the exit code when it finishes.
|
|
61
434
|
*
|
|
62
|
-
* @param cmd Shell command to run inside the
|
|
435
|
+
* @param cmd Shell command to run inside the sandbox.
|
|
63
436
|
* @param opts Optional execution options — environment variables, working
|
|
64
437
|
* directory, user, and timeout.
|
|
65
438
|
*
|
|
@@ -138,7 +511,7 @@ interface FileInfo {
|
|
|
138
511
|
modTime?: number;
|
|
139
512
|
}
|
|
140
513
|
/**
|
|
141
|
-
* Read and write files inside a Lizard sandbox
|
|
514
|
+
* Read and write files inside a Lizard sandbox.
|
|
142
515
|
*
|
|
143
516
|
* Access via `sandbox.fs`.
|
|
144
517
|
*/
|
|
@@ -147,23 +520,24 @@ declare class Fs {
|
|
|
147
520
|
private readonly config;
|
|
148
521
|
constructor(sandboxId: string, config: ConnectionConfig);
|
|
149
522
|
/**
|
|
150
|
-
* Write a file into the
|
|
523
|
+
* Write a file into the sandbox filesystem.
|
|
151
524
|
*
|
|
152
525
|
* Creates parent directories automatically if they don't exist.
|
|
526
|
+
* Byte input must contain valid UTF-8; arbitrary binary uploads are unsupported.
|
|
153
527
|
*
|
|
154
528
|
* @example
|
|
155
529
|
* ```ts
|
|
156
530
|
* await sandbox.fs.write('/app/index.js', 'console.log("hello")')
|
|
157
531
|
* ```
|
|
158
532
|
*
|
|
159
|
-
* @example Write
|
|
533
|
+
* @example Write UTF-8 bytes:
|
|
160
534
|
* ```ts
|
|
161
|
-
* await sandbox.fs.write('/app/
|
|
535
|
+
* await sandbox.fs.write('/app/notes.txt', new TextEncoder().encode('hello'))
|
|
162
536
|
* ```
|
|
163
537
|
*/
|
|
164
538
|
write(path: string, data: string | Uint8Array, opts?: FsOpts): Promise<void>;
|
|
165
539
|
/**
|
|
166
|
-
* Read a file from the
|
|
540
|
+
* Read a file from the sandbox filesystem.
|
|
167
541
|
*
|
|
168
542
|
* @returns The file contents as a UTF-8 string.
|
|
169
543
|
*
|
|
@@ -173,8 +547,10 @@ declare class Fs {
|
|
|
173
547
|
* ```
|
|
174
548
|
*/
|
|
175
549
|
read(path: string, opts?: FsOpts): Promise<string>;
|
|
550
|
+
/** Read a file as bytes. */
|
|
551
|
+
readBytes(path: string, opts?: FsOpts): Promise<Uint8Array>;
|
|
176
552
|
/**
|
|
177
|
-
* List files and directories at the given path inside the
|
|
553
|
+
* List files and directories at the given path inside the sandbox.
|
|
178
554
|
*
|
|
179
555
|
* @example
|
|
180
556
|
* ```ts
|
|
@@ -183,11 +559,11 @@ declare class Fs {
|
|
|
183
559
|
*/
|
|
184
560
|
list(path: string, opts?: FsOpts): Promise<FileInfo[]>;
|
|
185
561
|
/**
|
|
186
|
-
* Remove a file or directory from the
|
|
562
|
+
* Remove a file or directory from the sandbox filesystem.
|
|
187
563
|
*/
|
|
188
564
|
remove(path: string, opts?: FsOpts): Promise<void>;
|
|
189
565
|
/**
|
|
190
|
-
* Create a directory (and any missing parents) inside the
|
|
566
|
+
* Create a directory (and any missing parents) inside the sandbox.
|
|
191
567
|
*/
|
|
192
568
|
makeDir(path: string, opts?: FsOpts): Promise<void>;
|
|
193
569
|
/**
|
|
@@ -344,7 +720,9 @@ declare class SandboxClient {
|
|
|
344
720
|
protected static killSandbox(sandboxId: string, opts?: ConnectionOpts): Promise<boolean>;
|
|
345
721
|
protected static pauseSandbox(sandboxId: string, opts?: ConnectionOpts): Promise<boolean>;
|
|
346
722
|
protected static resumeSandbox(sandboxId: string, opts?: ConnectionOpts): Promise<boolean>;
|
|
347
|
-
protected static listSandboxes(opts?: ConnectionOpts
|
|
723
|
+
protected static listSandboxes(opts?: ConnectionOpts & {
|
|
724
|
+
projectId?: string;
|
|
725
|
+
}): Promise<SandboxInfo[]>;
|
|
348
726
|
protected static getSandboxInfo(sandboxId: string, opts?: ConnectionOpts): Promise<SandboxInfo>;
|
|
349
727
|
protected static setTimeoutSandbox(sandboxId: string, timeoutMs: number, opts?: ConnectionOpts): Promise<void>;
|
|
350
728
|
protected static exposeSandboxPort(sandboxId: string, port: number, opts?: ConnectionOpts): Promise<{
|
|
@@ -354,10 +732,9 @@ declare class SandboxClient {
|
|
|
354
732
|
}
|
|
355
733
|
|
|
356
734
|
/**
|
|
357
|
-
* A
|
|
735
|
+
* A Linux sandbox running on Kubernetes.
|
|
358
736
|
*
|
|
359
|
-
*
|
|
360
|
-
* process namespace, restored from a pre-warmed template snapshot.
|
|
737
|
+
* Run commands, read and write files, and expose HTTP ports in a sandbox.
|
|
361
738
|
*
|
|
362
739
|
* Sandboxes are **ephemeral**: killing one, or letting it hit its timeout, discards
|
|
363
740
|
* everything written inside it. State that has to outlive a sandbox belongs on a
|
|
@@ -369,10 +746,14 @@ declare class SandboxClient {
|
|
|
369
746
|
* import { Sandbox } from '@lizard-build/sdk'
|
|
370
747
|
*
|
|
371
748
|
* const sandbox = await Sandbox.create('base', { project: 'my-project' })
|
|
372
|
-
*
|
|
373
|
-
*
|
|
374
|
-
*
|
|
375
|
-
*
|
|
749
|
+
* try {
|
|
750
|
+
* await sandbox.fs.write('/tmp/hello.txt', 'hello world')
|
|
751
|
+
* const result = await sandbox.process.exec('cat /tmp/hello.txt')
|
|
752
|
+
* if (result.exitCode !== 0) throw new Error(result.stderr)
|
|
753
|
+
* console.log(result.stdout)
|
|
754
|
+
* } finally {
|
|
755
|
+
* await sandbox.kill()
|
|
756
|
+
* }
|
|
376
757
|
* ```
|
|
377
758
|
*
|
|
378
759
|
* @example Carry work across sandboxes with a volume:
|
|
@@ -393,11 +774,11 @@ declare class Sandbox extends SandboxClient {
|
|
|
393
774
|
protected static readonly defaultTemplate: string;
|
|
394
775
|
protected static readonly defaultTimeoutMs: number;
|
|
395
776
|
/**
|
|
396
|
-
* Unique identifier of this sandbox
|
|
777
|
+
* Unique identifier of this sandbox.
|
|
397
778
|
*/
|
|
398
779
|
readonly sandboxId: string;
|
|
399
780
|
/**
|
|
400
|
-
* Read and write files inside the
|
|
781
|
+
* Read and write files inside the sandbox filesystem.
|
|
401
782
|
*
|
|
402
783
|
* @example
|
|
403
784
|
* ```ts
|
|
@@ -407,7 +788,7 @@ declare class Sandbox extends SandboxClient {
|
|
|
407
788
|
*/
|
|
408
789
|
readonly fs: Fs;
|
|
409
790
|
/**
|
|
410
|
-
* Execute processes inside the
|
|
791
|
+
* Execute processes inside the sandbox.
|
|
411
792
|
*
|
|
412
793
|
* @example
|
|
413
794
|
* ```ts
|
|
@@ -431,16 +812,15 @@ declare class Sandbox extends SandboxClient {
|
|
|
431
812
|
/**
|
|
432
813
|
* Create a new Lizard sandbox from the specified template.
|
|
433
814
|
*
|
|
434
|
-
*
|
|
435
|
-
*
|
|
436
|
-
* `lizard push`.
|
|
815
|
+
* Template availability and installed tools depend on the platform and region.
|
|
816
|
+
* Use `base` for shell commands or `CodeSandbox` for stateful code execution.
|
|
437
817
|
*
|
|
438
818
|
* @param template Name of the sandbox template to boot from.
|
|
439
819
|
*
|
|
440
820
|
* @example
|
|
441
821
|
* ```ts
|
|
442
822
|
* const sandbox = await Sandbox.create('base', { project: 'my-project' })
|
|
443
|
-
* const
|
|
823
|
+
* const pythonSandbox = await Sandbox.create('code-interpreter-v1', { project: 'my-project', timeoutMs: 10 * 60 * 1000 })
|
|
444
824
|
* ```
|
|
445
825
|
*/
|
|
446
826
|
static create(template: string, opts?: SandboxOpts): Promise<Sandbox>;
|
|
@@ -450,11 +830,7 @@ declare class Sandbox extends SandboxClient {
|
|
|
450
830
|
* Verifies the sandbox exists and is reachable, then returns a handle to it.
|
|
451
831
|
* Throws `NotFoundError` if it has been killed or has expired.
|
|
452
832
|
*
|
|
453
|
-
*
|
|
454
|
-
* reconnecting to might be paused. Sandboxes are pods now and pause/resume is a
|
|
455
|
-
* `501` on every one of them, so that call turned every `connect()` into an
|
|
456
|
-
* error against a perfectly healthy sandbox. Connecting does not need to change
|
|
457
|
-
* a sandbox's state, so it no longer tries to.
|
|
833
|
+
* Connecting reads sandbox metadata without changing its state.
|
|
458
834
|
*
|
|
459
835
|
* @example
|
|
460
836
|
* ```ts
|
|
@@ -470,29 +846,27 @@ declare class Sandbox extends SandboxClient {
|
|
|
470
846
|
* const sandboxes = await Sandbox.list()
|
|
471
847
|
* ```
|
|
472
848
|
*/
|
|
473
|
-
static list(opts?: ConnectionOpts
|
|
849
|
+
static list(opts?: ConnectionOpts & {
|
|
850
|
+
projectId?: string;
|
|
851
|
+
}): Promise<SandboxInfo[]>;
|
|
474
852
|
/**
|
|
475
853
|
* Kill the sandbox and release its resources immediately.
|
|
476
854
|
*
|
|
477
|
-
* @returns `true` if the
|
|
855
|
+
* @returns `true` if the sandbox was terminated, `false` if it was already gone.
|
|
478
856
|
*/
|
|
479
857
|
kill(opts?: ConnectionOpts): Promise<boolean>;
|
|
480
858
|
/**
|
|
481
|
-
*
|
|
859
|
+
* Request sandbox pause. The Kubernetes backend returns HTTP 501.
|
|
482
860
|
*
|
|
483
|
-
* @deprecated
|
|
484
|
-
*
|
|
485
|
-
* checkpoint of the pod, which is not built. To park work across a gap, put it on a
|
|
486
|
-
* {@link Volume} and create a fresh sandbox on that volume later; the volume is the
|
|
487
|
-
* part that is meant to outlive a sandbox.
|
|
861
|
+
* @deprecated Unsupported on Kubernetes. Save files to a {@link Volume}
|
|
862
|
+
* and attach it to a new sandbox instead.
|
|
488
863
|
*/
|
|
489
864
|
pause(opts?: ConnectionOpts): Promise<boolean>;
|
|
490
865
|
/**
|
|
491
|
-
*
|
|
866
|
+
* Request sandbox resume. The Kubernetes backend returns HTTP 501.
|
|
492
867
|
*
|
|
493
|
-
* @deprecated
|
|
494
|
-
*
|
|
495
|
-
* calls this, so reconnecting to a running sandbox works without it.
|
|
868
|
+
* @deprecated Unsupported on Kubernetes. Use {@link Sandbox.connect} to
|
|
869
|
+
* reconnect to a running sandbox.
|
|
496
870
|
*/
|
|
497
871
|
resume(opts?: ConnectionOpts): Promise<boolean>;
|
|
498
872
|
/**
|
|
@@ -506,257 +880,38 @@ declare class Sandbox extends SandboxClient {
|
|
|
506
880
|
*/
|
|
507
881
|
setTimeout(timeoutMs: number, opts?: ConnectionOpts): Promise<void>;
|
|
508
882
|
/**
|
|
509
|
-
*
|
|
883
|
+
* Register a public HTTPS route and return its hostname without a scheme.
|
|
510
884
|
*
|
|
511
|
-
* Useful for accessing HTTP servers started inside the
|
|
885
|
+
* Useful for accessing HTTP servers started inside the sandbox from your
|
|
512
886
|
* agent or tests without additional tunneling.
|
|
513
887
|
*
|
|
514
888
|
* @example
|
|
515
889
|
* ```ts
|
|
516
|
-
*
|
|
517
|
-
* const
|
|
518
|
-
*
|
|
890
|
+
* // Start an HTTP server on port 3000 before exposing it.
|
|
891
|
+
* const hostname = await sandbox.getHost(3000)
|
|
892
|
+
* console.log(`https://${hostname}`)
|
|
519
893
|
* ```
|
|
520
894
|
*/
|
|
521
895
|
getHost(port: number, opts?: ConnectionOpts): Promise<string>;
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
/** Shared HTTP helper for platform (non-sandbox) API calls. */
|
|
526
|
-
declare class PlatformClient {
|
|
527
|
-
readonly config: ConnectionConfig;
|
|
528
|
-
constructor(opts: ConnectionOpts);
|
|
529
|
-
get<T>(path: string): Promise<T>;
|
|
530
|
-
post<T>(path: string, body?: unknown): Promise<T>;
|
|
531
|
-
patch<T>(path: string, body: unknown): Promise<T>;
|
|
532
|
-
delete<T = void>(path: string, body?: unknown): Promise<T>;
|
|
533
|
-
postForm<T>(path: string, form: FormData): Promise<T>;
|
|
534
|
-
/** Stream SSE events from a path, calling handler for each data line. */
|
|
535
|
-
streamSse(path: string): AsyncGenerator<string>;
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
interface Project {
|
|
539
|
-
id: string;
|
|
540
|
-
name: string;
|
|
541
|
-
slug: string;
|
|
542
|
-
workspaceId: string;
|
|
543
|
-
createdAt?: string;
|
|
544
|
-
}
|
|
545
|
-
interface CreateProjectOpts {
|
|
546
|
-
workspaceId: string;
|
|
547
|
-
name: string;
|
|
548
|
-
}
|
|
549
|
-
declare class ProjectsAPI {
|
|
550
|
-
private readonly client;
|
|
551
|
-
constructor(client: PlatformClient);
|
|
552
|
-
/** List all projects the API key can access. */
|
|
553
|
-
list(opts?: {
|
|
554
|
-
workspaceId?: string;
|
|
555
|
-
}): Promise<Project[]>;
|
|
556
|
-
/** Get a project by ID. */
|
|
557
|
-
get(id: string): Promise<Project>;
|
|
558
|
-
/** Create a new project. */
|
|
559
|
-
create(opts: CreateProjectOpts): Promise<Project>;
|
|
560
|
-
/** Update a project's name. */
|
|
561
|
-
update(id: string, opts: {
|
|
562
|
-
name?: string;
|
|
563
|
-
}): Promise<Project>;
|
|
564
|
-
/** Delete a project. */
|
|
565
|
-
delete(id: string): Promise<void>;
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
interface Service {
|
|
569
|
-
id: string;
|
|
570
|
-
name: string;
|
|
571
|
-
projectId: string;
|
|
572
|
-
status: 'none' | 'running' | 'crashed' | 'stopped';
|
|
573
|
-
deployStatus: 'idle' | 'building' | 'deploying' | 'restarting' | 'failed' | 'deleting';
|
|
574
|
-
domain?: string;
|
|
575
|
-
region?: string;
|
|
576
|
-
sourceType?: 'github' | 'upload';
|
|
577
|
-
repoUrl?: string;
|
|
578
|
-
branch?: string;
|
|
579
|
-
startCommand?: string;
|
|
580
|
-
buildCommand?: string;
|
|
581
|
-
containerPort?: number;
|
|
582
|
-
}
|
|
583
|
-
interface CreateServiceOpts {
|
|
584
|
-
projectId: string;
|
|
585
|
-
name: string;
|
|
586
|
-
sourceType?: 'github' | 'upload';
|
|
587
|
-
repoUrl?: string;
|
|
588
|
-
branch?: string;
|
|
589
|
-
startCommand?: string;
|
|
590
|
-
buildCommand?: string;
|
|
591
|
-
containerPort?: number;
|
|
592
|
-
region?: string;
|
|
593
|
-
/** Set to 0 for worker mode (no HTTP listener). */
|
|
594
|
-
port?: number;
|
|
595
|
-
}
|
|
596
|
-
interface ScaleOpts {
|
|
597
|
-
replicas?: number;
|
|
598
|
-
cpuMillis?: number;
|
|
599
|
-
memoryMi?: number;
|
|
600
|
-
storageMi?: number;
|
|
601
|
-
}
|
|
602
|
-
interface LogLine {
|
|
603
|
-
level: 'info' | 'error' | 'warn' | 'debug';
|
|
604
|
-
message: string;
|
|
605
|
-
ts: number;
|
|
606
|
-
service?: string;
|
|
607
|
-
replica?: string;
|
|
608
|
-
}
|
|
609
|
-
interface DeployEvent {
|
|
610
|
-
event: 'log' | 'done' | 'error' | 'deployed' | 'failed' | 'deploying';
|
|
611
|
-
line?: string;
|
|
612
|
-
message?: string;
|
|
613
|
-
status?: string;
|
|
614
|
-
url?: string | null;
|
|
615
|
-
}
|
|
616
|
-
/**
|
|
617
|
-
* Handle for a running deploy — stream its logs or await completion.
|
|
618
|
-
*
|
|
619
|
-
* @example
|
|
620
|
-
* ```ts
|
|
621
|
-
* const deploy = await lizard.services.upload({ projectId, source: fs.readFileSync('app.tar.gz') })
|
|
622
|
-
* for await (const line of deploy.logs()) console.log(line)
|
|
623
|
-
* const result = await deploy.wait()
|
|
624
|
-
* console.log('deployed to', result.url)
|
|
625
|
-
* ```
|
|
626
|
-
*/
|
|
627
|
-
declare class DeployHandle {
|
|
628
|
-
private readonly _serviceId;
|
|
629
|
-
private readonly _buildId;
|
|
630
|
-
private readonly _client;
|
|
631
|
-
constructor(client: PlatformClient, serviceId: string, buildId?: string);
|
|
632
|
-
get serviceId(): string;
|
|
633
|
-
/** Stream build + runtime log lines until the deploy finishes. */
|
|
634
|
-
logs(): AsyncGenerator<string>;
|
|
635
|
-
/**
|
|
636
|
-
* Poll until the deploy reaches a terminal state.
|
|
637
|
-
* @returns `{ url, status }` on success; throws `LizardError` on failure.
|
|
638
|
-
*/
|
|
639
|
-
wait(opts?: {
|
|
896
|
+
/** Fork is unsupported on Kubernetes; the backend returns HTTP 501. */
|
|
897
|
+
fork(opts?: {
|
|
898
|
+
count?: number;
|
|
640
899
|
timeoutMs?: number;
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
/**
|
|
651
|
-
|
|
652
|
-
projectId: string;
|
|
653
|
-
}): Promise<Service[]>;
|
|
654
|
-
/** Get a service by ID. */
|
|
655
|
-
get(id: string): Promise<Service>;
|
|
656
|
-
/**
|
|
657
|
-
* Create a service and start a deploy from a git repo.
|
|
658
|
-
* Returns a DeployHandle to track progress.
|
|
659
|
-
*/
|
|
660
|
-
deploy(opts: CreateServiceOpts & {
|
|
661
|
-
waitForDeploy?: boolean;
|
|
662
|
-
}): Promise<DeployHandle>;
|
|
663
|
-
/**
|
|
664
|
-
* Upload a tarball and deploy it.
|
|
665
|
-
*
|
|
666
|
-
* @param opts.source - A `Buffer`, `Blob`, or `Uint8Array` of a `.tar.gz` file.
|
|
667
|
-
*/
|
|
668
|
-
upload(opts: {
|
|
669
|
-
projectId: string;
|
|
670
|
-
name: string;
|
|
671
|
-
source: Blob | string;
|
|
672
|
-
startCommand?: string;
|
|
673
|
-
buildCommand?: string;
|
|
674
|
-
port?: number;
|
|
675
|
-
region?: string;
|
|
676
|
-
}): Promise<DeployHandle>;
|
|
677
|
-
/** Trigger a redeploy (rebuild from current source). */
|
|
678
|
-
redeploy(id: string): Promise<DeployHandle>;
|
|
679
|
-
/** Restart a service without rebuilding. */
|
|
680
|
-
restart(id: string): Promise<void>;
|
|
681
|
-
/** Scale a service. */
|
|
682
|
-
scale(id: string, opts: ScaleOpts): Promise<void>;
|
|
683
|
-
/**
|
|
684
|
-
* Get recent log lines. For a live tail, use the WebSocket API instead.
|
|
685
|
-
*
|
|
686
|
-
* @param opts.limit - Max lines to return (default 200, max 1000).
|
|
687
|
-
*/
|
|
688
|
-
logs(id: string, opts?: {
|
|
689
|
-
limit?: number;
|
|
690
|
-
since?: string;
|
|
691
|
-
}): Promise<LogLine[]>;
|
|
692
|
-
/** Execute a command inside the running service container. */
|
|
693
|
-
exec(id: string, cmd: string, opts?: {
|
|
900
|
+
}): Promise<unknown>;
|
|
901
|
+
/** Snapshot creation is unsupported on Kubernetes; the backend returns HTTP 501. */
|
|
902
|
+
snapshot(name?: string): Promise<unknown>;
|
|
903
|
+
unexpose(port: number): Promise<void>;
|
|
904
|
+
logs(opts?: {
|
|
905
|
+
tail?: number;
|
|
906
|
+
signal?: AbortSignal;
|
|
907
|
+
}): AsyncGenerator<StreamEvent, any, any>;
|
|
908
|
+
static snapshots(projectId: string, opts?: ConnectionOpts): Promise<unknown[]>;
|
|
909
|
+
/** Snapshot restore is unsupported on Kubernetes; the backend returns HTTP 501. */
|
|
910
|
+
static restore(snapshotId: string, opts?: ConnectionOpts & {
|
|
694
911
|
timeoutMs?: number;
|
|
695
|
-
}): Promise<
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
exitCode: number;
|
|
699
|
-
}>;
|
|
700
|
-
/** Update service configuration. */
|
|
701
|
-
update(id: string, opts: Partial<Pick<Service, 'name' | 'startCommand' | 'buildCommand' | 'containerPort' | 'repoUrl' | 'branch' | 'sourceType'>>): Promise<Service>;
|
|
702
|
-
/** Delete a service. */
|
|
703
|
-
delete(id: string): Promise<void>;
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
type AddonType = 'postgres' | 'mysql' | 'mongodb' | 'redis' | 's3';
|
|
707
|
-
interface Addon {
|
|
708
|
-
id: string;
|
|
709
|
-
name: string;
|
|
710
|
-
type: AddonType;
|
|
711
|
-
projectId: string;
|
|
712
|
-
status: 'none' | 'running' | 'crashed' | 'stopped';
|
|
713
|
-
deployStatus: string;
|
|
714
|
-
version?: string;
|
|
715
|
-
/** Exposed connection variables (e.g. DATABASE_URL, REDIS_URL). */
|
|
716
|
-
env?: Record<string, string>;
|
|
717
|
-
}
|
|
718
|
-
interface CreateAddonOpts {
|
|
719
|
-
projectId: string;
|
|
720
|
-
type: AddonType;
|
|
721
|
-
name?: string;
|
|
722
|
-
version?: string;
|
|
723
|
-
/** vCPU count */
|
|
724
|
-
vcpu?: number;
|
|
725
|
-
/** Memory in MB */
|
|
726
|
-
memoryMb?: number;
|
|
727
|
-
/** Storage in GB */
|
|
728
|
-
storageGb?: number;
|
|
729
|
-
}
|
|
730
|
-
declare class AddonsAPI {
|
|
731
|
-
private readonly client;
|
|
732
|
-
constructor(client: PlatformClient);
|
|
733
|
-
/** List all addons in a project. */
|
|
734
|
-
list(opts: {
|
|
735
|
-
projectId: string;
|
|
736
|
-
}): Promise<Addon[]>;
|
|
737
|
-
/** Get an addon by ID. */
|
|
738
|
-
get(projectId: string, addonId: string): Promise<Addon>;
|
|
739
|
-
/**
|
|
740
|
-
* Create a new managed addon (database, cache, or object store).
|
|
741
|
-
*
|
|
742
|
-
* @example
|
|
743
|
-
* ```ts
|
|
744
|
-
* const pg = await lizard.addons.create({ projectId, type: 'postgres' })
|
|
745
|
-
* // Inject into a service:
|
|
746
|
-
* await lizard.secrets.set({ serviceId: svcId, key: 'DATABASE_URL', value: `${{${pg.name}.DATABASE_URL}}` })
|
|
747
|
-
* ```
|
|
748
|
-
*/
|
|
749
|
-
create(opts: CreateAddonOpts): Promise<Addon>;
|
|
750
|
-
/** Delete an addon. */
|
|
751
|
-
delete(projectId: string, addonId: string): Promise<void>;
|
|
752
|
-
/** Resize an addon (CPU / memory / storage). */
|
|
753
|
-
resize(projectId: string, addonId: string, opts: {
|
|
754
|
-
vcpu?: number;
|
|
755
|
-
memoryMb?: number;
|
|
756
|
-
storageGb?: number;
|
|
757
|
-
}): Promise<Addon>;
|
|
758
|
-
/** Restart an addon VM. */
|
|
759
|
-
redeploy(projectId: string, addonId: string): Promise<void>;
|
|
912
|
+
}): Promise<Sandbox>;
|
|
913
|
+
static deleteSnapshot(snapshotId: string, opts?: ConnectionOpts): Promise<void>;
|
|
914
|
+
private resolveOpts;
|
|
760
915
|
}
|
|
761
916
|
|
|
762
917
|
interface Secret {
|
|
@@ -796,17 +951,21 @@ declare class SecretsAPI {
|
|
|
796
951
|
* ```
|
|
797
952
|
*/
|
|
798
953
|
set(projectId: string, secrets: SetSecretOpts | SetSecretOpts[]): Promise<void>;
|
|
799
|
-
/** Delete a secret by key. */
|
|
800
954
|
delete(projectId: string, opts: {
|
|
801
955
|
key: string;
|
|
802
956
|
serviceId?: string;
|
|
803
957
|
}): Promise<void>;
|
|
958
|
+
refs(projectId: string, serviceId?: string): Promise<unknown>;
|
|
804
959
|
}
|
|
805
960
|
|
|
806
961
|
interface DomainInfo {
|
|
807
962
|
domain: string;
|
|
808
963
|
/** 'pending' until DNS propagates and the platform verifies the CNAME/TXT record. */
|
|
809
964
|
verified: boolean;
|
|
965
|
+
hostname?: string;
|
|
966
|
+
txtValue?: string;
|
|
967
|
+
live?: boolean;
|
|
968
|
+
generated?: boolean;
|
|
810
969
|
txtRecord?: string;
|
|
811
970
|
cnameTarget?: string;
|
|
812
971
|
}
|
|
@@ -818,6 +977,7 @@ declare class DomainsAPI {
|
|
|
818
977
|
* The platform-assigned `.onlizard.com` subdomain is always present.
|
|
819
978
|
*/
|
|
820
979
|
list(serviceId: string): Promise<DomainInfo[]>;
|
|
980
|
+
info(serviceId: string): Promise<DomainStatus>;
|
|
821
981
|
/**
|
|
822
982
|
* Attach a custom domain to a service.
|
|
823
983
|
* Returns the DNS records to add before calling `verify()`.
|
|
@@ -828,12 +988,32 @@ declare class DomainsAPI {
|
|
|
828
988
|
* console.log('Add CNAME:', info.cnameTarget)
|
|
829
989
|
* ```
|
|
830
990
|
*/
|
|
831
|
-
add(serviceId: string, domain: string
|
|
991
|
+
add(serviceId: string, domain: string, opts?: {
|
|
992
|
+
force?: boolean;
|
|
993
|
+
}): Promise<DomainInfo>;
|
|
832
994
|
/**
|
|
833
995
|
* Verify that DNS records have propagated and activate the domain.
|
|
834
996
|
* Call after adding the CNAME or TXT record returned by `add()`.
|
|
835
997
|
*/
|
|
836
998
|
verify(serviceId: string, domain: string): Promise<DomainInfo>;
|
|
999
|
+
generate(serviceId: string): Promise<{
|
|
1000
|
+
hostname: string;
|
|
1001
|
+
generated: boolean;
|
|
1002
|
+
}>;
|
|
1003
|
+
delete(serviceId: string, hostname: string): Promise<void>;
|
|
1004
|
+
}
|
|
1005
|
+
interface DomainStatus {
|
|
1006
|
+
domain: string | null;
|
|
1007
|
+
domains: string[];
|
|
1008
|
+
generatedDomain: string | null;
|
|
1009
|
+
cnameTarget: string;
|
|
1010
|
+
dnsOk: Record<string, boolean>;
|
|
1011
|
+
pending: Array<{
|
|
1012
|
+
hostname: string;
|
|
1013
|
+
txtRecord: string;
|
|
1014
|
+
txtValue: string;
|
|
1015
|
+
cnameTarget: string;
|
|
1016
|
+
}>;
|
|
837
1017
|
}
|
|
838
1018
|
|
|
839
1019
|
type MetricRange = '1h' | '6h' | '24h' | '7d' | '14d' | '30d';
|
|
@@ -856,32 +1036,44 @@ interface CostMetrics {
|
|
|
856
1036
|
total: number;
|
|
857
1037
|
currency: string;
|
|
858
1038
|
}
|
|
1039
|
+
interface RawMetrics {
|
|
1040
|
+
timestamps: number[];
|
|
1041
|
+
series: Array<{
|
|
1042
|
+
metric: string;
|
|
1043
|
+
values: number[];
|
|
1044
|
+
available?: boolean[];
|
|
1045
|
+
}>;
|
|
1046
|
+
latest?: Record<string, unknown>;
|
|
1047
|
+
limits?: Record<string, number>;
|
|
1048
|
+
}
|
|
1049
|
+
interface ProjectCost {
|
|
1050
|
+
projectId: string;
|
|
1051
|
+
costUsd: number;
|
|
1052
|
+
[key: string]: unknown;
|
|
1053
|
+
}
|
|
859
1054
|
declare class MetricsAPI {
|
|
860
1055
|
private readonly client;
|
|
861
1056
|
constructor(client: PlatformClient);
|
|
862
|
-
|
|
1057
|
+
service(id: string, range?: MetricRange): Promise<RawMetrics>;
|
|
1058
|
+
addon(projectId: string, addonId: string, range?: MetricRange): Promise<RawMetrics>;
|
|
1059
|
+
project(id: string, opts?: {
|
|
1060
|
+
range?: MetricRange;
|
|
1061
|
+
live?: boolean;
|
|
1062
|
+
}): Promise<unknown>;
|
|
1063
|
+
private points;
|
|
863
1064
|
cpu(id: string, range?: MetricRange): Promise<MetricPoint[]>;
|
|
864
|
-
/** Get memory metrics for a service or addon. */
|
|
865
1065
|
memory(id: string, range?: MetricRange): Promise<MetricPoint[]>;
|
|
866
|
-
/** Get network I/O metrics for a service. */
|
|
867
1066
|
network(id: string, range?: MetricRange): Promise<{
|
|
868
1067
|
rx: MetricPoint[];
|
|
869
1068
|
tx: MetricPoint[];
|
|
870
1069
|
}>;
|
|
871
|
-
/** Get disk I/O metrics for a service. */
|
|
872
1070
|
disk(id: string, range?: MetricRange): Promise<{
|
|
873
1071
|
read: MetricPoint[];
|
|
874
1072
|
write: MetricPoint[];
|
|
875
1073
|
}>;
|
|
876
|
-
/**
|
|
877
|
-
* Get cost breakdown for a project over the given range.
|
|
878
|
-
* Costs are in USD cents unless the `currency` field says otherwise.
|
|
879
|
-
*/
|
|
880
|
-
cost(projectId: string, range?: MetricRange): Promise<CostMetrics>;
|
|
881
|
-
/**
|
|
882
|
-
* Convenience: fetch all metric types for a service in one call.
|
|
883
|
-
*/
|
|
884
1074
|
all(id: string, range?: MetricRange): Promise<ServiceMetrics>;
|
|
1075
|
+
/** Return the backend's project cost row in USD, without guessing missing totals. */
|
|
1076
|
+
cost(projectId: string, range?: MetricRange): Promise<ProjectCost | null>;
|
|
885
1077
|
}
|
|
886
1078
|
|
|
887
1079
|
interface Workspace {
|
|
@@ -1116,6 +1308,37 @@ declare class BillingAPI {
|
|
|
1116
1308
|
summary(): Promise<unknown>;
|
|
1117
1309
|
/** Live (not-yet-invoiced) usage accumulating right now. */
|
|
1118
1310
|
live(): Promise<unknown>;
|
|
1311
|
+
paymentMethods(): Promise<{
|
|
1312
|
+
items: unknown[];
|
|
1313
|
+
}>;
|
|
1314
|
+
setupPaymentMethod(returnUrl?: string): Promise<{
|
|
1315
|
+
url: string;
|
|
1316
|
+
}>;
|
|
1317
|
+
removePaymentMethod(id: string): Promise<void>;
|
|
1318
|
+
purchase(creditCents: number, opts?: {
|
|
1319
|
+
paymentMethod?: 'card' | 'crypto';
|
|
1320
|
+
returnUrl?: string;
|
|
1321
|
+
}): Promise<{
|
|
1322
|
+
url: string;
|
|
1323
|
+
sessionId?: string;
|
|
1324
|
+
}>;
|
|
1325
|
+
autoTopup(): Promise<unknown>;
|
|
1326
|
+
setAutoTopup(opts: {
|
|
1327
|
+
enabled: boolean;
|
|
1328
|
+
thresholdCents: number;
|
|
1329
|
+
amountCents: number;
|
|
1330
|
+
paymentMethodIds: string[];
|
|
1331
|
+
}): Promise<unknown>;
|
|
1332
|
+
runAutoTopup(): Promise<unknown>;
|
|
1333
|
+
redeemPromo(code: string): Promise<unknown>;
|
|
1334
|
+
x402Quote(creditCents: number): Promise<unknown>;
|
|
1335
|
+
paymentStatus(attemptId: string): Promise<unknown>;
|
|
1336
|
+
/** Pay with the CLI's durable x402 journal. Requires CLI >= 4.0.8. Amounts are cents. */
|
|
1337
|
+
payX402(creditCents: number, opts: {
|
|
1338
|
+
maxTotalCents: number;
|
|
1339
|
+
requestId?: string;
|
|
1340
|
+
executable?: string;
|
|
1341
|
+
}): Promise<unknown>;
|
|
1119
1342
|
}
|
|
1120
1343
|
|
|
1121
1344
|
interface VolumeInfo {
|
|
@@ -1250,6 +1473,8 @@ declare class Lizard {
|
|
|
1250
1473
|
readonly domains: DomainsAPI;
|
|
1251
1474
|
/** Query CPU, memory, network, disk, and cost metrics. */
|
|
1252
1475
|
readonly metrics: MetricsAPI;
|
|
1476
|
+
readonly storage: StorageAPI;
|
|
1477
|
+
readonly github: GitHubAPI;
|
|
1253
1478
|
constructor(opts: LizardOpts);
|
|
1254
1479
|
/** Resolve the client's project reference to a stable project ID (cached). */
|
|
1255
1480
|
projectId(): Promise<string>;
|
|
@@ -1325,7 +1550,7 @@ interface Account {
|
|
|
1325
1550
|
|
|
1326
1551
|
/**
|
|
1327
1552
|
* Resolve a project reference — its ID, slug, or name — to the stable project
|
|
1328
|
-
* ID the API bills against.
|
|
1553
|
+
* ID the API bills against. Only resources visible to this credential are used.
|
|
1329
1554
|
*
|
|
1330
1555
|
* @throws {LizardError} when the reference matches no project the key can see.
|
|
1331
1556
|
*/
|
|
@@ -1334,6 +1559,11 @@ declare function resolveProjectId(ref: string, config: ConnectionConfig): Promis
|
|
|
1334
1559
|
declare class LizardError extends Error {
|
|
1335
1560
|
constructor(message: string);
|
|
1336
1561
|
}
|
|
1562
|
+
/** Config was saved, but one or more deploy/restart actions failed. Never retry blindly. */
|
|
1563
|
+
declare class ConfigApplyError extends LizardError {
|
|
1564
|
+
readonly result: unknown;
|
|
1565
|
+
constructor(result: unknown);
|
|
1566
|
+
}
|
|
1337
1567
|
declare class AuthenticationError extends LizardError {
|
|
1338
1568
|
constructor(message?: string);
|
|
1339
1569
|
}
|
|
@@ -1371,7 +1601,7 @@ type OutputItem = {
|
|
|
1371
1601
|
message: string;
|
|
1372
1602
|
traceback: string;
|
|
1373
1603
|
};
|
|
1374
|
-
/** Error
|
|
1604
|
+
/** Error returned in Execution.error when executed code raises an exception. */
|
|
1375
1605
|
declare class ExecutionError extends Error {
|
|
1376
1606
|
readonly name: string;
|
|
1377
1607
|
readonly traceback: string;
|
|
@@ -1406,7 +1636,7 @@ interface RunCodeOpts {
|
|
|
1406
1636
|
context?: CodeContext;
|
|
1407
1637
|
/** Extra environment variables available to the code. */
|
|
1408
1638
|
envs?: Record<string, string>;
|
|
1409
|
-
/**
|
|
1639
|
+
/** Client timeout in milliseconds. No client timer is set when omitted. */
|
|
1410
1640
|
timeoutMs?: number;
|
|
1411
1641
|
onStdout?: (data: string) => void;
|
|
1412
1642
|
onStderr?: (data: string) => void;
|
|
@@ -1428,7 +1658,7 @@ interface CreateContextOpts {
|
|
|
1428
1658
|
*
|
|
1429
1659
|
* @example
|
|
1430
1660
|
* ```ts
|
|
1431
|
-
* import { CodeSandbox } from 'lizard/
|
|
1661
|
+
* import { CodeSandbox } from '@lizard-build/sdk'
|
|
1432
1662
|
*
|
|
1433
1663
|
* const sandbox = await CodeSandbox.create({ project: 'my-project' })
|
|
1434
1664
|
*
|
|
@@ -1459,8 +1689,7 @@ declare class CodeSandbox extends Sandbox {
|
|
|
1459
1689
|
*
|
|
1460
1690
|
* @returns Execution result with stdout, stderr, results, and any error.
|
|
1461
1691
|
*
|
|
1462
|
-
*
|
|
1463
|
-
* default context exists — which cannot happen in normal usage.
|
|
1692
|
+
* Code errors appear in `execution.error`; request failures throw.
|
|
1464
1693
|
*
|
|
1465
1694
|
* @example
|
|
1466
1695
|
* ```ts
|
|
@@ -1503,4 +1732,28 @@ declare class CodeSandbox extends Sandbox {
|
|
|
1503
1732
|
static connect(sandboxId: string, opts?: ConnectionOpts): Promise<CodeSandbox>;
|
|
1504
1733
|
}
|
|
1505
1734
|
|
|
1506
|
-
|
|
1735
|
+
interface CLIResult {
|
|
1736
|
+
code: number;
|
|
1737
|
+
stdout: string;
|
|
1738
|
+
stderr: string;
|
|
1739
|
+
events: unknown[];
|
|
1740
|
+
}
|
|
1741
|
+
interface CLIOptions extends ConnectionOpts {
|
|
1742
|
+
executable?: string;
|
|
1743
|
+
cwd?: string;
|
|
1744
|
+
timeoutMs?: number;
|
|
1745
|
+
}
|
|
1746
|
+
/** Optional adapter for local CLI workflows. Requires the Lizard CLI on PATH.
|
|
1747
|
+
* Arguments are passed directly, without a shell. It does not add --yes, retry
|
|
1748
|
+
* payments. Authentication follows the CLI configuration.
|
|
1749
|
+
*/
|
|
1750
|
+
declare class LizardCLI {
|
|
1751
|
+
private readonly opts;
|
|
1752
|
+
constructor(opts?: CLIOptions);
|
|
1753
|
+
run(args: readonly string[], opts?: {
|
|
1754
|
+
stdin?: string;
|
|
1755
|
+
signal?: AbortSignal;
|
|
1756
|
+
}): Promise<CLIResult>;
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
export { type Account, type Addon, type AddonType, AddonsAPI, type ApiKey, type ApiKeyScope, ApiKeysAPI, AuthenticationError, type Balance, BillingAPI, type CLIOptions, type CLIResult, type CodeContext, CodeSandbox, ConfigApplyError, type ConfigResult, ConflictError, type ConnectionOpts, type CostMetrics, type CreateAddonOpts, type CreateApiKeyOpts, type CreateContextOpts, type CreateProjectOpts, type CreateServiceOpts, type CreateVolumeOpts, type CreateWorkspaceOpts, type CreatedApiKey, type DeployEvent, DeployHandle, type DomainInfo, type DomainStatus, DomainsAPI, Execution, ExecutionError, type FileInfo, type FsOpts, GitHubAPI, type ListTransactionsOpts, Lizard, LizardCLI, LizardError, type LizardOpts, type LogLine, type MetricPoint, type MetricRange, MetricsAPI, NotFoundError, PlatformClient, type ProcessOpts, type ProcessResult, type Project, type ProjectConfig, type ProjectCost, ProjectsAPI, type RawMetrics, type Region, RegionsAPI, type RunCodeLanguage, type RunCodeOpts, Sandbox, type SandboxInfo, type SandboxOpts, type ScaleOpts, type Secret, SecretsAPI, type Service, type ServiceMetrics, type ServiceUpdate, ServicesAPI, type SetSecretOpts, StorageAPI, type StreamEvent, TimeoutError, type Transaction, type TransactionPage, Volume, type VolumeInfo, type Workspace, WorkspacesAPI, resolveProjectId };
|