@lizard-build/sdk 0.1.39 → 0.1.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.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 VM. */
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;
@@ -181,6 +554,7 @@ declare class Fs {
181
554
  * const entries = await sandbox.fs.list('/app')
182
555
  * ```
183
556
  */
557
+ readBytes(path: string, opts?: FsOpts): Promise<Uint8Array>;
184
558
  list(path: string, opts?: FsOpts): Promise<FileInfo[]>;
185
559
  /**
186
560
  * Remove a file or directory from the microVM filesystem.
@@ -344,7 +718,9 @@ declare class SandboxClient {
344
718
  protected static killSandbox(sandboxId: string, opts?: ConnectionOpts): Promise<boolean>;
345
719
  protected static pauseSandbox(sandboxId: string, opts?: ConnectionOpts): Promise<boolean>;
346
720
  protected static resumeSandbox(sandboxId: string, opts?: ConnectionOpts): Promise<boolean>;
347
- protected static listSandboxes(opts?: ConnectionOpts): Promise<SandboxInfo[]>;
721
+ protected static listSandboxes(opts?: ConnectionOpts & {
722
+ projectId?: string;
723
+ }): Promise<SandboxInfo[]>;
348
724
  protected static getSandboxInfo(sandboxId: string, opts?: ConnectionOpts): Promise<SandboxInfo>;
349
725
  protected static setTimeoutSandbox(sandboxId: string, timeoutMs: number, opts?: ConnectionOpts): Promise<void>;
350
726
  protected static exposeSandboxPort(sandboxId: string, port: number, opts?: ConnectionOpts): Promise<{
@@ -470,7 +846,9 @@ declare class Sandbox extends SandboxClient {
470
846
  * const sandboxes = await Sandbox.list()
471
847
  * ```
472
848
  */
473
- static list(opts?: ConnectionOpts): Promise<SandboxInfo[]>;
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
  *
@@ -519,244 +897,22 @@ declare class Sandbox extends SandboxClient {
519
897
  * ```
520
898
  */
521
899
  getHost(port: number, opts?: ConnectionOpts): Promise<string>;
522
- private resolveOpts;
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?: {
900
+ fork(opts?: {
901
+ count?: number;
640
902
  timeoutMs?: number;
641
- pollMs?: number;
642
- }): Promise<{
643
- url: string | null;
644
- status: string;
645
- }>;
646
- }
647
- declare class ServicesAPI {
648
- private readonly client;
649
- constructor(client: PlatformClient);
650
- /** List all services in a project. */
651
- list(opts: {
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?: {
903
+ }): Promise<unknown>;
904
+ snapshot(name?: string): Promise<unknown>;
905
+ unexpose(port: number): Promise<void>;
906
+ logs(opts?: {
907
+ tail?: number;
908
+ signal?: AbortSignal;
909
+ }): AsyncGenerator<StreamEvent, any, any>;
910
+ static snapshots(projectId: string, opts?: ConnectionOpts): Promise<unknown[]>;
911
+ static restore(snapshotId: string, opts?: ConnectionOpts & {
694
912
  timeoutMs?: number;
695
- }): Promise<{
696
- stdout: string;
697
- stderr: string;
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>;
913
+ }): Promise<Sandbox>;
914
+ static deleteSnapshot(snapshotId: string, opts?: ConnectionOpts): Promise<void>;
915
+ private resolveOpts;
760
916
  }
761
917
 
762
918
  interface Secret {
@@ -796,17 +952,21 @@ declare class SecretsAPI {
796
952
  * ```
797
953
  */
798
954
  set(projectId: string, secrets: SetSecretOpts | SetSecretOpts[]): Promise<void>;
799
- /** Delete a secret by key. */
800
955
  delete(projectId: string, opts: {
801
956
  key: string;
802
957
  serviceId?: string;
803
958
  }): Promise<void>;
959
+ refs(projectId: string, serviceId?: string): Promise<unknown>;
804
960
  }
805
961
 
806
962
  interface DomainInfo {
807
963
  domain: string;
808
964
  /** 'pending' until DNS propagates and the platform verifies the CNAME/TXT record. */
809
965
  verified: boolean;
966
+ hostname?: string;
967
+ txtValue?: string;
968
+ live?: boolean;
969
+ generated?: boolean;
810
970
  txtRecord?: string;
811
971
  cnameTarget?: string;
812
972
  }
@@ -818,6 +978,7 @@ declare class DomainsAPI {
818
978
  * The platform-assigned `.onlizard.com` subdomain is always present.
819
979
  */
820
980
  list(serviceId: string): Promise<DomainInfo[]>;
981
+ info(serviceId: string): Promise<DomainStatus>;
821
982
  /**
822
983
  * Attach a custom domain to a service.
823
984
  * Returns the DNS records to add before calling `verify()`.
@@ -828,12 +989,32 @@ declare class DomainsAPI {
828
989
  * console.log('Add CNAME:', info.cnameTarget)
829
990
  * ```
830
991
  */
831
- add(serviceId: string, domain: string): Promise<DomainInfo>;
992
+ add(serviceId: string, domain: string, opts?: {
993
+ force?: boolean;
994
+ }): Promise<DomainInfo>;
832
995
  /**
833
996
  * Verify that DNS records have propagated and activate the domain.
834
997
  * Call after adding the CNAME or TXT record returned by `add()`.
835
998
  */
836
999
  verify(serviceId: string, domain: string): Promise<DomainInfo>;
1000
+ generate(serviceId: string): Promise<{
1001
+ hostname: string;
1002
+ generated: boolean;
1003
+ }>;
1004
+ delete(serviceId: string, hostname: string): Promise<void>;
1005
+ }
1006
+ interface DomainStatus {
1007
+ domain: string | null;
1008
+ domains: string[];
1009
+ generatedDomain: string | null;
1010
+ cnameTarget: string;
1011
+ dnsOk: Record<string, boolean>;
1012
+ pending: Array<{
1013
+ hostname: string;
1014
+ txtRecord: string;
1015
+ txtValue: string;
1016
+ cnameTarget: string;
1017
+ }>;
837
1018
  }
838
1019
 
839
1020
  type MetricRange = '1h' | '6h' | '24h' | '7d' | '14d' | '30d';
@@ -856,32 +1037,44 @@ interface CostMetrics {
856
1037
  total: number;
857
1038
  currency: string;
858
1039
  }
1040
+ interface RawMetrics {
1041
+ timestamps: number[];
1042
+ series: Array<{
1043
+ metric: string;
1044
+ values: number[];
1045
+ available?: boolean[];
1046
+ }>;
1047
+ latest?: Record<string, unknown>;
1048
+ limits?: Record<string, number>;
1049
+ }
1050
+ interface ProjectCost {
1051
+ projectId: string;
1052
+ costUsd: number;
1053
+ [key: string]: unknown;
1054
+ }
859
1055
  declare class MetricsAPI {
860
1056
  private readonly client;
861
1057
  constructor(client: PlatformClient);
862
- /** Get CPU metrics for a service or addon. */
1058
+ service(id: string, range?: MetricRange): Promise<RawMetrics>;
1059
+ addon(projectId: string, addonId: string, range?: MetricRange): Promise<RawMetrics>;
1060
+ project(id: string, opts?: {
1061
+ range?: MetricRange;
1062
+ live?: boolean;
1063
+ }): Promise<unknown>;
1064
+ private points;
863
1065
  cpu(id: string, range?: MetricRange): Promise<MetricPoint[]>;
864
- /** Get memory metrics for a service or addon. */
865
1066
  memory(id: string, range?: MetricRange): Promise<MetricPoint[]>;
866
- /** Get network I/O metrics for a service. */
867
1067
  network(id: string, range?: MetricRange): Promise<{
868
1068
  rx: MetricPoint[];
869
1069
  tx: MetricPoint[];
870
1070
  }>;
871
- /** Get disk I/O metrics for a service. */
872
1071
  disk(id: string, range?: MetricRange): Promise<{
873
1072
  read: MetricPoint[];
874
1073
  write: MetricPoint[];
875
1074
  }>;
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
1075
  all(id: string, range?: MetricRange): Promise<ServiceMetrics>;
1076
+ /** Return the backend's project cost row in USD, without guessing missing totals. */
1077
+ cost(projectId: string, range?: MetricRange): Promise<ProjectCost | null>;
885
1078
  }
886
1079
 
887
1080
  interface Workspace {
@@ -1116,6 +1309,37 @@ declare class BillingAPI {
1116
1309
  summary(): Promise<unknown>;
1117
1310
  /** Live (not-yet-invoiced) usage accumulating right now. */
1118
1311
  live(): Promise<unknown>;
1312
+ paymentMethods(): Promise<{
1313
+ items: unknown[];
1314
+ }>;
1315
+ setupPaymentMethod(returnUrl?: string): Promise<{
1316
+ url: string;
1317
+ }>;
1318
+ removePaymentMethod(id: string): Promise<void>;
1319
+ purchase(creditCents: number, opts?: {
1320
+ paymentMethod?: 'card' | 'crypto';
1321
+ returnUrl?: string;
1322
+ }): Promise<{
1323
+ url: string;
1324
+ sessionId?: string;
1325
+ }>;
1326
+ autoTopup(): Promise<unknown>;
1327
+ setAutoTopup(opts: {
1328
+ enabled: boolean;
1329
+ thresholdCents: number;
1330
+ amountCents: number;
1331
+ paymentMethodIds: string[];
1332
+ }): Promise<unknown>;
1333
+ runAutoTopup(): Promise<unknown>;
1334
+ redeemPromo(code: string): Promise<unknown>;
1335
+ x402Quote(creditCents: number): Promise<unknown>;
1336
+ paymentStatus(attemptId: string): Promise<unknown>;
1337
+ /** Pay with the CLI's durable x402 journal. Requires CLI >= 4.0.8. Amounts are cents. */
1338
+ payX402(creditCents: number, opts: {
1339
+ maxTotalCents: number;
1340
+ requestId?: string;
1341
+ executable?: string;
1342
+ }): Promise<unknown>;
1119
1343
  }
1120
1344
 
1121
1345
  interface VolumeInfo {
@@ -1250,6 +1474,8 @@ declare class Lizard {
1250
1474
  readonly domains: DomainsAPI;
1251
1475
  /** Query CPU, memory, network, disk, and cost metrics. */
1252
1476
  readonly metrics: MetricsAPI;
1477
+ readonly storage: StorageAPI;
1478
+ readonly github: GitHubAPI;
1253
1479
  constructor(opts: LizardOpts);
1254
1480
  /** Resolve the client's project reference to a stable project ID (cached). */
1255
1481
  projectId(): Promise<string>;
@@ -1325,7 +1551,7 @@ interface Account {
1325
1551
 
1326
1552
  /**
1327
1553
  * Resolve a project reference — its ID, slug, or name — to the stable project
1328
- * ID the API bills against. Exact-ID refs skip the network entirely.
1554
+ * ID the API bills against. Only resources visible to this credential are used.
1329
1555
  *
1330
1556
  * @throws {LizardError} when the reference matches no project the key can see.
1331
1557
  */
@@ -1334,6 +1560,11 @@ declare function resolveProjectId(ref: string, config: ConnectionConfig): Promis
1334
1560
  declare class LizardError extends Error {
1335
1561
  constructor(message: string);
1336
1562
  }
1563
+ /** Config was saved, but one or more deploy/restart actions failed. Never retry blindly. */
1564
+ declare class ConfigApplyError extends LizardError {
1565
+ readonly result: unknown;
1566
+ constructor(result: unknown);
1567
+ }
1337
1568
  declare class AuthenticationError extends LizardError {
1338
1569
  constructor(message?: string);
1339
1570
  }
@@ -1503,4 +1734,28 @@ declare class CodeSandbox extends Sandbox {
1503
1734
  static connect(sandboxId: string, opts?: ConnectionOpts): Promise<CodeSandbox>;
1504
1735
  }
1505
1736
 
1506
- export { type Account, type Addon, type AddonType, AddonsAPI, type ApiKey, type ApiKeyScope, ApiKeysAPI, AuthenticationError, type Balance, BillingAPI, type CodeContext, CodeSandbox, 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, DomainsAPI, Execution, ExecutionError, type FileInfo, type FsOpts, type ListTransactionsOpts, Lizard, LizardError, type LizardOpts, type LogLine, type MetricPoint, type MetricRange, MetricsAPI, NotFoundError, PlatformClient, type ProcessOpts, type ProcessResult, type Project, ProjectsAPI, type Region, RegionsAPI, type RunCodeLanguage, type RunCodeOpts, Sandbox, type SandboxInfo, type SandboxOpts, type ScaleOpts, type Secret, SecretsAPI, type Service, type ServiceMetrics, ServicesAPI, type SetSecretOpts, TimeoutError, type Transaction, type TransactionPage, Volume, type VolumeInfo, type Workspace, WorkspacesAPI, resolveProjectId };
1737
+ interface CLIResult {
1738
+ code: number;
1739
+ stdout: string;
1740
+ stderr: string;
1741
+ events: unknown[];
1742
+ }
1743
+ interface CLIOptions extends ConnectionOpts {
1744
+ executable?: string;
1745
+ cwd?: string;
1746
+ timeoutMs?: number;
1747
+ }
1748
+ /** Optional adapter for local CLI workflows. Requires the Lizard CLI on PATH.
1749
+ * Arguments are passed directly, without a shell. It does not add --yes, retry
1750
+ * payments. Authentication follows the CLI configuration.
1751
+ */
1752
+ declare class LizardCLI {
1753
+ private readonly opts;
1754
+ constructor(opts?: CLIOptions);
1755
+ run(args: readonly string[], opts?: {
1756
+ stdin?: string;
1757
+ signal?: AbortSignal;
1758
+ }): Promise<CLIResult>;
1759
+ }
1760
+
1761
+ 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 };