@lizard-build/sdk 0.1.61 → 0.1.63

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
@@ -68,7 +68,7 @@ interface Addon {
68
68
  name: string;
69
69
  type: AddonType;
70
70
  projectId: string;
71
- status: 'none' | 'running' | 'crashed' | 'stopped';
71
+ status: 'none' | 'running' | 'crashed' | 'stopped' | 'paused';
72
72
  deployStatus: string;
73
73
  version?: string;
74
74
  /** Exposed connection variables (e.g. DATABASE_URL, REDIS_URL). */
@@ -117,6 +117,17 @@ declare class AddonsAPI {
117
117
  }): Promise<Addon>;
118
118
  /** Restart an addon. */
119
119
  redeploy(projectId: string, addonId: string): Promise<void>;
120
+ /**
121
+ * Pause a managed database: it scales to 0 (connections are refused) and keeps its host,
122
+ * port, password and data. Postgres and Redis.
123
+ */
124
+ pause(projectId: string, addonId: string): Promise<PauseState>;
125
+ /** Resume a paused database: same host, port, password and data. */
126
+ resume(projectId: string, addonId: string): Promise<PauseState>;
127
+ /** Serverless setting of a database (Postgres, Redis). */
128
+ getSleep(projectId: string, addonId: string): Promise<SleepSetting>;
129
+ /** Make a database serverless (sleep when idle, wake on the next connection) or always on. */
130
+ setSleep(projectId: string, addonId: string, opts: SleepOpts): Promise<SleepSetting>;
120
131
  rename(projectId: string, addonId: string, name: string): Promise<unknown>;
121
132
  secrets(projectId: string, addonId: string): Promise<Array<{
122
133
  key: string;
@@ -136,6 +147,45 @@ interface CreateProjectOpts {
136
147
  workspaceId: string;
137
148
  name: string;
138
149
  }
150
+ /** One app or managed database a project / workspace pause or resume acted on. */
151
+ interface PausedService {
152
+ kind: 'app' | 'database';
153
+ id: string;
154
+ name: string;
155
+ }
156
+ /** What `projects.pause/resume` and `workspaces.pause/resume` answer: what was done, and
157
+ * what was skipped with why (already paused, not running, busy, a storage bucket...). */
158
+ interface PauseResult {
159
+ done: PausedService[];
160
+ skipped: Array<PausedService & {
161
+ reason: string;
162
+ }>;
163
+ }
164
+ /**
165
+ * Serverless ("sleep when idle"): after `idleMinutes` with no traffic the service sleeps with
166
+ * its memory saved, and the next request or connection wakes it in about a second.
167
+ */
168
+ interface SleepSetting {
169
+ enabled: boolean;
170
+ idleMinutes: number;
171
+ lastSleptAt: number | null;
172
+ lastWokeAt: number | null;
173
+ lastError: string | null;
174
+ sleeps: number;
175
+ wakes: number;
176
+ /** On a change: whether the service restarted to apply it. */
177
+ restarted?: boolean;
178
+ }
179
+ /** Turn serverless on (`idleMinutes` 5-1440, default 15) or off. */
180
+ interface SleepOpts {
181
+ enabled: boolean;
182
+ idleMinutes?: number;
183
+ }
184
+ /** What pausing or resuming one service answers. */
185
+ interface PauseState {
186
+ ok: boolean;
187
+ status: 'paused' | 'running';
188
+ }
139
189
  declare class ProjectsAPI {
140
190
  private readonly client;
141
191
  constructor(client: PlatformClient);
@@ -154,6 +204,13 @@ declare class ProjectsAPI {
154
204
  update(id: string, opts: {
155
205
  name?: string;
156
206
  }): Promise<Project>;
207
+ /**
208
+ * Pause every app and managed database of a project: each scales to 0 and keeps its URL,
209
+ * host, port, password, settings and volumes. Skipped ones are listed with why.
210
+ */
211
+ pause(id: string): Promise<PauseResult>;
212
+ /** Resume what was paused in a project (not what a billing freeze paused). */
213
+ resume(id: string): Promise<PauseResult>;
157
214
  /** Delete a project. */
158
215
  delete(id: string): Promise<void>;
159
216
  apply(id: string, config: ProjectConfig): Promise<ConfigResult>;
@@ -205,7 +262,7 @@ interface Service {
205
262
  id: string;
206
263
  name: string;
207
264
  projectId: string;
208
- status: 'none' | 'running' | 'crashed' | 'stopped';
265
+ status: 'none' | 'running' | 'crashed' | 'stopped' | 'paused';
209
266
  deployStatus: 'idle' | 'building' | 'deploying' | 'restarting' | 'failed' | 'deleting';
210
267
  domain?: string;
211
268
  region?: string;
@@ -323,6 +380,20 @@ declare class ServicesAPI {
323
380
  redeploy(id: string): Promise<DeployHandle>;
324
381
  /** Restart a service without rebuilding. */
325
382
  restart(id: string): Promise<void>;
383
+ /**
384
+ * Pause a service: it scales to 0 (its URL answers 503) and keeps its URL, settings, env
385
+ * and volumes. Restart and redeploy are refused until it is resumed.
386
+ */
387
+ pause(id: string): Promise<PauseState>;
388
+ /** Resume a paused service: it starts again from the same image, with its data. */
389
+ resume(id: string): Promise<PauseState>;
390
+ /** Serverless setting of a service: whether it sleeps when idle, and how often it did. */
391
+ getSleep(id: string): Promise<SleepSetting>;
392
+ /**
393
+ * Make a service serverless (sleep when idle, wake in about a second on the next request) or
394
+ * always on. Turning it on restarts it once. Needs one replica and a port.
395
+ */
396
+ setSleep(id: string, opts: SleepOpts): Promise<SleepSetting>;
326
397
  /** Scale a service. */
327
398
  scale(id: string, opts: ScaleOpts): Promise<void>;
328
399
  /**
@@ -1432,6 +1503,13 @@ declare class WorkspacesAPI {
1432
1503
  * `code: 'ACCOUNT_SCOPE_REQUIRED'`.
1433
1504
  */
1434
1505
  create(opts: CreateWorkspaceOpts): Promise<Workspace>;
1506
+ /**
1507
+ * Pause every app and managed database in every project of a workspace (owner only).
1508
+ * Each keeps its URL, host, port, password, settings and volumes.
1509
+ */
1510
+ pause(id: string): Promise<PauseResult>;
1511
+ /** Resume what was paused in a workspace (owner only; not what a billing freeze paused). */
1512
+ resume(id: string): Promise<PauseResult>;
1435
1513
  /**
1436
1514
  * Delete a workspace.
1437
1515
  *
package/dist/index.d.ts CHANGED
@@ -68,7 +68,7 @@ interface Addon {
68
68
  name: string;
69
69
  type: AddonType;
70
70
  projectId: string;
71
- status: 'none' | 'running' | 'crashed' | 'stopped';
71
+ status: 'none' | 'running' | 'crashed' | 'stopped' | 'paused';
72
72
  deployStatus: string;
73
73
  version?: string;
74
74
  /** Exposed connection variables (e.g. DATABASE_URL, REDIS_URL). */
@@ -117,6 +117,17 @@ declare class AddonsAPI {
117
117
  }): Promise<Addon>;
118
118
  /** Restart an addon. */
119
119
  redeploy(projectId: string, addonId: string): Promise<void>;
120
+ /**
121
+ * Pause a managed database: it scales to 0 (connections are refused) and keeps its host,
122
+ * port, password and data. Postgres and Redis.
123
+ */
124
+ pause(projectId: string, addonId: string): Promise<PauseState>;
125
+ /** Resume a paused database: same host, port, password and data. */
126
+ resume(projectId: string, addonId: string): Promise<PauseState>;
127
+ /** Serverless setting of a database (Postgres, Redis). */
128
+ getSleep(projectId: string, addonId: string): Promise<SleepSetting>;
129
+ /** Make a database serverless (sleep when idle, wake on the next connection) or always on. */
130
+ setSleep(projectId: string, addonId: string, opts: SleepOpts): Promise<SleepSetting>;
120
131
  rename(projectId: string, addonId: string, name: string): Promise<unknown>;
121
132
  secrets(projectId: string, addonId: string): Promise<Array<{
122
133
  key: string;
@@ -136,6 +147,45 @@ interface CreateProjectOpts {
136
147
  workspaceId: string;
137
148
  name: string;
138
149
  }
150
+ /** One app or managed database a project / workspace pause or resume acted on. */
151
+ interface PausedService {
152
+ kind: 'app' | 'database';
153
+ id: string;
154
+ name: string;
155
+ }
156
+ /** What `projects.pause/resume` and `workspaces.pause/resume` answer: what was done, and
157
+ * what was skipped with why (already paused, not running, busy, a storage bucket...). */
158
+ interface PauseResult {
159
+ done: PausedService[];
160
+ skipped: Array<PausedService & {
161
+ reason: string;
162
+ }>;
163
+ }
164
+ /**
165
+ * Serverless ("sleep when idle"): after `idleMinutes` with no traffic the service sleeps with
166
+ * its memory saved, and the next request or connection wakes it in about a second.
167
+ */
168
+ interface SleepSetting {
169
+ enabled: boolean;
170
+ idleMinutes: number;
171
+ lastSleptAt: number | null;
172
+ lastWokeAt: number | null;
173
+ lastError: string | null;
174
+ sleeps: number;
175
+ wakes: number;
176
+ /** On a change: whether the service restarted to apply it. */
177
+ restarted?: boolean;
178
+ }
179
+ /** Turn serverless on (`idleMinutes` 5-1440, default 15) or off. */
180
+ interface SleepOpts {
181
+ enabled: boolean;
182
+ idleMinutes?: number;
183
+ }
184
+ /** What pausing or resuming one service answers. */
185
+ interface PauseState {
186
+ ok: boolean;
187
+ status: 'paused' | 'running';
188
+ }
139
189
  declare class ProjectsAPI {
140
190
  private readonly client;
141
191
  constructor(client: PlatformClient);
@@ -154,6 +204,13 @@ declare class ProjectsAPI {
154
204
  update(id: string, opts: {
155
205
  name?: string;
156
206
  }): Promise<Project>;
207
+ /**
208
+ * Pause every app and managed database of a project: each scales to 0 and keeps its URL,
209
+ * host, port, password, settings and volumes. Skipped ones are listed with why.
210
+ */
211
+ pause(id: string): Promise<PauseResult>;
212
+ /** Resume what was paused in a project (not what a billing freeze paused). */
213
+ resume(id: string): Promise<PauseResult>;
157
214
  /** Delete a project. */
158
215
  delete(id: string): Promise<void>;
159
216
  apply(id: string, config: ProjectConfig): Promise<ConfigResult>;
@@ -205,7 +262,7 @@ interface Service {
205
262
  id: string;
206
263
  name: string;
207
264
  projectId: string;
208
- status: 'none' | 'running' | 'crashed' | 'stopped';
265
+ status: 'none' | 'running' | 'crashed' | 'stopped' | 'paused';
209
266
  deployStatus: 'idle' | 'building' | 'deploying' | 'restarting' | 'failed' | 'deleting';
210
267
  domain?: string;
211
268
  region?: string;
@@ -323,6 +380,20 @@ declare class ServicesAPI {
323
380
  redeploy(id: string): Promise<DeployHandle>;
324
381
  /** Restart a service without rebuilding. */
325
382
  restart(id: string): Promise<void>;
383
+ /**
384
+ * Pause a service: it scales to 0 (its URL answers 503) and keeps its URL, settings, env
385
+ * and volumes. Restart and redeploy are refused until it is resumed.
386
+ */
387
+ pause(id: string): Promise<PauseState>;
388
+ /** Resume a paused service: it starts again from the same image, with its data. */
389
+ resume(id: string): Promise<PauseState>;
390
+ /** Serverless setting of a service: whether it sleeps when idle, and how often it did. */
391
+ getSleep(id: string): Promise<SleepSetting>;
392
+ /**
393
+ * Make a service serverless (sleep when idle, wake in about a second on the next request) or
394
+ * always on. Turning it on restarts it once. Needs one replica and a port.
395
+ */
396
+ setSleep(id: string, opts: SleepOpts): Promise<SleepSetting>;
326
397
  /** Scale a service. */
327
398
  scale(id: string, opts: ScaleOpts): Promise<void>;
328
399
  /**
@@ -1432,6 +1503,13 @@ declare class WorkspacesAPI {
1432
1503
  * `code: 'ACCOUNT_SCOPE_REQUIRED'`.
1433
1504
  */
1434
1505
  create(opts: CreateWorkspaceOpts): Promise<Workspace>;
1506
+ /**
1507
+ * Pause every app and managed database in every project of a workspace (owner only).
1508
+ * Each keeps its URL, host, port, password, settings and volumes.
1509
+ */
1510
+ pause(id: string): Promise<PauseResult>;
1511
+ /** Resume what was paused in a workspace (owner only; not what a billing freeze paused). */
1512
+ resume(id: string): Promise<PauseResult>;
1435
1513
  /**
1436
1514
  * Delete a workspace.
1437
1515
  *
package/dist/index.js CHANGED
@@ -407,6 +407,28 @@ var ServicesAPI = class {
407
407
  restart(id) {
408
408
  return this.client.post(`/api/apps/${id}/restart`, {});
409
409
  }
410
+ /**
411
+ * Pause a service: it scales to 0 (its URL answers 503) and keeps its URL, settings, env
412
+ * and volumes. Restart and redeploy are refused until it is resumed.
413
+ */
414
+ pause(id) {
415
+ return this.client.post(`/api/apps/${id}/pause`, {});
416
+ }
417
+ /** Resume a paused service: it starts again from the same image, with its data. */
418
+ resume(id) {
419
+ return this.client.post(`/api/apps/${id}/resume`, {});
420
+ }
421
+ /** Serverless setting of a service: whether it sleeps when idle, and how often it did. */
422
+ getSleep(id) {
423
+ return this.client.get(`/api/apps/${id}/sleep`);
424
+ }
425
+ /**
426
+ * Make a service serverless (sleep when idle, wake in about a second on the next request) or
427
+ * always on. Turning it on restarts it once. Needs one replica and a port.
428
+ */
429
+ setSleep(id, opts) {
430
+ return this.client.put(`/api/apps/${id}/sleep`, opts);
431
+ }
410
432
  /** Scale a service. */
411
433
  async scale(id, opts) {
412
434
  if (opts.storageMi !== void 0) throw new LizardError("Storage scaling is only supported for addons");
@@ -1393,6 +1415,17 @@ var ProjectsAPI = class {
1393
1415
  update(id, opts) {
1394
1416
  return this.client.patch(`/api/projects/${id}`, opts);
1395
1417
  }
1418
+ /**
1419
+ * Pause every app and managed database of a project: each scales to 0 and keeps its URL,
1420
+ * host, port, password, settings and volumes. Skipped ones are listed with why.
1421
+ */
1422
+ pause(id) {
1423
+ return this.client.post(`/api/projects/${id}/pause`, {});
1424
+ }
1425
+ /** Resume what was paused in a project (not what a billing freeze paused). */
1426
+ resume(id) {
1427
+ return this.client.post(`/api/projects/${id}/resume`, {});
1428
+ }
1396
1429
  /** Delete a project. */
1397
1430
  delete(id) {
1398
1431
  return this.client.delete(`/api/projects/${id}`);
@@ -1473,6 +1506,25 @@ var AddonsAPI = class {
1473
1506
  redeploy(projectId, addonId) {
1474
1507
  return this.client.post(`/api/projects/${projectId}/addons/${addonId}/redeploy`, {});
1475
1508
  }
1509
+ /**
1510
+ * Pause a managed database: it scales to 0 (connections are refused) and keeps its host,
1511
+ * port, password and data. Postgres and Redis.
1512
+ */
1513
+ pause(projectId, addonId) {
1514
+ return this.client.post(`/api/projects/${projectId}/addons/${addonId}/pause`, {});
1515
+ }
1516
+ /** Resume a paused database: same host, port, password and data. */
1517
+ resume(projectId, addonId) {
1518
+ return this.client.post(`/api/projects/${projectId}/addons/${addonId}/resume`, {});
1519
+ }
1520
+ /** Serverless setting of a database (Postgres, Redis). */
1521
+ getSleep(projectId, addonId) {
1522
+ return this.client.get(`/api/projects/${projectId}/addons/${addonId}/sleep`);
1523
+ }
1524
+ /** Make a database serverless (sleep when idle, wake on the next connection) or always on. */
1525
+ setSleep(projectId, addonId, opts) {
1526
+ return this.client.put(`/api/projects/${projectId}/addons/${addonId}/sleep`, opts);
1527
+ }
1476
1528
  rename(projectId, addonId, name) {
1477
1529
  return this.client.patch(`/api/projects/${projectId}/addons/${addonId}`, { name });
1478
1530
  }
@@ -1663,6 +1715,17 @@ var WorkspacesAPI = class {
1663
1715
  create(opts) {
1664
1716
  return this.client.post("/api/workspaces", opts);
1665
1717
  }
1718
+ /**
1719
+ * Pause every app and managed database in every project of a workspace (owner only).
1720
+ * Each keeps its URL, host, port, password, settings and volumes.
1721
+ */
1722
+ pause(id) {
1723
+ return this.client.post(`/api/workspaces/${id}/pause`, {});
1724
+ }
1725
+ /** Resume what was paused in a workspace (owner only; not what a billing freeze paused). */
1726
+ resume(id) {
1727
+ return this.client.post(`/api/workspaces/${id}/resume`, {});
1728
+ }
1666
1729
  /**
1667
1730
  * Delete a workspace.
1668
1731
  *
package/dist/index.mjs CHANGED
@@ -354,6 +354,28 @@ var ServicesAPI = class {
354
354
  restart(id) {
355
355
  return this.client.post(`/api/apps/${id}/restart`, {});
356
356
  }
357
+ /**
358
+ * Pause a service: it scales to 0 (its URL answers 503) and keeps its URL, settings, env
359
+ * and volumes. Restart and redeploy are refused until it is resumed.
360
+ */
361
+ pause(id) {
362
+ return this.client.post(`/api/apps/${id}/pause`, {});
363
+ }
364
+ /** Resume a paused service: it starts again from the same image, with its data. */
365
+ resume(id) {
366
+ return this.client.post(`/api/apps/${id}/resume`, {});
367
+ }
368
+ /** Serverless setting of a service: whether it sleeps when idle, and how often it did. */
369
+ getSleep(id) {
370
+ return this.client.get(`/api/apps/${id}/sleep`);
371
+ }
372
+ /**
373
+ * Make a service serverless (sleep when idle, wake in about a second on the next request) or
374
+ * always on. Turning it on restarts it once. Needs one replica and a port.
375
+ */
376
+ setSleep(id, opts) {
377
+ return this.client.put(`/api/apps/${id}/sleep`, opts);
378
+ }
357
379
  /** Scale a service. */
358
380
  async scale(id, opts) {
359
381
  if (opts.storageMi !== void 0) throw new LizardError("Storage scaling is only supported for addons");
@@ -1340,6 +1362,17 @@ var ProjectsAPI = class {
1340
1362
  update(id, opts) {
1341
1363
  return this.client.patch(`/api/projects/${id}`, opts);
1342
1364
  }
1365
+ /**
1366
+ * Pause every app and managed database of a project: each scales to 0 and keeps its URL,
1367
+ * host, port, password, settings and volumes. Skipped ones are listed with why.
1368
+ */
1369
+ pause(id) {
1370
+ return this.client.post(`/api/projects/${id}/pause`, {});
1371
+ }
1372
+ /** Resume what was paused in a project (not what a billing freeze paused). */
1373
+ resume(id) {
1374
+ return this.client.post(`/api/projects/${id}/resume`, {});
1375
+ }
1343
1376
  /** Delete a project. */
1344
1377
  delete(id) {
1345
1378
  return this.client.delete(`/api/projects/${id}`);
@@ -1420,6 +1453,25 @@ var AddonsAPI = class {
1420
1453
  redeploy(projectId, addonId) {
1421
1454
  return this.client.post(`/api/projects/${projectId}/addons/${addonId}/redeploy`, {});
1422
1455
  }
1456
+ /**
1457
+ * Pause a managed database: it scales to 0 (connections are refused) and keeps its host,
1458
+ * port, password and data. Postgres and Redis.
1459
+ */
1460
+ pause(projectId, addonId) {
1461
+ return this.client.post(`/api/projects/${projectId}/addons/${addonId}/pause`, {});
1462
+ }
1463
+ /** Resume a paused database: same host, port, password and data. */
1464
+ resume(projectId, addonId) {
1465
+ return this.client.post(`/api/projects/${projectId}/addons/${addonId}/resume`, {});
1466
+ }
1467
+ /** Serverless setting of a database (Postgres, Redis). */
1468
+ getSleep(projectId, addonId) {
1469
+ return this.client.get(`/api/projects/${projectId}/addons/${addonId}/sleep`);
1470
+ }
1471
+ /** Make a database serverless (sleep when idle, wake on the next connection) or always on. */
1472
+ setSleep(projectId, addonId, opts) {
1473
+ return this.client.put(`/api/projects/${projectId}/addons/${addonId}/sleep`, opts);
1474
+ }
1423
1475
  rename(projectId, addonId, name) {
1424
1476
  return this.client.patch(`/api/projects/${projectId}/addons/${addonId}`, { name });
1425
1477
  }
@@ -1610,6 +1662,17 @@ var WorkspacesAPI = class {
1610
1662
  create(opts) {
1611
1663
  return this.client.post("/api/workspaces", opts);
1612
1664
  }
1665
+ /**
1666
+ * Pause every app and managed database in every project of a workspace (owner only).
1667
+ * Each keeps its URL, host, port, password, settings and volumes.
1668
+ */
1669
+ pause(id) {
1670
+ return this.client.post(`/api/workspaces/${id}/pause`, {});
1671
+ }
1672
+ /** Resume what was paused in a workspace (owner only; not what a billing freeze paused). */
1673
+ resume(id) {
1674
+ return this.client.post(`/api/workspaces/${id}/resume`, {});
1675
+ }
1613
1676
  /**
1614
1677
  * Delete a workspace.
1615
1678
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lizard-build/sdk",
3
- "version": "0.1.61",
3
+ "version": "0.1.63",
4
4
  "description": "TypeScript SDK for Lizard: Firecracker microVM sandboxes, code execution and cloud apps.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",