@blaxel/core 0.3.8-preview.232 → 0.3.8-preview.234

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.
@@ -24,8 +24,8 @@ function missingCredentialsMessage() {
24
24
  return "No Blaxel credentials found. Set the BL_API_KEY and BL_WORKSPACE environment variables, or run `bl login`.";
25
25
  }
26
26
  // Build info - these placeholders are replaced at build time by build:replace-imports
27
- const BUILD_VERSION = "0.3.8-preview.232";
28
- const BUILD_COMMIT = "984d0f21ad10014285117ebbbff73e62efd5cf98";
27
+ const BUILD_VERSION = "0.3.8-preview.234";
28
+ const BUILD_COMMIT = "640ca44f9533691231a7903a1685eb57c244a43d";
29
29
  const BUILD_SENTRY_DSN = "https://fd5e60e1c9820e1eef5ccebb84a07127@o4508714045276160.ingest.us.sentry.io/4510465864564736";
30
30
  const BLAXEL_API_VERSION = "2026-04-28";
31
31
  // Bun < 1.3.11 never sends connection-level WINDOW_UPDATE: the pooled h2
@@ -1,4 +1,4 @@
1
- import { createSandbox, deleteSandbox, getSandbox, getSandboxByExternalId, listSandboxes, updateSandbox } from "../client/index.js";
1
+ import { createSandbox, createSandboxSnapshot, deleteSandbox, deleteSandboxSnapshot, forkSandbox, getSandbox, getSandboxByExternalId, listSandboxes, listSandboxSnapshots, updateSandbox } from "../client/index.js";
2
2
  import { logger } from "../common/logger.js";
3
3
  import { backoffDelayMs } from "../common/transient-retry.js";
4
4
  import { createPaginatedList } from "../common/pagination.js";
@@ -128,6 +128,64 @@ export class SandboxInstance {
128
128
  async fetch(port, path = "/", init) {
129
129
  return this.network.fetch(port, path, init);
130
130
  }
131
+ /**
132
+ * Create a point-in-time snapshot of this sandbox. Snapshots capture the
133
+ * sandbox state and can be forked into new sandboxes or applications.
134
+ *
135
+ * @param name - Optional human-readable name for the snapshot.
136
+ */
137
+ async snapshot(name) {
138
+ const { data } = await createSandboxSnapshot({
139
+ path: { sandboxName: this.metadata.name },
140
+ body: name ? { name } : {},
141
+ throwOnError: true,
142
+ });
143
+ return data;
144
+ }
145
+ /**
146
+ * List the snapshots of this sandbox.
147
+ */
148
+ async listSnapshots() {
149
+ const { data } = await listSandboxSnapshots({
150
+ path: { sandboxName: this.metadata.name },
151
+ throwOnError: true,
152
+ });
153
+ return data;
154
+ }
155
+ /**
156
+ * Delete a snapshot of this sandbox by its ID.
157
+ */
158
+ async deleteSnapshot(snapshotId) {
159
+ await deleteSandboxSnapshot({
160
+ path: { sandboxName: this.metadata.name, snapshotId },
161
+ throwOnError: true,
162
+ });
163
+ }
164
+ /**
165
+ * Fork this sandbox into a new sandbox or application.
166
+ *
167
+ * Pass `snapshotId` to fork from a specific snapshot (create a sandbox from a
168
+ * snapshot) instead of the sandbox's live state.
169
+ *
170
+ * @param targetName - Name of the sandbox/application to create.
171
+ * @param options - Fork options (target type, port, traffic, snapshot, ...).
172
+ */
173
+ async fork(targetName, options = {}) {
174
+ const { data } = await forkSandbox({
175
+ path: { sandboxName: this.metadata.name },
176
+ body: {
177
+ targetName,
178
+ targetType: options.targetType ?? "sandbox",
179
+ ...(options.port !== undefined ? { port: options.port } : {}),
180
+ ...(options.traffic !== undefined ? { traffic: options.traffic } : {}),
181
+ ...(options.customDomain !== undefined ? { customDomain: options.customDomain } : {}),
182
+ ...(options.prefix !== undefined ? { prefix: options.prefix } : {}),
183
+ ...(options.snapshotId !== undefined ? { snapshotId: options.snapshotId } : {}),
184
+ },
185
+ throwOnError: true,
186
+ });
187
+ return data;
188
+ }
131
189
  /* eslint-disable */
132
190
  async wait({ maxWait = 60000, interval = 1000 } = {}) {
133
191
  logger.warn("⚠️ Warning: sandbox.wait() is deprecated. You don't need to wait for the sandbox to be deployed anymore.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaxel/core",
3
- "version": "0.3.8-preview.232",
3
+ "version": "0.3.8-preview.234",
4
4
  "description": "Blaxel Core SDK for TypeScript",
5
5
  "license": "MIT",
6
6
  "author": "Blaxel, INC (https://blaxel.ai)",