ppio-sandbox 1.1.1-b3 → 1.1.2-b1

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.1.1-b3";
51
+ var version = "1.1.2-b1";
52
52
 
53
53
  // src/core/api/metadata.ts
54
54
  function getRuntime() {
@@ -2011,6 +2011,39 @@ var SandboxApi = class {
2011
2011
  }
2012
2012
  return true;
2013
2013
  }
2014
+ static async connectSandbox(sandboxId, opts) {
2015
+ var _a2, _b;
2016
+ const timeoutMs = (_a2 = opts == null ? void 0 : opts.timeoutMs) != null ? _a2 : DEFAULT_SANDBOX_TIMEOUT_MS;
2017
+ const config = new ConnectionConfig(opts);
2018
+ const client = new ApiClient(config);
2019
+ const res = await client.api.POST("/sandboxes/{sandboxID}/connect", {
2020
+ params: {
2021
+ path: {
2022
+ sandboxID: sandboxId
2023
+ }
2024
+ },
2025
+ body: {
2026
+ timeout: timeoutToSeconds(timeoutMs)
2027
+ },
2028
+ signal: config.getSignal(opts == null ? void 0 : opts.requestTimeoutMs)
2029
+ });
2030
+ if (((_b = res.error) == null ? void 0 : _b.code) === 404) {
2031
+ throw new NotFoundError(`Sandbox ${sandboxId} not found`);
2032
+ }
2033
+ const err = handleApiError(res);
2034
+ if (err) {
2035
+ throw err;
2036
+ }
2037
+ if (!res.data) {
2038
+ throw new Error("Sandbox not found");
2039
+ }
2040
+ return {
2041
+ sandboxId: `${res.data.sandboxID}-${res.data.clientID}`,
2042
+ envdVersion: res.data.envdVersion,
2043
+ envdAccessToken: res.data.envdAccessToken,
2044
+ sandboxDomain: void 0
2045
+ };
2046
+ }
2014
2047
  /**
2015
2048
  * Reset sandbox memory and optionally resume the sandbox.
2016
2049
  *
@@ -2301,23 +2334,10 @@ var Sandbox = class extends SandboxApi {
2301
2334
  * ```
2302
2335
  */
2303
2336
  static async connect(sandboxId, opts) {
2304
- try {
2305
- await SandboxApi.setTimeout(
2306
- sandboxId,
2307
- (opts == null ? void 0 : opts.timeoutMs) || DEFAULT_SANDBOX_TIMEOUT_MS,
2308
- opts
2309
- );
2310
- } catch (e) {
2311
- if (e instanceof SandboxError) {
2312
- await SandboxApi.resumeSandbox(sandboxId, opts);
2313
- } else {
2314
- throw e;
2315
- }
2316
- }
2317
- const info = await SandboxApi.getFullInfo(sandboxId, opts);
2337
+ const info = await SandboxApi.connectSandbox(sandboxId, opts);
2318
2338
  const config = new ConnectionConfig(opts);
2319
2339
  return new this(__spreadValues({
2320
- sandboxId,
2340
+ sandboxId: info.sandboxId,
2321
2341
  sandboxDomain: info.sandboxDomain,
2322
2342
  envdAccessToken: info.envdAccessToken,
2323
2343
  envdVersion: info.envdVersion
@@ -2383,15 +2403,7 @@ var Sandbox = class extends SandboxApi {
2383
2403
  * ```
2384
2404
  */
2385
2405
  async connect(opts) {
2386
- try {
2387
- await SandboxApi.setTimeout(
2388
- this.sandboxId,
2389
- (opts == null ? void 0 : opts.timeoutMs) || DEFAULT_SANDBOX_TIMEOUT_MS,
2390
- opts
2391
- );
2392
- } catch (e) {
2393
- await SandboxApi.resumeSandbox(this.sandboxId, opts);
2394
- }
2406
+ await SandboxApi.connectSandbox(this.sandboxId, opts);
2395
2407
  return this;
2396
2408
  }
2397
2409
  /**
@@ -2659,4 +2671,4 @@ export {
2659
2671
  Sandbox,
2660
2672
  core_default
2661
2673
  };
2662
- //# sourceMappingURL=chunk-4PHLEILJ.mjs.map
2674
+ //# sourceMappingURL=chunk-GOQK52FY.mjs.map