@lizard-build/sdk 0.1.55 → 0.1.57

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 CHANGED
@@ -40,7 +40,7 @@ The package includes TypeScript declarations and ESM and CommonJS builds. For Co
40
40
 
41
41
  ## Machine size
42
42
 
43
- Sandboxes come in three sizes: `small` (2 vCPU / 4 GB, $0.018/h), `medium` (4 vCPU / 8 GB, $0.036/h, the default) and `large` (8 vCPU / 16 GB, $0.072/h). Billing is flat by size, per second while the sandbox runs; measured CPU/RAM are not charged, egress is free, and volumes bill separately.
43
+ Sandboxes come in three sizes: `small` (2 vCPU / 4 GB, $0.0162/h), `medium` (4 vCPU / 8 GB, $0.0324/h, the default) and `large` (8 vCPU / 16 GB, $0.0648/h). Billing is flat by size, per second while the sandbox runs; measured CPU/RAM are not charged, egress is free, and volumes bill separately.
44
44
 
45
45
  ```ts
46
46
  const sandbox = await lizard.create('base', { size: 'large' })
package/dist/index.d.mts CHANGED
@@ -831,9 +831,9 @@ interface SandboxOpts extends ConnectionOpts {
831
831
  snapshotId?: string;
832
832
  /**
833
833
  * Machine size, billed flat per hour (per second of running time):
834
- * - `'small'` — 2 vCPU / 4 GB, $0.018/h
835
- * - `'medium'` — 4 vCPU / 8 GB, $0.036/h (default)
836
- * - `'large'` — 8 vCPU / 16 GB, $0.072/h
834
+ * - `'small'` — 2 vCPU / 4 GB, $0.0162/h
835
+ * - `'medium'` — 4 vCPU / 8 GB, $0.0324/h (default)
836
+ * - `'large'` — 8 vCPU / 16 GB, $0.0648/h
837
837
  *
838
838
  * Measured CPU/RAM are not charged and egress is free. Ignored with {@link SandboxOpts.snapshotId}.
839
839
  */
@@ -918,10 +918,22 @@ interface SandboxSnapshot {
918
918
  memoryMb: number;
919
919
  /** Unix milliseconds. */
920
920
  createdAt: number;
921
+ /** Where it may be restored; see {@link SnapshotScope}. */
922
+ scope: SnapshotScope;
923
+ /** The user who took it; `null` for snapshots from before snapshots belonged to a user. */
924
+ createdBy: string | null;
921
925
  }
926
+ /**
927
+ * Where a snapshot may be restored, always in its own region: `'user'` (the default) into any
928
+ * project you can use, in any of your workspaces; `'workspace'` only its own workspace;
929
+ * `'project'` only its own project.
930
+ */
931
+ type SnapshotScope = 'user' | 'workspace' | 'project';
922
932
  interface SnapshotOpts {
923
933
  /** Warm copies to keep ready (container sandboxes only; ignored for Firecracker, whose snapshots restore from disk). */
924
934
  poolSize?: number;
935
+ /** Where it may be restored. Default `'user'`: any of your projects and workspaces. */
936
+ scope?: SnapshotScope;
925
937
  }
926
938
  /**
927
939
  * One entry of {@link Sandbox.fork}'s result: the new sandbox, or why that copy
@@ -1173,11 +1185,19 @@ declare class Sandbox extends SandboxClient {
1173
1185
  signal?: AbortSignal;
1174
1186
  }): AsyncGenerator<StreamEvent, any, any>;
1175
1187
  static snapshots(projectId: string, opts?: ConnectionOpts): Promise<SandboxSnapshot[]>;
1188
+ /** Every snapshot you took, across all your workspaces and projects. */
1189
+ static mySnapshots(opts?: ConnectionOpts): Promise<SandboxSnapshot[]>;
1176
1190
  static getSnapshot(snapshotId: string, opts?: ConnectionOpts): Promise<SandboxSnapshot>;
1177
- /** Start a new sandbox from a snapshot, in the snapshot's project and region. */
1191
+ /**
1192
+ * Start a new sandbox from a snapshot, in its region. `projectId` puts it in another project,
1193
+ * in any of your workspaces, as the snapshot's scope allows; default: the snapshot's own project.
1194
+ */
1178
1195
  static restore(snapshotId: string, opts?: ConnectionOpts & {
1179
1196
  timeoutMs?: number;
1197
+ projectId?: string;
1180
1198
  }): Promise<Sandbox>;
1199
+ /** Change where a snapshot you took may be restored. */
1200
+ static setSnapshotScope(snapshotId: string, scope: SnapshotScope, opts?: ConnectionOpts): Promise<SandboxSnapshot>;
1181
1201
  static setSnapshotWarmPool(snapshotId: string, poolSize: number, opts?: ConnectionOpts): Promise<SandboxSnapshot>;
1182
1202
  /** Release idle warm copies (container snapshots); retain saved state and existing claimed sandboxes. */
1183
1203
  static pauseSnapshot(snapshotId: string, opts?: ConnectionOpts): Promise<SandboxSnapshot>;
@@ -2218,4 +2238,4 @@ declare class LizardCLI {
2218
2238
  }): Promise<CLIResult>;
2219
2239
  }
2220
2240
 
2221
- export { type Account, type Addon, type AddonType, AddonsAPI, type ApiKey, type ApiKeyScope, ApiKeysAPI, AuthenticationError, type Balance, BillingAPI, type CLIOptions, type CLIResult, type CheckoutSession, type ClickOpts, 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, Desktop, type DesktopInfo, type DesktopStartOpts, type DomainInfo, type DomainStatus, DomainsAPI, Execution, ExecutionError, type ExposedPort, type FileInfo, type ForkResult, type FsEvent, type FsOpts, GitHubAPI, type ListTransactionsOpts, Lizard, LizardCLI, LizardError, type LizardOpts, type LogLine, type MetricPoint, type MetricRange, MetricsAPI, type MouseButton, NotFoundError, PaymentRequiredError, type Plan, PlatformClient, type ProcessInfo, type ProcessOpts, type ProcessResult, type ProcessSignal, type Project, type ProjectConfig, type ProjectCost, ProjectsAPI, type PromoRedemption, type RawMetrics, type Region, RegionsAPI, type RunCodeLanguage, type RunCodeOpts, Sandbox, type SandboxInfo, type SandboxOpts, type SandboxSnapshot, type ScaleOpts, type ScrollDirection, type Secret, SecretsAPI, type Service, type ServiceMetrics, type ServiceUpdate, ServicesAPI, type SetSecretOpts, type SnapshotOpts, type SnapshotWaitOpts, type StartCheckoutOpts, type StartProNowResult, StorageAPI, type StreamEvent, type Subscription, type SubscriptionStatus, TimeoutError, type Transaction, type TransactionPage, Volume, type VolumeInfo, type Workspace, WorkspacesAPI, resolveProjectId };
2241
+ export { type Account, type Addon, type AddonType, AddonsAPI, type ApiKey, type ApiKeyScope, ApiKeysAPI, AuthenticationError, type Balance, BillingAPI, type CLIOptions, type CLIResult, type CheckoutSession, type ClickOpts, 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, Desktop, type DesktopInfo, type DesktopStartOpts, type DomainInfo, type DomainStatus, DomainsAPI, Execution, ExecutionError, type ExposedPort, type FileInfo, type ForkResult, type FsEvent, type FsOpts, GitHubAPI, type ListTransactionsOpts, Lizard, LizardCLI, LizardError, type LizardOpts, type LogLine, type MetricPoint, type MetricRange, MetricsAPI, type MouseButton, NotFoundError, PaymentRequiredError, type Plan, PlatformClient, type ProcessInfo, type ProcessOpts, type ProcessResult, type ProcessSignal, type Project, type ProjectConfig, type ProjectCost, ProjectsAPI, type PromoRedemption, type RawMetrics, type Region, RegionsAPI, type RunCodeLanguage, type RunCodeOpts, Sandbox, type SandboxInfo, type SandboxOpts, type SandboxSnapshot, type ScaleOpts, type ScrollDirection, type Secret, SecretsAPI, type Service, type ServiceMetrics, type ServiceUpdate, ServicesAPI, type SetSecretOpts, type SnapshotOpts, type SnapshotScope, type SnapshotWaitOpts, type StartCheckoutOpts, type StartProNowResult, StorageAPI, type StreamEvent, type Subscription, type SubscriptionStatus, TimeoutError, type Transaction, type TransactionPage, Volume, type VolumeInfo, type Workspace, WorkspacesAPI, resolveProjectId };
package/dist/index.d.ts CHANGED
@@ -831,9 +831,9 @@ interface SandboxOpts extends ConnectionOpts {
831
831
  snapshotId?: string;
832
832
  /**
833
833
  * Machine size, billed flat per hour (per second of running time):
834
- * - `'small'` — 2 vCPU / 4 GB, $0.018/h
835
- * - `'medium'` — 4 vCPU / 8 GB, $0.036/h (default)
836
- * - `'large'` — 8 vCPU / 16 GB, $0.072/h
834
+ * - `'small'` — 2 vCPU / 4 GB, $0.0162/h
835
+ * - `'medium'` — 4 vCPU / 8 GB, $0.0324/h (default)
836
+ * - `'large'` — 8 vCPU / 16 GB, $0.0648/h
837
837
  *
838
838
  * Measured CPU/RAM are not charged and egress is free. Ignored with {@link SandboxOpts.snapshotId}.
839
839
  */
@@ -918,10 +918,22 @@ interface SandboxSnapshot {
918
918
  memoryMb: number;
919
919
  /** Unix milliseconds. */
920
920
  createdAt: number;
921
+ /** Where it may be restored; see {@link SnapshotScope}. */
922
+ scope: SnapshotScope;
923
+ /** The user who took it; `null` for snapshots from before snapshots belonged to a user. */
924
+ createdBy: string | null;
921
925
  }
926
+ /**
927
+ * Where a snapshot may be restored, always in its own region: `'user'` (the default) into any
928
+ * project you can use, in any of your workspaces; `'workspace'` only its own workspace;
929
+ * `'project'` only its own project.
930
+ */
931
+ type SnapshotScope = 'user' | 'workspace' | 'project';
922
932
  interface SnapshotOpts {
923
933
  /** Warm copies to keep ready (container sandboxes only; ignored for Firecracker, whose snapshots restore from disk). */
924
934
  poolSize?: number;
935
+ /** Where it may be restored. Default `'user'`: any of your projects and workspaces. */
936
+ scope?: SnapshotScope;
925
937
  }
926
938
  /**
927
939
  * One entry of {@link Sandbox.fork}'s result: the new sandbox, or why that copy
@@ -1173,11 +1185,19 @@ declare class Sandbox extends SandboxClient {
1173
1185
  signal?: AbortSignal;
1174
1186
  }): AsyncGenerator<StreamEvent, any, any>;
1175
1187
  static snapshots(projectId: string, opts?: ConnectionOpts): Promise<SandboxSnapshot[]>;
1188
+ /** Every snapshot you took, across all your workspaces and projects. */
1189
+ static mySnapshots(opts?: ConnectionOpts): Promise<SandboxSnapshot[]>;
1176
1190
  static getSnapshot(snapshotId: string, opts?: ConnectionOpts): Promise<SandboxSnapshot>;
1177
- /** Start a new sandbox from a snapshot, in the snapshot's project and region. */
1191
+ /**
1192
+ * Start a new sandbox from a snapshot, in its region. `projectId` puts it in another project,
1193
+ * in any of your workspaces, as the snapshot's scope allows; default: the snapshot's own project.
1194
+ */
1178
1195
  static restore(snapshotId: string, opts?: ConnectionOpts & {
1179
1196
  timeoutMs?: number;
1197
+ projectId?: string;
1180
1198
  }): Promise<Sandbox>;
1199
+ /** Change where a snapshot you took may be restored. */
1200
+ static setSnapshotScope(snapshotId: string, scope: SnapshotScope, opts?: ConnectionOpts): Promise<SandboxSnapshot>;
1181
1201
  static setSnapshotWarmPool(snapshotId: string, poolSize: number, opts?: ConnectionOpts): Promise<SandboxSnapshot>;
1182
1202
  /** Release idle warm copies (container snapshots); retain saved state and existing claimed sandboxes. */
1183
1203
  static pauseSnapshot(snapshotId: string, opts?: ConnectionOpts): Promise<SandboxSnapshot>;
@@ -2218,4 +2238,4 @@ declare class LizardCLI {
2218
2238
  }): Promise<CLIResult>;
2219
2239
  }
2220
2240
 
2221
- export { type Account, type Addon, type AddonType, AddonsAPI, type ApiKey, type ApiKeyScope, ApiKeysAPI, AuthenticationError, type Balance, BillingAPI, type CLIOptions, type CLIResult, type CheckoutSession, type ClickOpts, 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, Desktop, type DesktopInfo, type DesktopStartOpts, type DomainInfo, type DomainStatus, DomainsAPI, Execution, ExecutionError, type ExposedPort, type FileInfo, type ForkResult, type FsEvent, type FsOpts, GitHubAPI, type ListTransactionsOpts, Lizard, LizardCLI, LizardError, type LizardOpts, type LogLine, type MetricPoint, type MetricRange, MetricsAPI, type MouseButton, NotFoundError, PaymentRequiredError, type Plan, PlatformClient, type ProcessInfo, type ProcessOpts, type ProcessResult, type ProcessSignal, type Project, type ProjectConfig, type ProjectCost, ProjectsAPI, type PromoRedemption, type RawMetrics, type Region, RegionsAPI, type RunCodeLanguage, type RunCodeOpts, Sandbox, type SandboxInfo, type SandboxOpts, type SandboxSnapshot, type ScaleOpts, type ScrollDirection, type Secret, SecretsAPI, type Service, type ServiceMetrics, type ServiceUpdate, ServicesAPI, type SetSecretOpts, type SnapshotOpts, type SnapshotWaitOpts, type StartCheckoutOpts, type StartProNowResult, StorageAPI, type StreamEvent, type Subscription, type SubscriptionStatus, TimeoutError, type Transaction, type TransactionPage, Volume, type VolumeInfo, type Workspace, WorkspacesAPI, resolveProjectId };
2241
+ export { type Account, type Addon, type AddonType, AddonsAPI, type ApiKey, type ApiKeyScope, ApiKeysAPI, AuthenticationError, type Balance, BillingAPI, type CLIOptions, type CLIResult, type CheckoutSession, type ClickOpts, 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, Desktop, type DesktopInfo, type DesktopStartOpts, type DomainInfo, type DomainStatus, DomainsAPI, Execution, ExecutionError, type ExposedPort, type FileInfo, type ForkResult, type FsEvent, type FsOpts, GitHubAPI, type ListTransactionsOpts, Lizard, LizardCLI, LizardError, type LizardOpts, type LogLine, type MetricPoint, type MetricRange, MetricsAPI, type MouseButton, NotFoundError, PaymentRequiredError, type Plan, PlatformClient, type ProcessInfo, type ProcessOpts, type ProcessResult, type ProcessSignal, type Project, type ProjectConfig, type ProjectCost, ProjectsAPI, type PromoRedemption, type RawMetrics, type Region, RegionsAPI, type RunCodeLanguage, type RunCodeOpts, Sandbox, type SandboxInfo, type SandboxOpts, type SandboxSnapshot, type ScaleOpts, type ScrollDirection, type Secret, SecretsAPI, type Service, type ServiceMetrics, type ServiceUpdate, ServicesAPI, type SetSecretOpts, type SnapshotOpts, type SnapshotScope, type SnapshotWaitOpts, type StartCheckoutOpts, type StartProNowResult, StorageAPI, type StreamEvent, type Subscription, type SubscriptionStatus, TimeoutError, type Transaction, type TransactionPage, Volume, type VolumeInfo, type Workspace, WorkspacesAPI, resolveProjectId };
package/dist/index.js CHANGED
@@ -1291,7 +1291,7 @@ var Sandbox = class extends SandboxClient {
1291
1291
  * keeps running. `poolSize` applies to container sandboxes only.
1292
1292
  */
1293
1293
  snapshot(name = `Snapshot ${this.sandboxId}`, opts = {}) {
1294
- return new PlatformClient(this.resolveOpts()).post(`/api/sandboxes/${this.sandboxId}/snapshot`, { name, poolSize: opts.poolSize ?? 5 });
1294
+ return new PlatformClient(this.resolveOpts()).post(`/api/sandboxes/${this.sandboxId}/snapshot`, { name, poolSize: opts.poolSize ?? 5, scope: opts.scope });
1295
1295
  }
1296
1296
  unexpose(port) {
1297
1297
  return new PlatformClient(this.resolveOpts()).delete(`/api/sandboxes/${this.sandboxId}/expose/${port}`);
@@ -1303,21 +1303,32 @@ var Sandbox = class extends SandboxClient {
1303
1303
  static snapshots(projectId, opts) {
1304
1304
  return new PlatformClient(opts ?? {}).get(`/api/projects/${encodeURIComponent(projectId)}/snapshots`);
1305
1305
  }
1306
+ /** Every snapshot you took, across all your workspaces and projects. */
1307
+ static mySnapshots(opts) {
1308
+ return new PlatformClient(opts ?? {}).get("/api/sandbox-snapshots");
1309
+ }
1306
1310
  static getSnapshot(snapshotId, opts) {
1307
1311
  return new PlatformClient(opts ?? {}).get(`/api/sandbox-snapshots/${encodeURIComponent(snapshotId)}`);
1308
1312
  }
1309
- /** Start a new sandbox from a snapshot, in the snapshot's project and region. */
1313
+ /**
1314
+ * Start a new sandbox from a snapshot, in its region. `projectId` puts it in another project,
1315
+ * in any of your workspaces, as the snapshot's scope allows; default: the snapshot's own project.
1316
+ */
1310
1317
  static async restore(snapshotId, opts) {
1311
1318
  const client = new PlatformClient(opts ?? {});
1312
1319
  const snapshot = await this.getSnapshot(snapshotId, opts);
1313
1320
  const result = await client.post("/api/sandboxes", {
1314
1321
  snapshotId,
1315
- projectId: snapshot.projectId,
1322
+ projectId: opts?.projectId ?? snapshot.projectId,
1316
1323
  region: snapshot.region,
1317
1324
  timeoutMs: opts?.timeoutMs ?? DEFAULT_SANDBOX_TIMEOUT_MS
1318
1325
  });
1319
1326
  return new this({ ...opts, sandboxId: result.sandboxId ?? result.id });
1320
1327
  }
1328
+ /** Change where a snapshot you took may be restored. */
1329
+ static setSnapshotScope(snapshotId, scope, opts) {
1330
+ return new PlatformClient(opts ?? {}).patch(`/api/sandbox-snapshots/${encodeURIComponent(snapshotId)}`, { scope });
1331
+ }
1321
1332
  static setSnapshotWarmPool(snapshotId, poolSize, opts) {
1322
1333
  return new PlatformClient(opts ?? {}).patch(`/api/sandbox-snapshots/${encodeURIComponent(snapshotId)}`, { poolSize });
1323
1334
  }
package/dist/index.mjs CHANGED
@@ -1238,7 +1238,7 @@ var Sandbox = class extends SandboxClient {
1238
1238
  * keeps running. `poolSize` applies to container sandboxes only.
1239
1239
  */
1240
1240
  snapshot(name = `Snapshot ${this.sandboxId}`, opts = {}) {
1241
- return new PlatformClient(this.resolveOpts()).post(`/api/sandboxes/${this.sandboxId}/snapshot`, { name, poolSize: opts.poolSize ?? 5 });
1241
+ return new PlatformClient(this.resolveOpts()).post(`/api/sandboxes/${this.sandboxId}/snapshot`, { name, poolSize: opts.poolSize ?? 5, scope: opts.scope });
1242
1242
  }
1243
1243
  unexpose(port) {
1244
1244
  return new PlatformClient(this.resolveOpts()).delete(`/api/sandboxes/${this.sandboxId}/expose/${port}`);
@@ -1250,21 +1250,32 @@ var Sandbox = class extends SandboxClient {
1250
1250
  static snapshots(projectId, opts) {
1251
1251
  return new PlatformClient(opts ?? {}).get(`/api/projects/${encodeURIComponent(projectId)}/snapshots`);
1252
1252
  }
1253
+ /** Every snapshot you took, across all your workspaces and projects. */
1254
+ static mySnapshots(opts) {
1255
+ return new PlatformClient(opts ?? {}).get("/api/sandbox-snapshots");
1256
+ }
1253
1257
  static getSnapshot(snapshotId, opts) {
1254
1258
  return new PlatformClient(opts ?? {}).get(`/api/sandbox-snapshots/${encodeURIComponent(snapshotId)}`);
1255
1259
  }
1256
- /** Start a new sandbox from a snapshot, in the snapshot's project and region. */
1260
+ /**
1261
+ * Start a new sandbox from a snapshot, in its region. `projectId` puts it in another project,
1262
+ * in any of your workspaces, as the snapshot's scope allows; default: the snapshot's own project.
1263
+ */
1257
1264
  static async restore(snapshotId, opts) {
1258
1265
  const client = new PlatformClient(opts ?? {});
1259
1266
  const snapshot = await this.getSnapshot(snapshotId, opts);
1260
1267
  const result = await client.post("/api/sandboxes", {
1261
1268
  snapshotId,
1262
- projectId: snapshot.projectId,
1269
+ projectId: opts?.projectId ?? snapshot.projectId,
1263
1270
  region: snapshot.region,
1264
1271
  timeoutMs: opts?.timeoutMs ?? DEFAULT_SANDBOX_TIMEOUT_MS
1265
1272
  });
1266
1273
  return new this({ ...opts, sandboxId: result.sandboxId ?? result.id });
1267
1274
  }
1275
+ /** Change where a snapshot you took may be restored. */
1276
+ static setSnapshotScope(snapshotId, scope, opts) {
1277
+ return new PlatformClient(opts ?? {}).patch(`/api/sandbox-snapshots/${encodeURIComponent(snapshotId)}`, { scope });
1278
+ }
1268
1279
  static setSnapshotWarmPool(snapshotId, poolSize, opts) {
1269
1280
  return new PlatformClient(opts ?? {}).patch(`/api/sandbox-snapshots/${encodeURIComponent(snapshotId)}`, { poolSize });
1270
1281
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lizard-build/sdk",
3
- "version": "0.1.55",
3
+ "version": "0.1.57",
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",