@lizard-build/sdk 0.1.67 → 0.1.69
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 +44 -2
- package/dist/index.d.ts +44 -2
- package/dist/index.js +23 -2
- package/dist/index.mjs +22 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1401,6 +1401,7 @@ interface MetricPoint {
|
|
|
1401
1401
|
}
|
|
1402
1402
|
interface ServiceMetrics {
|
|
1403
1403
|
cpu: MetricPoint[];
|
|
1404
|
+
/** Working set: what the service holds, without the file cache the kernel frees on demand. */
|
|
1404
1405
|
memory: MetricPoint[];
|
|
1405
1406
|
networkRx: MetricPoint[];
|
|
1406
1407
|
networkTx: MetricPoint[];
|
|
@@ -1493,12 +1494,16 @@ interface WorkspaceLimits {
|
|
|
1493
1494
|
maxCpuVcpus: number | null;
|
|
1494
1495
|
/** Memory (MB) its apps and databases may be using right now (measured). */
|
|
1495
1496
|
maxMemoryMb: number | null;
|
|
1497
|
+
/** SSD (GB) its databases and volumes may hold (measured: data written, not sizes asked for). */
|
|
1498
|
+
maxDiskGb: number | null;
|
|
1496
1499
|
}
|
|
1497
1500
|
interface WorkspaceUsage {
|
|
1498
1501
|
runningSandboxes: number;
|
|
1499
1502
|
/** Measured, all regions, its apps and databases. */
|
|
1500
1503
|
cpuVcpus: number;
|
|
1501
1504
|
memoryMb: number;
|
|
1505
|
+
/** SSD (GB) its databases and volumes hold, last measurement of each. */
|
|
1506
|
+
diskGb: number;
|
|
1502
1507
|
/** Unix ms of the oldest reading in the sum; null when nothing was measured. */
|
|
1503
1508
|
measuredAt: number | null;
|
|
1504
1509
|
}
|
|
@@ -1586,9 +1591,12 @@ declare class WorkspacesAPI {
|
|
|
1586
1591
|
* not their configured limits). While at or over a cap, deploys, redeploys, restarts,
|
|
1587
1592
|
* scale-ups, new databases and resumes there fail with HTTP 429 `WORKSPACE_USAGE_LIMIT`;
|
|
1588
1593
|
* services already running keep running.
|
|
1594
|
+
* - `maxDiskGb`: the SSD its databases and volumes hold (measured, not their sizes). While at
|
|
1595
|
+
* or over it, new volumes, volume growth, new databases and template deploys fail with
|
|
1596
|
+
* HTTP 429 `WORKSPACE_USAGE_LIMIT`; data already written stays.
|
|
1589
1597
|
*
|
|
1590
1598
|
* ```ts
|
|
1591
|
-
* await lizard.workspaces.setLimits(ws.id, { maxRunningSandboxes: 5, maxCpuVcpus: 2, maxMemoryMb: 4096 })
|
|
1599
|
+
* await lizard.workspaces.setLimits(ws.id, { maxRunningSandboxes: 5, maxCpuVcpus: 2, maxMemoryMb: 4096, maxDiskGb: 20 })
|
|
1592
1600
|
* ```
|
|
1593
1601
|
*/
|
|
1594
1602
|
setLimits(id: string, limits: Partial<WorkspaceLimits>): Promise<WorkspaceLimitsInfo>;
|
|
@@ -2251,6 +2259,40 @@ declare class PaymentRequiredError extends LizardError {
|
|
|
2251
2259
|
/** The one page to open next for this {@link paymentStatus}. */
|
|
2252
2260
|
get url(): string | undefined;
|
|
2253
2261
|
}
|
|
2262
|
+
/**
|
|
2263
|
+
* A limit was reached (HTTP 429). {@link LizardError.code} says which:
|
|
2264
|
+
* - `SANDBOX_LIMIT_REACHED` / `SANDBOX_RATE_LIMITED`: the account's sandbox limits (running at
|
|
2265
|
+
* once, starts per minute/hour/day); {@link retryAfterS} says when to try again.
|
|
2266
|
+
* - `WORKSPACE_SANDBOX_LIMIT`: the workspace's own cap on running sandboxes
|
|
2267
|
+
* (`workspaces.setLimits`).
|
|
2268
|
+
* - `WORKSPACE_USAGE_LIMIT`: the workspace's apps and databases use as much CPU or memory as its
|
|
2269
|
+
* cap; {@link usage} and {@link limits} carry both.
|
|
2270
|
+
* Still a {@link LizardError}, so existing `catch` blocks keep working.
|
|
2271
|
+
*/
|
|
2272
|
+
declare class LimitExceededError extends LizardError {
|
|
2273
|
+
/** The limit that was reached (sandbox counts). */
|
|
2274
|
+
limit?: number;
|
|
2275
|
+
/** How many were running when it was refused. */
|
|
2276
|
+
running?: number;
|
|
2277
|
+
/** Seconds until a rate limit lets the next start through. */
|
|
2278
|
+
retryAfterS?: number;
|
|
2279
|
+
/** `WORKSPACE_USAGE_LIMIT`: the workspace's current use. */
|
|
2280
|
+
usage?: {
|
|
2281
|
+
runningSandboxes: number;
|
|
2282
|
+
cpuVcpus: number;
|
|
2283
|
+
memoryMb: number;
|
|
2284
|
+
diskGb?: number;
|
|
2285
|
+
measuredAt: number | null;
|
|
2286
|
+
};
|
|
2287
|
+
/** `WORKSPACE_USAGE_LIMIT`: the workspace's limits. */
|
|
2288
|
+
limits?: {
|
|
2289
|
+
maxRunningSandboxes: number | null;
|
|
2290
|
+
maxCpuVcpus: number | null;
|
|
2291
|
+
maxMemoryMb: number | null;
|
|
2292
|
+
maxDiskGb?: number | null;
|
|
2293
|
+
};
|
|
2294
|
+
constructor(message?: string);
|
|
2295
|
+
}
|
|
2254
2296
|
|
|
2255
2297
|
/** A single output item produced during code execution. */
|
|
2256
2298
|
type OutputItem = {
|
|
@@ -2426,4 +2468,4 @@ declare class LizardCLI {
|
|
|
2426
2468
|
}): Promise<CLIResult>;
|
|
2427
2469
|
}
|
|
2428
2470
|
|
|
2429
|
-
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 ResaleMultipliers, type ResalePricing, 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, type WorkspaceLimits, type WorkspaceLimitsInfo, type WorkspaceUsage, WorkspacesAPI, resolveProjectId };
|
|
2471
|
+
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, LimitExceededError, 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 ResaleMultipliers, type ResalePricing, 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, type WorkspaceLimits, type WorkspaceLimitsInfo, type WorkspaceUsage, WorkspacesAPI, resolveProjectId };
|
package/dist/index.d.ts
CHANGED
|
@@ -1401,6 +1401,7 @@ interface MetricPoint {
|
|
|
1401
1401
|
}
|
|
1402
1402
|
interface ServiceMetrics {
|
|
1403
1403
|
cpu: MetricPoint[];
|
|
1404
|
+
/** Working set: what the service holds, without the file cache the kernel frees on demand. */
|
|
1404
1405
|
memory: MetricPoint[];
|
|
1405
1406
|
networkRx: MetricPoint[];
|
|
1406
1407
|
networkTx: MetricPoint[];
|
|
@@ -1493,12 +1494,16 @@ interface WorkspaceLimits {
|
|
|
1493
1494
|
maxCpuVcpus: number | null;
|
|
1494
1495
|
/** Memory (MB) its apps and databases may be using right now (measured). */
|
|
1495
1496
|
maxMemoryMb: number | null;
|
|
1497
|
+
/** SSD (GB) its databases and volumes may hold (measured: data written, not sizes asked for). */
|
|
1498
|
+
maxDiskGb: number | null;
|
|
1496
1499
|
}
|
|
1497
1500
|
interface WorkspaceUsage {
|
|
1498
1501
|
runningSandboxes: number;
|
|
1499
1502
|
/** Measured, all regions, its apps and databases. */
|
|
1500
1503
|
cpuVcpus: number;
|
|
1501
1504
|
memoryMb: number;
|
|
1505
|
+
/** SSD (GB) its databases and volumes hold, last measurement of each. */
|
|
1506
|
+
diskGb: number;
|
|
1502
1507
|
/** Unix ms of the oldest reading in the sum; null when nothing was measured. */
|
|
1503
1508
|
measuredAt: number | null;
|
|
1504
1509
|
}
|
|
@@ -1586,9 +1591,12 @@ declare class WorkspacesAPI {
|
|
|
1586
1591
|
* not their configured limits). While at or over a cap, deploys, redeploys, restarts,
|
|
1587
1592
|
* scale-ups, new databases and resumes there fail with HTTP 429 `WORKSPACE_USAGE_LIMIT`;
|
|
1588
1593
|
* services already running keep running.
|
|
1594
|
+
* - `maxDiskGb`: the SSD its databases and volumes hold (measured, not their sizes). While at
|
|
1595
|
+
* or over it, new volumes, volume growth, new databases and template deploys fail with
|
|
1596
|
+
* HTTP 429 `WORKSPACE_USAGE_LIMIT`; data already written stays.
|
|
1589
1597
|
*
|
|
1590
1598
|
* ```ts
|
|
1591
|
-
* await lizard.workspaces.setLimits(ws.id, { maxRunningSandboxes: 5, maxCpuVcpus: 2, maxMemoryMb: 4096 })
|
|
1599
|
+
* await lizard.workspaces.setLimits(ws.id, { maxRunningSandboxes: 5, maxCpuVcpus: 2, maxMemoryMb: 4096, maxDiskGb: 20 })
|
|
1592
1600
|
* ```
|
|
1593
1601
|
*/
|
|
1594
1602
|
setLimits(id: string, limits: Partial<WorkspaceLimits>): Promise<WorkspaceLimitsInfo>;
|
|
@@ -2251,6 +2259,40 @@ declare class PaymentRequiredError extends LizardError {
|
|
|
2251
2259
|
/** The one page to open next for this {@link paymentStatus}. */
|
|
2252
2260
|
get url(): string | undefined;
|
|
2253
2261
|
}
|
|
2262
|
+
/**
|
|
2263
|
+
* A limit was reached (HTTP 429). {@link LizardError.code} says which:
|
|
2264
|
+
* - `SANDBOX_LIMIT_REACHED` / `SANDBOX_RATE_LIMITED`: the account's sandbox limits (running at
|
|
2265
|
+
* once, starts per minute/hour/day); {@link retryAfterS} says when to try again.
|
|
2266
|
+
* - `WORKSPACE_SANDBOX_LIMIT`: the workspace's own cap on running sandboxes
|
|
2267
|
+
* (`workspaces.setLimits`).
|
|
2268
|
+
* - `WORKSPACE_USAGE_LIMIT`: the workspace's apps and databases use as much CPU or memory as its
|
|
2269
|
+
* cap; {@link usage} and {@link limits} carry both.
|
|
2270
|
+
* Still a {@link LizardError}, so existing `catch` blocks keep working.
|
|
2271
|
+
*/
|
|
2272
|
+
declare class LimitExceededError extends LizardError {
|
|
2273
|
+
/** The limit that was reached (sandbox counts). */
|
|
2274
|
+
limit?: number;
|
|
2275
|
+
/** How many were running when it was refused. */
|
|
2276
|
+
running?: number;
|
|
2277
|
+
/** Seconds until a rate limit lets the next start through. */
|
|
2278
|
+
retryAfterS?: number;
|
|
2279
|
+
/** `WORKSPACE_USAGE_LIMIT`: the workspace's current use. */
|
|
2280
|
+
usage?: {
|
|
2281
|
+
runningSandboxes: number;
|
|
2282
|
+
cpuVcpus: number;
|
|
2283
|
+
memoryMb: number;
|
|
2284
|
+
diskGb?: number;
|
|
2285
|
+
measuredAt: number | null;
|
|
2286
|
+
};
|
|
2287
|
+
/** `WORKSPACE_USAGE_LIMIT`: the workspace's limits. */
|
|
2288
|
+
limits?: {
|
|
2289
|
+
maxRunningSandboxes: number | null;
|
|
2290
|
+
maxCpuVcpus: number | null;
|
|
2291
|
+
maxMemoryMb: number | null;
|
|
2292
|
+
maxDiskGb?: number | null;
|
|
2293
|
+
};
|
|
2294
|
+
constructor(message?: string);
|
|
2295
|
+
}
|
|
2254
2296
|
|
|
2255
2297
|
/** A single output item produced during code execution. */
|
|
2256
2298
|
type OutputItem = {
|
|
@@ -2426,4 +2468,4 @@ declare class LizardCLI {
|
|
|
2426
2468
|
}): Promise<CLIResult>;
|
|
2427
2469
|
}
|
|
2428
2470
|
|
|
2429
|
-
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 ResaleMultipliers, type ResalePricing, 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, type WorkspaceLimits, type WorkspaceLimitsInfo, type WorkspaceUsage, WorkspacesAPI, resolveProjectId };
|
|
2471
|
+
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, LimitExceededError, 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 ResaleMultipliers, type ResalePricing, 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, type WorkspaceLimits, type WorkspaceLimitsInfo, type WorkspaceUsage, WorkspacesAPI, resolveProjectId };
|
package/dist/index.js
CHANGED
|
@@ -31,6 +31,7 @@ __export(index_exports, {
|
|
|
31
31
|
Desktop: () => Desktop,
|
|
32
32
|
DomainsAPI: () => DomainsAPI,
|
|
33
33
|
GitHubAPI: () => GitHubAPI,
|
|
34
|
+
LimitExceededError: () => LimitExceededError,
|
|
34
35
|
Lizard: () => Lizard,
|
|
35
36
|
LizardCLI: () => LizardCLI,
|
|
36
37
|
LizardError: () => LizardError,
|
|
@@ -126,6 +127,12 @@ var PaymentRequiredError = class extends LizardError {
|
|
|
126
127
|
return this.billingUrl ?? this.subscribeUrl ?? this.topupUrl;
|
|
127
128
|
}
|
|
128
129
|
};
|
|
130
|
+
var LimitExceededError = class extends LizardError {
|
|
131
|
+
constructor(message = "Limit reached") {
|
|
132
|
+
super(message);
|
|
133
|
+
this.name = "LimitExceededError";
|
|
134
|
+
}
|
|
135
|
+
};
|
|
129
136
|
var PREPAID_STATUSES = /* @__PURE__ */ new Set(["grace", "frozen", "card_required", "credits_required"]);
|
|
130
137
|
var ERROR_CODE = /^[A-Z][A-Z0-9_]*$/;
|
|
131
138
|
async function handleApiError(res) {
|
|
@@ -153,7 +160,17 @@ async function handleApiError(res) {
|
|
|
153
160
|
else if (res.status === 404) err = new NotFoundError(message);
|
|
154
161
|
else if (res.status === 409) err = new ConflictError(message);
|
|
155
162
|
else if (res.status === 408 || res.status === 504) err = new TimeoutError(message);
|
|
156
|
-
else
|
|
163
|
+
else if (res.status === 429) {
|
|
164
|
+
const limited = new LimitExceededError(message);
|
|
165
|
+
const n = (key) => typeof body[key] === "number" ? body[key] : void 0;
|
|
166
|
+
limited.limit = n("limit");
|
|
167
|
+
limited.running = n("running");
|
|
168
|
+
const retry = n("retryAfterS") ?? (Number(res.headers?.get?.("retry-after")) || void 0);
|
|
169
|
+
limited.retryAfterS = retry;
|
|
170
|
+
if (body.usage && typeof body.usage === "object") limited.usage = body.usage;
|
|
171
|
+
if (body.limits && typeof body.limits === "object") limited.limits = body.limits;
|
|
172
|
+
err = limited;
|
|
173
|
+
} else err = new LizardError(`API error ${res.status}: ${message}`);
|
|
157
174
|
err.status = res.status;
|
|
158
175
|
err.code = code;
|
|
159
176
|
throw err;
|
|
@@ -1769,9 +1786,12 @@ var WorkspacesAPI = class {
|
|
|
1769
1786
|
* not their configured limits). While at or over a cap, deploys, redeploys, restarts,
|
|
1770
1787
|
* scale-ups, new databases and resumes there fail with HTTP 429 `WORKSPACE_USAGE_LIMIT`;
|
|
1771
1788
|
* services already running keep running.
|
|
1789
|
+
* - `maxDiskGb`: the SSD its databases and volumes hold (measured, not their sizes). While at
|
|
1790
|
+
* or over it, new volumes, volume growth, new databases and template deploys fail with
|
|
1791
|
+
* HTTP 429 `WORKSPACE_USAGE_LIMIT`; data already written stays.
|
|
1772
1792
|
*
|
|
1773
1793
|
* ```ts
|
|
1774
|
-
* await lizard.workspaces.setLimits(ws.id, { maxRunningSandboxes: 5, maxCpuVcpus: 2, maxMemoryMb: 4096 })
|
|
1794
|
+
* await lizard.workspaces.setLimits(ws.id, { maxRunningSandboxes: 5, maxCpuVcpus: 2, maxMemoryMb: 4096, maxDiskGb: 20 })
|
|
1775
1795
|
* ```
|
|
1776
1796
|
*/
|
|
1777
1797
|
setLimits(id, limits) {
|
|
@@ -2689,6 +2709,7 @@ var LizardCLI = class {
|
|
|
2689
2709
|
Desktop,
|
|
2690
2710
|
DomainsAPI,
|
|
2691
2711
|
GitHubAPI,
|
|
2712
|
+
LimitExceededError,
|
|
2692
2713
|
Lizard,
|
|
2693
2714
|
LizardCLI,
|
|
2694
2715
|
LizardError,
|
package/dist/index.mjs
CHANGED
|
@@ -73,6 +73,12 @@ var PaymentRequiredError = class extends LizardError {
|
|
|
73
73
|
return this.billingUrl ?? this.subscribeUrl ?? this.topupUrl;
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
|
+
var LimitExceededError = class extends LizardError {
|
|
77
|
+
constructor(message = "Limit reached") {
|
|
78
|
+
super(message);
|
|
79
|
+
this.name = "LimitExceededError";
|
|
80
|
+
}
|
|
81
|
+
};
|
|
76
82
|
var PREPAID_STATUSES = /* @__PURE__ */ new Set(["grace", "frozen", "card_required", "credits_required"]);
|
|
77
83
|
var ERROR_CODE = /^[A-Z][A-Z0-9_]*$/;
|
|
78
84
|
async function handleApiError(res) {
|
|
@@ -100,7 +106,17 @@ async function handleApiError(res) {
|
|
|
100
106
|
else if (res.status === 404) err = new NotFoundError(message);
|
|
101
107
|
else if (res.status === 409) err = new ConflictError(message);
|
|
102
108
|
else if (res.status === 408 || res.status === 504) err = new TimeoutError(message);
|
|
103
|
-
else
|
|
109
|
+
else if (res.status === 429) {
|
|
110
|
+
const limited = new LimitExceededError(message);
|
|
111
|
+
const n = (key) => typeof body[key] === "number" ? body[key] : void 0;
|
|
112
|
+
limited.limit = n("limit");
|
|
113
|
+
limited.running = n("running");
|
|
114
|
+
const retry = n("retryAfterS") ?? (Number(res.headers?.get?.("retry-after")) || void 0);
|
|
115
|
+
limited.retryAfterS = retry;
|
|
116
|
+
if (body.usage && typeof body.usage === "object") limited.usage = body.usage;
|
|
117
|
+
if (body.limits && typeof body.limits === "object") limited.limits = body.limits;
|
|
118
|
+
err = limited;
|
|
119
|
+
} else err = new LizardError(`API error ${res.status}: ${message}`);
|
|
104
120
|
err.status = res.status;
|
|
105
121
|
err.code = code;
|
|
106
122
|
throw err;
|
|
@@ -1716,9 +1732,12 @@ var WorkspacesAPI = class {
|
|
|
1716
1732
|
* not their configured limits). While at or over a cap, deploys, redeploys, restarts,
|
|
1717
1733
|
* scale-ups, new databases and resumes there fail with HTTP 429 `WORKSPACE_USAGE_LIMIT`;
|
|
1718
1734
|
* services already running keep running.
|
|
1735
|
+
* - `maxDiskGb`: the SSD its databases and volumes hold (measured, not their sizes). While at
|
|
1736
|
+
* or over it, new volumes, volume growth, new databases and template deploys fail with
|
|
1737
|
+
* HTTP 429 `WORKSPACE_USAGE_LIMIT`; data already written stays.
|
|
1719
1738
|
*
|
|
1720
1739
|
* ```ts
|
|
1721
|
-
* await lizard.workspaces.setLimits(ws.id, { maxRunningSandboxes: 5, maxCpuVcpus: 2, maxMemoryMb: 4096 })
|
|
1740
|
+
* await lizard.workspaces.setLimits(ws.id, { maxRunningSandboxes: 5, maxCpuVcpus: 2, maxMemoryMb: 4096, maxDiskGb: 20 })
|
|
1722
1741
|
* ```
|
|
1723
1742
|
*/
|
|
1724
1743
|
setLimits(id, limits) {
|
|
@@ -2635,6 +2654,7 @@ export {
|
|
|
2635
2654
|
Desktop,
|
|
2636
2655
|
DomainsAPI,
|
|
2637
2656
|
GitHubAPI,
|
|
2657
|
+
LimitExceededError,
|
|
2638
2658
|
Lizard,
|
|
2639
2659
|
LizardCLI,
|
|
2640
2660
|
LizardError,
|
package/package.json
CHANGED