@declaw/sdk 1.0.4 → 1.1.1

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/CHANGELOG.md CHANGED
@@ -5,6 +5,49 @@ All notable changes to the Declaw TypeScript / JavaScript SDK are documented in
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.1.1]
9
+
10
+ ### Changed
11
+
12
+ - **Process-wide HTTP client cache.** `Sandbox.create` / `.connect` /
13
+ `.list`, `Volumes.*`, and `Template.*` now share a single `ApiClient`
14
+ per `(apiKey, apiUrl, requestTimeout)` via the new `getSharedClient`
15
+ helper instead of constructing a fresh instance per call. Matches the
16
+ symmetry added on the Python side and removes unnecessary
17
+ `AbortController` churn. Node's global fetch / undici dispatcher was
18
+ already pooling TCP + TLS under the hood, so end-to-end latency is
19
+ unchanged for most callers — the user-visible win is that
20
+ `close()` on a returned `Sandbox` is now a no-op rather than
21
+ aborting an in-flight request on the shared client.
22
+ - New exports from the package root: `getSharedClient`,
23
+ `resetSharedClients`. Use `resetSharedClients()` from tests or
24
+ long-running services that want to force a full teardown.
25
+ - `Sandbox.close()` is now a no-op. `Sandbox.kill()` still kills the
26
+ VM and is unchanged.
27
+
28
+ ## [1.1.0]
29
+
30
+ ### Added
31
+
32
+ - **Volumes API.** Upload a tarball once, attach it to one or many
33
+ sandboxes at create time. The server streams the blob from object
34
+ storage into each sandbox's overlay filesystem at boot — so N
35
+ parallel sandboxes share a dataset without N uploads.
36
+ - New `Volumes` class with static `create` / `get` / `list` /
37
+ `delete` methods. Body is a `Uint8Array` or `ArrayBuffer`;
38
+ streams end-to-end with no in-memory buffering on the server.
39
+ - New types: `VolumeInfo`, `VolumeAttachment`, `VolumeCreateOpts`,
40
+ `VolumeRequestOpts` — exported from the package root.
41
+ - `SandboxOpts.volumes?: VolumeAttachment[]` on `Sandbox.create` —
42
+ each attachment is `{ volumeId, mountPath }`. Multiple sandboxes
43
+ can attach the same `volumeId` in parallel.
44
+ - Helper functions `parseVolumeInfo` (wire → shape) and
45
+ `volumeAttachmentToJSON` (shape → wire).
46
+ - Phase 1 limits: upload body capped at 4 GiB; format must be
47
+ `application/gzip` (tar.gz); volumes are read-at-boot (sandbox
48
+ writes do not flow back). Symlinks, hardlinks, device nodes, and
49
+ entries containing `..` are dropped server-side for safety.
50
+
8
51
  ## [1.0.4]
9
52
 
10
53
  ### Changed
package/dist/index.cjs CHANGED
@@ -54,6 +54,7 @@ __export(index_exports, {
54
54
  TemplateError: () => TemplateError,
55
55
  TimeoutError: () => TimeoutError,
56
56
  TransformDirection: () => TransformDirection,
57
+ Volumes: () => Volumes,
57
58
  WatchHandle: () => WatchHandle,
58
59
  applyTransformation: () => applyTransformation,
59
60
  codeSecurityConfigToJSON: () => codeSecurityConfigToJSON,
@@ -68,6 +69,7 @@ __export(index_exports, {
68
69
  createToxicityConfig: () => createToxicityConfig,
69
70
  createTransformationRule: () => createTransformationRule,
70
71
  domainMatches: () => domainMatches,
72
+ getSharedClient: () => getSharedClient,
71
73
  invisibleTextConfigToJSON: () => invisibleTextConfigToJSON,
72
74
  isSensitive: () => isSensitive,
73
75
  networkPolicyToOpts: () => networkPolicyToOpts,
@@ -92,11 +94,14 @@ __export(index_exports, {
92
94
  parseSnapshotInfo: () => parseSnapshotInfo,
93
95
  parseTemplateBuildStatus: () => parseTemplateBuildStatus,
94
96
  parseToxicityConfig: () => parseToxicityConfig,
97
+ parseVolumeInfo: () => parseVolumeInfo,
95
98
  parseWriteInfo: () => parseWriteInfo,
96
99
  requiresTlsInterception: () => requiresTlsInterception,
100
+ resetSharedClients: () => resetSharedClients,
97
101
  securityPolicyToJSON: () => securityPolicyToJSON,
98
102
  toxicityConfigToJSON: () => toxicityConfigToJSON,
99
- validateNetworkEntry: () => validateNetworkEntry
103
+ validateNetworkEntry: () => validateNetworkEntry,
104
+ volumeAttachmentToJSON: () => volumeAttachmentToJSON
100
105
  });
101
106
  module.exports = __toCommonJS(index_exports);
102
107
 
@@ -273,6 +278,12 @@ var ApiClient = class {
273
278
  }
274
279
  /**
275
280
  * Abort all in-flight requests and release resources.
281
+ *
282
+ * Since 1.1.1 the SDK maintains a process-wide shared ApiClient cache
283
+ * for hot class-method paths (Sandbox.create, Volumes.*, Template.*).
284
+ * Calling `close()` on a shared instance aborts its AbortController,
285
+ * which would cancel any concurrent in-flight call. Prefer
286
+ * `resetSharedClients()` if you want to tear down every cached client.
276
287
  */
277
288
  close() {
278
289
  this.abortController.abort();
@@ -392,6 +403,28 @@ var ApiClient = class {
392
403
  await new Promise((resolve) => setTimeout(resolve, ms));
393
404
  }
394
405
  };
406
+ var _sharedClients = /* @__PURE__ */ new Map();
407
+ function sharedKey(config) {
408
+ return [config.apiKey ?? "", config.apiUrl, config.requestTimeout ?? ""].join("|");
409
+ }
410
+ function getSharedClient(config) {
411
+ const key = sharedKey(config);
412
+ let client = _sharedClients.get(key);
413
+ if (!client) {
414
+ client = new ApiClient(config);
415
+ _sharedClients.set(key, client);
416
+ }
417
+ return client;
418
+ }
419
+ function resetSharedClients() {
420
+ for (const client of _sharedClients.values()) {
421
+ try {
422
+ client.close();
423
+ } catch {
424
+ }
425
+ }
426
+ _sharedClients.clear();
427
+ }
395
428
 
396
429
  // src/sandbox/network.ts
397
430
  var ALL_TRAFFIC = "0.0.0.0/0";
@@ -1795,6 +1828,23 @@ var Pty = class {
1795
1828
  }
1796
1829
  };
1797
1830
 
1831
+ // src/volumes/models.ts
1832
+ function parseVolumeInfo(data) {
1833
+ return {
1834
+ volumeId: String(data.volume_id ?? ""),
1835
+ ownerId: String(data.owner_id ?? ""),
1836
+ name: String(data.name ?? ""),
1837
+ blobKey: String(data.blob_key ?? ""),
1838
+ sizeBytes: Number(data.size_bytes ?? 0),
1839
+ contentType: String(data.content_type ?? ""),
1840
+ metadata: data.metadata ?? {},
1841
+ createdAt: String(data.created_at ?? "")
1842
+ };
1843
+ }
1844
+ function volumeAttachmentToJSON(att) {
1845
+ return { volume_id: att.volumeId, mount_path: att.mountPath };
1846
+ }
1847
+
1798
1848
  // src/sandbox/sandbox.ts
1799
1849
  var DEFAULT_TEMPLATE = "base";
1800
1850
  var DEFAULT_TIMEOUT = 300;
@@ -1924,51 +1974,49 @@ var Sandbox = class _Sandbox {
1924
1974
  apiUrl: opts?.apiUrl,
1925
1975
  requestTimeout: opts?.requestTimeout
1926
1976
  });
1927
- const client = new ApiClient(config);
1928
- try {
1929
- const body = {
1930
- template: opts?.template ?? DEFAULT_TEMPLATE,
1931
- timeout: opts?.timeout ?? DEFAULT_TIMEOUT,
1932
- secure: opts?.secure ?? true
1933
- };
1934
- if (opts?.metadata) {
1935
- body.metadata = opts.metadata;
1936
- }
1937
- if (opts?.envs) {
1938
- body.envs = opts.envs;
1939
- }
1940
- if (opts?.network) {
1941
- body.network = networkOptsToJSON(opts.network);
1942
- } else if (opts?.allowInternetAccess === false) {
1943
- body.network = { deny_out: [ALL_TRAFFIC] };
1944
- }
1945
- if (opts?.security) {
1946
- body.security = { policy_json: JSON.stringify(securityPolicyToJSON(opts.security)) };
1947
- if (opts.security.network && !body.network) {
1948
- body.network = typeof opts.security.network === "object" && "allowOut" in opts.security.network ? networkOptsToJSON(opts.security.network) : opts.security.network;
1949
- }
1950
- }
1951
- if (opts?.lifecycle) {
1952
- body.lifecycle = lifecycleToJSON(opts.lifecycle);
1977
+ const client = getSharedClient(config);
1978
+ const body = {
1979
+ template: opts?.template ?? DEFAULT_TEMPLATE,
1980
+ timeout: opts?.timeout ?? DEFAULT_TIMEOUT,
1981
+ secure: opts?.secure ?? true
1982
+ };
1983
+ if (opts?.metadata) {
1984
+ body.metadata = opts.metadata;
1985
+ }
1986
+ if (opts?.envs) {
1987
+ body.envs = opts.envs;
1988
+ }
1989
+ if (opts?.network) {
1990
+ body.network = networkOptsToJSON(opts.network);
1991
+ } else if (opts?.allowInternetAccess === false) {
1992
+ body.network = { deny_out: [ALL_TRAFFIC] };
1993
+ }
1994
+ if (opts?.security) {
1995
+ body.security = { policy_json: JSON.stringify(securityPolicyToJSON(opts.security)) };
1996
+ if (opts.security.network && !body.network) {
1997
+ body.network = typeof opts.security.network === "object" && "allowOut" in opts.security.network ? networkOptsToJSON(opts.security.network) : opts.security.network;
1953
1998
  }
1954
- const data = await client.post("/sandboxes", {
1955
- json: body,
1956
- timeout: opts?.requestTimeout
1957
- });
1958
- const sandboxId = data.sandbox_id;
1959
- assertValidId(sandboxId, "sandbox ID (from server)");
1960
- return new _Sandbox(
1961
- sandboxId,
1962
- config,
1963
- client,
1964
- data.envd_access_token,
1965
- data.sandbox_domain,
1966
- data.traffic_access_token
1967
- );
1968
- } catch (error) {
1969
- client.close();
1970
- throw error;
1971
1999
  }
2000
+ if (opts?.lifecycle) {
2001
+ body.lifecycle = lifecycleToJSON(opts.lifecycle);
2002
+ }
2003
+ if (opts?.volumes && opts.volumes.length > 0) {
2004
+ body.volumes = opts.volumes.map(volumeAttachmentToJSON);
2005
+ }
2006
+ const data = await client.post("/sandboxes", {
2007
+ json: body,
2008
+ timeout: opts?.requestTimeout
2009
+ });
2010
+ const sandboxId = data.sandbox_id;
2011
+ assertValidId(sandboxId, "sandbox ID (from server)");
2012
+ return new _Sandbox(
2013
+ sandboxId,
2014
+ config,
2015
+ client,
2016
+ data.envd_access_token,
2017
+ data.sandbox_domain,
2018
+ data.traffic_access_token
2019
+ );
1972
2020
  }
1973
2021
  /**
1974
2022
  * Connect to an existing sandbox.
@@ -1985,23 +2033,18 @@ var Sandbox = class _Sandbox {
1985
2033
  apiUrl: opts?.apiUrl,
1986
2034
  requestTimeout: opts?.requestTimeout
1987
2035
  });
1988
- const client = new ApiClient(config);
1989
- try {
1990
- const data = await client.get(`/sandboxes/${sandboxId}`, {
1991
- timeout: opts?.requestTimeout
1992
- });
1993
- return new _Sandbox(
1994
- data.sandbox_id,
1995
- config,
1996
- client,
1997
- data.envd_access_token,
1998
- data.sandbox_domain,
1999
- data.traffic_access_token
2000
- );
2001
- } catch (error) {
2002
- client.close();
2003
- throw error;
2004
- }
2036
+ const client = getSharedClient(config);
2037
+ const data = await client.get(`/sandboxes/${sandboxId}`, {
2038
+ timeout: opts?.requestTimeout
2039
+ });
2040
+ return new _Sandbox(
2041
+ data.sandbox_id,
2042
+ config,
2043
+ client,
2044
+ data.envd_access_token,
2045
+ data.sandbox_domain,
2046
+ data.traffic_access_token
2047
+ );
2005
2048
  }
2006
2049
  /**
2007
2050
  * List sandboxes.
@@ -2018,35 +2061,31 @@ var Sandbox = class _Sandbox {
2018
2061
  apiUrl: opts?.apiUrl,
2019
2062
  requestTimeout: opts?.requestTimeout
2020
2063
  });
2021
- const client = new ApiClient(config);
2022
- try {
2023
- const params = {};
2024
- if (opts?.query) {
2025
- for (const [key, value] of Object.entries(opts.query)) {
2026
- params[key] = value;
2027
- }
2028
- }
2029
- if (opts?.limit !== void 0) {
2030
- params.limit = String(opts.limit);
2031
- }
2032
- if (opts?.nextToken) {
2033
- params.next_token = opts.nextToken;
2064
+ const client = getSharedClient(config);
2065
+ const params = {};
2066
+ if (opts?.query) {
2067
+ for (const [key, value] of Object.entries(opts.query)) {
2068
+ params[key] = value;
2034
2069
  }
2035
- const data = await client.get("/sandboxes", {
2036
- params,
2037
- timeout: opts?.requestTimeout
2038
- });
2039
- const rawSandboxes = data.sandboxes ?? [];
2040
- const sandboxes = rawSandboxes.map(
2041
- (s) => parseSandboxInfo(s)
2042
- );
2043
- return {
2044
- sandboxes,
2045
- nextToken: data.next_token ?? void 0
2046
- };
2047
- } finally {
2048
- client.close();
2049
2070
  }
2071
+ if (opts?.limit !== void 0) {
2072
+ params.limit = String(opts.limit);
2073
+ }
2074
+ if (opts?.nextToken) {
2075
+ params.next_token = opts.nextToken;
2076
+ }
2077
+ const data = await client.get("/sandboxes", {
2078
+ params,
2079
+ timeout: opts?.requestTimeout
2080
+ });
2081
+ const rawSandboxes = data.sandboxes ?? [];
2082
+ const sandboxes = rawSandboxes.map(
2083
+ (s) => parseSandboxInfo(s)
2084
+ );
2085
+ return {
2086
+ sandboxes,
2087
+ nextToken: data.next_token ?? void 0
2088
+ };
2050
2089
  }
2051
2090
  /**
2052
2091
  * Kill this sandbox.
@@ -2198,33 +2237,31 @@ var Sandbox = class _Sandbox {
2198
2237
  apiUrl: options.apiUrl,
2199
2238
  requestTimeout: options.requestTimeout
2200
2239
  });
2201
- const client = new ApiClient(config);
2202
- try {
2203
- const query = options.snapshotId ? `?snapshot_id=${encodeURIComponent(options.snapshotId)}` : "";
2204
- await client.post(`/sandboxes/${sandboxId}/restore${query}`, {
2205
- timeout: options.requestTimeout
2206
- });
2207
- const data = await client.get(`/sandboxes/${sandboxId}`, {
2208
- timeout: options.requestTimeout
2209
- });
2210
- return new _Sandbox(
2211
- data.sandbox_id,
2212
- config,
2213
- client,
2214
- data.envd_access_token,
2215
- data.sandbox_domain,
2216
- data.traffic_access_token
2217
- );
2218
- } catch (error) {
2219
- client.close();
2220
- throw error;
2221
- }
2240
+ const client = getSharedClient(config);
2241
+ const query = options.snapshotId ? `?snapshot_id=${encodeURIComponent(options.snapshotId)}` : "";
2242
+ await client.post(`/sandboxes/${sandboxId}/restore${query}`, {
2243
+ timeout: options.requestTimeout
2244
+ });
2245
+ const data = await client.get(`/sandboxes/${sandboxId}`, {
2246
+ timeout: options.requestTimeout
2247
+ });
2248
+ return new _Sandbox(
2249
+ data.sandbox_id,
2250
+ config,
2251
+ client,
2252
+ data.envd_access_token,
2253
+ data.sandbox_domain,
2254
+ data.traffic_access_token
2255
+ );
2222
2256
  }
2223
2257
  /**
2224
- * Close the underlying HTTP client and release resources.
2258
+ * Historically closed the sandbox's HTTP client; since 1.1.1 the SDK
2259
+ * maintains a process-wide shared ApiClient (see `getSharedClient` in
2260
+ * api/client.ts) so per-sandbox close no longer tears the connection
2261
+ * pool down. Kept as a no-op for backwards compatibility — call
2262
+ * `resetSharedClients()` if you want to force a full teardown.
2225
2263
  */
2226
2264
  close() {
2227
- this._client.close();
2228
2265
  }
2229
2266
  /**
2230
2267
  * Support `await using sandbox = await Sandbox.create(...)` for automatic cleanup.
@@ -2454,36 +2491,32 @@ var Template = class {
2454
2491
  domain: opts?.domain,
2455
2492
  requestTimeout: opts?.requestTimeout
2456
2493
  });
2457
- const client = new ApiClient(config);
2458
- try {
2459
- const body = {
2460
- template: template.toJSON(),
2461
- alias
2462
- };
2463
- if (opts?.cpuCount !== void 0) {
2464
- body.cpu_count = opts.cpuCount;
2465
- }
2466
- if (opts?.memoryMb !== void 0) {
2467
- body.memory_mb = opts.memoryMb;
2468
- }
2469
- if (opts?.diskMb !== void 0) {
2470
- body.disk_mb = opts.diskMb;
2471
- }
2472
- const data = await client.post("/templates/build", {
2473
- json: body,
2474
- timeout: opts?.requestTimeout
2475
- });
2476
- const response = data;
2477
- const result = parseBuildInfo(response);
2478
- if (opts?.onBuildLogs && Array.isArray(response.logs)) {
2479
- for (const log of response.logs) {
2480
- opts.onBuildLogs(log);
2481
- }
2494
+ const client = getSharedClient(config);
2495
+ const body = {
2496
+ template: template.toJSON(),
2497
+ alias
2498
+ };
2499
+ if (opts?.cpuCount !== void 0) {
2500
+ body.cpu_count = opts.cpuCount;
2501
+ }
2502
+ if (opts?.memoryMb !== void 0) {
2503
+ body.memory_mb = opts.memoryMb;
2504
+ }
2505
+ if (opts?.diskMb !== void 0) {
2506
+ body.disk_mb = opts.diskMb;
2507
+ }
2508
+ const data = await client.post("/templates/build", {
2509
+ json: body,
2510
+ timeout: opts?.requestTimeout
2511
+ });
2512
+ const response = data;
2513
+ const result = parseBuildInfo(response);
2514
+ if (opts?.onBuildLogs && Array.isArray(response.logs)) {
2515
+ for (const log of response.logs) {
2516
+ opts.onBuildLogs(log);
2482
2517
  }
2483
- return result;
2484
- } finally {
2485
- client.close();
2486
2518
  }
2519
+ return result;
2487
2520
  }
2488
2521
  /**
2489
2522
  * Start a template build in the background.
@@ -2496,30 +2529,26 @@ var Template = class {
2496
2529
  domain: opts?.domain,
2497
2530
  requestTimeout: opts?.requestTimeout
2498
2531
  });
2499
- const client = new ApiClient(config);
2500
- try {
2501
- const body = {
2502
- template: template.toJSON(),
2503
- alias,
2504
- background: true
2505
- };
2506
- if (opts?.cpuCount !== void 0) {
2507
- body.cpu_count = opts.cpuCount;
2508
- }
2509
- if (opts?.memoryMb !== void 0) {
2510
- body.memory_mb = opts.memoryMb;
2511
- }
2512
- if (opts?.diskMb !== void 0) {
2513
- body.disk_mb = opts.diskMb;
2514
- }
2515
- const data = await client.post("/templates/build", {
2516
- json: body,
2517
- timeout: opts?.requestTimeout
2518
- });
2519
- return parseBuildInfo(data);
2520
- } finally {
2521
- client.close();
2532
+ const client = getSharedClient(config);
2533
+ const body = {
2534
+ template: template.toJSON(),
2535
+ alias,
2536
+ background: true
2537
+ };
2538
+ if (opts?.cpuCount !== void 0) {
2539
+ body.cpu_count = opts.cpuCount;
2540
+ }
2541
+ if (opts?.memoryMb !== void 0) {
2542
+ body.memory_mb = opts.memoryMb;
2522
2543
  }
2544
+ if (opts?.diskMb !== void 0) {
2545
+ body.disk_mb = opts.diskMb;
2546
+ }
2547
+ const data = await client.post("/templates/build", {
2548
+ json: body,
2549
+ timeout: opts?.requestTimeout
2550
+ });
2551
+ return parseBuildInfo(data);
2523
2552
  }
2524
2553
  /**
2525
2554
  * Get the status of a template build.
@@ -2533,15 +2562,86 @@ var Template = class {
2533
2562
  domain: opts?.domain,
2534
2563
  requestTimeout: opts?.requestTimeout
2535
2564
  });
2536
- const client = new ApiClient(config);
2537
- try {
2538
- const data = await client.get(`/templates/builds/${buildId}`, {
2539
- timeout: opts?.requestTimeout
2540
- });
2541
- return parseTemplateBuildStatus(data);
2542
- } finally {
2543
- client.close();
2565
+ const client = getSharedClient(config);
2566
+ const data = await client.get(`/templates/builds/${buildId}`, {
2567
+ timeout: opts?.requestTimeout
2568
+ });
2569
+ return parseTemplateBuildStatus(data);
2570
+ }
2571
+ };
2572
+
2573
+ // src/volumes/volumes.ts
2574
+ var VALID_VOLUME_ID_RE = /^[a-zA-Z0-9_-]+$/;
2575
+ function assertValidVolumeId(id) {
2576
+ if (!id || !VALID_VOLUME_ID_RE.test(id)) {
2577
+ throw new InvalidArgumentError(
2578
+ `Invalid volume ID: "${id}". Must be alphanumeric with hyphens/underscores only.`
2579
+ );
2580
+ }
2581
+ }
2582
+ var Volumes = class {
2583
+ /** Create a volume by streaming a tarball to the server. */
2584
+ static async create(name, data, opts) {
2585
+ if (!name) {
2586
+ throw new InvalidArgumentError("volume name is required");
2544
2587
  }
2588
+ const config = new ConnectionConfig({
2589
+ apiKey: opts?.apiKey,
2590
+ domain: opts?.domain,
2591
+ apiUrl: opts?.apiUrl,
2592
+ requestTimeout: opts?.requestTimeout
2593
+ });
2594
+ const client = getSharedClient(config);
2595
+ const body = data instanceof Uint8Array ? data : new Uint8Array(data);
2596
+ const resp = await client.post("/volumes", {
2597
+ params: { name },
2598
+ body,
2599
+ headers: { "Content-Type": opts?.contentType ?? "application/gzip" },
2600
+ timeout: opts?.requestTimeout
2601
+ });
2602
+ return parseVolumeInfo(resp);
2603
+ }
2604
+ /** Fetch metadata for a single volume. */
2605
+ static async get(volumeId, opts) {
2606
+ assertValidVolumeId(volumeId);
2607
+ const config = new ConnectionConfig({
2608
+ apiKey: opts?.apiKey,
2609
+ domain: opts?.domain,
2610
+ apiUrl: opts?.apiUrl,
2611
+ requestTimeout: opts?.requestTimeout
2612
+ });
2613
+ const client = getSharedClient(config);
2614
+ const resp = await client.get(`/volumes/${volumeId}`, {
2615
+ timeout: opts?.requestTimeout
2616
+ });
2617
+ return parseVolumeInfo(resp);
2618
+ }
2619
+ /** List all volumes owned by the caller, newest first. */
2620
+ static async list(opts) {
2621
+ const config = new ConnectionConfig({
2622
+ apiKey: opts?.apiKey,
2623
+ domain: opts?.domain,
2624
+ apiUrl: opts?.apiUrl,
2625
+ requestTimeout: opts?.requestTimeout
2626
+ });
2627
+ const client = getSharedClient(config);
2628
+ const resp = await client.get("/volumes", {
2629
+ timeout: opts?.requestTimeout
2630
+ });
2631
+ const rows = resp.volumes ?? [];
2632
+ return rows.map(parseVolumeInfo);
2633
+ }
2634
+ /** Delete a volume and its blob. Idempotent on the wire. */
2635
+ static async delete(volumeId, opts) {
2636
+ assertValidVolumeId(volumeId);
2637
+ const config = new ConnectionConfig({
2638
+ apiKey: opts?.apiKey,
2639
+ domain: opts?.domain,
2640
+ apiUrl: opts?.apiUrl,
2641
+ requestTimeout: opts?.requestTimeout
2642
+ });
2643
+ const client = getSharedClient(config);
2644
+ await client.delete(`/volumes/${volumeId}`, { timeout: opts?.requestTimeout });
2545
2645
  }
2546
2646
  };
2547
2647
  // Annotate the CommonJS export names for ESM import in node:
@@ -2580,6 +2680,7 @@ var Template = class {
2580
2680
  TemplateError,
2581
2681
  TimeoutError,
2582
2682
  TransformDirection,
2683
+ Volumes,
2583
2684
  WatchHandle,
2584
2685
  applyTransformation,
2585
2686
  codeSecurityConfigToJSON,
@@ -2594,6 +2695,7 @@ var Template = class {
2594
2695
  createToxicityConfig,
2595
2696
  createTransformationRule,
2596
2697
  domainMatches,
2698
+ getSharedClient,
2597
2699
  invisibleTextConfigToJSON,
2598
2700
  isSensitive,
2599
2701
  networkPolicyToOpts,
@@ -2618,10 +2720,13 @@ var Template = class {
2618
2720
  parseSnapshotInfo,
2619
2721
  parseTemplateBuildStatus,
2620
2722
  parseToxicityConfig,
2723
+ parseVolumeInfo,
2621
2724
  parseWriteInfo,
2622
2725
  requiresTlsInterception,
2726
+ resetSharedClients,
2623
2727
  securityPolicyToJSON,
2624
2728
  toxicityConfigToJSON,
2625
- validateNetworkEntry
2729
+ validateNetworkEntry,
2730
+ volumeAttachmentToJSON
2626
2731
  });
2627
2732
  //# sourceMappingURL=index.cjs.map