ppio-sandbox 1.0.1 → 1.0.3-a5

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.
@@ -48,7 +48,7 @@ import createClient from "openapi-fetch";
48
48
  import platform from "platform";
49
49
 
50
50
  // package.json
51
- var version = "1.0.1";
51
+ var version = "1.0.3-a5";
52
52
 
53
53
  // src/core/api/metadata.ts
54
54
  function getRuntime() {
@@ -258,6 +258,7 @@ var ApiClient = class {
258
258
 
259
259
  // src/core/connectionConfig.ts
260
260
  var REQUEST_TIMEOUT_MS = 6e4;
261
+ var REQUEST_LONG_TIMEOUT_MS = 3e5;
261
262
  var DEFAULT_SANDBOX_TIMEOUT_MS = 3e5;
262
263
  var KEEPALIVE_PING_INTERVAL_SEC = 50;
263
264
  var KEEPALIVE_PING_HEADER = "Keepalive-Ping-Interval";
@@ -1665,7 +1666,7 @@ var SandboxApi = class {
1665
1666
  * @returns `true` if the sandbox got paused, `false` if the sandbox was already paused.
1666
1667
  */
1667
1668
  static async betaPause(sandboxId, opts) {
1668
- var _a2, _b;
1669
+ var _a2, _b, _c;
1669
1670
  const config = new ConnectionConfig(opts);
1670
1671
  const client = new ApiClient(config);
1671
1672
  const res = await client.api.POST("/sandboxes/{sandboxID}/pause", {
@@ -1674,12 +1675,15 @@ var SandboxApi = class {
1674
1675
  sandboxID: sandboxId
1675
1676
  }
1676
1677
  },
1678
+ body: {
1679
+ sync: (_a2 = opts == null ? void 0 : opts.sync) != null ? _a2 : false
1680
+ },
1677
1681
  signal: config.getSignal(opts == null ? void 0 : opts.requestTimeoutMs)
1678
1682
  });
1679
- if (((_a2 = res.error) == null ? void 0 : _a2.code) === 404) {
1683
+ if (((_b = res.error) == null ? void 0 : _b.code) === 404) {
1680
1684
  throw new NotFoundError(`Sandbox ${sandboxId} not found`);
1681
1685
  }
1682
- if (((_b = res.error) == null ? void 0 : _b.code) === 409) {
1686
+ if (((_c = res.error) == null ? void 0 : _c.code) === 409) {
1683
1687
  return false;
1684
1688
  }
1685
1689
  const err = handleApiError(res);
@@ -1688,6 +1692,56 @@ var SandboxApi = class {
1688
1692
  }
1689
1693
  return true;
1690
1694
  }
1695
+ /**
1696
+ * Clone a sandbox to create multiple identical sandboxes.
1697
+ *
1698
+ * Note: This low-level API returns raw identifiers required to construct SDK instances.
1699
+ *
1700
+ * @param sandboxId sandbox ID.
1701
+ * @param opts clone options including count.
1702
+ *
1703
+ * @returns clone response with count and list of cloned sandboxes.
1704
+ */
1705
+ static async cloneSandboxes(sandboxId, opts) {
1706
+ var _a2, _b, _c, _d;
1707
+ const config = new ConnectionConfig(opts);
1708
+ const client = new ApiClient(config);
1709
+ const res = await client.api.POST("/sandboxes/{sandboxID}/clone", {
1710
+ params: {
1711
+ path: {
1712
+ sandboxID: sandboxId
1713
+ }
1714
+ },
1715
+ body: __spreadValues({
1716
+ count: (_a2 = opts.count) != null ? _a2 : 1,
1717
+ nodeID: opts.nodeID,
1718
+ strict: (_b = opts.strict) != null ? _b : false
1719
+ }, typeof opts.timeoutMs === "number" ? { timeout: timeoutToSeconds(opts.timeoutMs) } : {}),
1720
+ // Use an extended timeout for clone operation by default
1721
+ signal: config.getSignal(
1722
+ (_c = opts == null ? void 0 : opts.requestTimeoutMs) != null ? _c : REQUEST_LONG_TIMEOUT_MS
1723
+ )
1724
+ });
1725
+ if (((_d = res.error) == null ? void 0 : _d.code) === 404) {
1726
+ throw new NotFoundError(`Sandbox ${sandboxId} not found`);
1727
+ }
1728
+ const err = handleApiError(res);
1729
+ if (err) {
1730
+ throw err;
1731
+ }
1732
+ if (!res.data) {
1733
+ throw new Error("Clone response data is missing");
1734
+ }
1735
+ const sandboxes = (res.data.sandboxes || []).map((sb) => ({
1736
+ sandboxId: `${sb.sandboxID}-${sb.clientID}`,
1737
+ envdVersion: sb.envdVersion,
1738
+ envdAccessToken: sb.envdAccessToken
1739
+ }));
1740
+ return {
1741
+ count: res.data.count,
1742
+ sandboxes
1743
+ };
1744
+ }
1691
1745
  static async createSandbox(template, timeoutMs, opts) {
1692
1746
  var _a2, _b;
1693
1747
  const config = new ConnectionConfig(opts);
@@ -1701,7 +1755,8 @@ var SandboxApi = class {
1701
1755
  timeout: timeoutToSeconds(timeoutMs),
1702
1756
  secure: (_b = opts == null ? void 0 : opts.secure) != null ? _b : false,
1703
1757
  // allow_internet_access: opts?.allowInternetAccess ?? true,
1704
- allow_internet_access: true
1758
+ allow_internet_access: true,
1759
+ nodeID: opts == null ? void 0 : opts.nodeID
1705
1760
  },
1706
1761
  signal: config.getSignal(opts == null ? void 0 : opts.requestTimeoutMs)
1707
1762
  });
@@ -1978,6 +2033,36 @@ var Sandbox = class extends SandboxApi {
1978
2033
  envdVersion: info.envdVersion
1979
2034
  }, config));
1980
2035
  }
2036
+ /**
2037
+ * Clone a sandbox to create multiple identical sandboxes.
2038
+ *
2039
+ * @param sandboxId sandbox ID.
2040
+ * @param count number of sandboxes to clone.
2041
+ * @param opts clone options.
2042
+ *
2043
+ * @returns clone response with count and list of cloned sandboxes.
2044
+ *
2045
+ * @example
2046
+ * ```ts
2047
+ * const cloneResponse = await Sandbox.clone('sandbox-id', {
2048
+ * count: 3,
2049
+ * strict: false
2050
+ * })
2051
+ * console.log(`Cloned ${cloneResponse.count} sandboxes`)
2052
+ * ```
2053
+ */
2054
+ static async clone(sandboxId, opts) {
2055
+ const res = await SandboxApi.cloneSandboxes(sandboxId, opts);
2056
+ const instances = res.sandboxes.map((sb) => {
2057
+ const config = new ConnectionConfig(opts);
2058
+ return new this(__spreadValues({
2059
+ sandboxId: sb.sandboxId,
2060
+ envdVersion: sb.envdVersion,
2061
+ envdAccessToken: sb.envdAccessToken
2062
+ }, config));
2063
+ });
2064
+ return instances;
2065
+ }
1981
2066
  /**
1982
2067
  * Connect to a sandbox. If the sandbox is paused, it will be automatically resumed.
1983
2068
  * Sandbox must be either running or be paused.
@@ -2248,4 +2333,4 @@ export {
2248
2333
  Sandbox,
2249
2334
  core_default
2250
2335
  };
2251
- //# sourceMappingURL=chunk-7OUSMPTE.mjs.map
2336
+ //# sourceMappingURL=chunk-46PHQ57P.mjs.map