@blaxel/core 0.3.28 → 0.3.29-preview.321

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.
@@ -30,8 +30,8 @@ function missingCredentialsMessage() {
30
30
  return "No Blaxel credentials found. Set the BL_API_KEY and BL_WORKSPACE environment variables, or run `bl login`.";
31
31
  }
32
32
  // Build info - these placeholders are replaced at build time by build:replace-imports
33
- const BUILD_VERSION = "0.3.28";
34
- const BUILD_COMMIT = "643251a25f011082e6849e55e91f3b06e3a1efb3";
33
+ const BUILD_VERSION = "0.3.29-preview.321";
34
+ const BUILD_COMMIT = "c1f5d1cffc5e85565febbbe0737df89947f2caa5";
35
35
  const BUILD_SENTRY_DSN = "https://fd5e60e1c9820e1eef5ccebb84a07127@o4508714045276160.ingest.us.sentry.io/4510465864564736";
36
36
  const BLAXEL_API_VERSION = "2026-09-22";
37
37
  // Bun < 1.3.11 never sends connection-level WINDOW_UPDATE: the pooled h2
@@ -29,6 +29,8 @@ const BUILD_UPLOAD_LABELS = [
29
29
  "x-blaxel-build-cache",
30
30
  ];
31
31
  const MAX_BUILD_UPLOAD_LABEL_VALUE = 64;
32
+ // The builder ignores a region that is not a resource name, so reject it here.
33
+ const BUILD_REGION_PATTERN = /^[a-z0-9][a-z0-9-]{0,62}$/;
32
34
  // Reads an option that also has a deprecated `...Mb` spelling.
33
35
  function buildSizeLabel(option, value, deprecatedValue, min, max) {
34
36
  if (value !== undefined && deprecatedValue !== undefined) {
@@ -826,6 +828,12 @@ class ImageInstance {
826
828
  if (buildVolume !== undefined) {
827
829
  buildLabels["x-blaxel-build-volume"] = buildVolume;
828
830
  }
831
+ if (options.buildRegion !== undefined) {
832
+ if (typeof options.buildRegion !== "string" || !BUILD_REGION_PATTERN.test(options.buildRegion)) {
833
+ throw new Error("buildRegion must be a region name such as us-was-1");
834
+ }
835
+ buildLabels["x-blaxel-build-region"] = options.buildRegion;
836
+ }
829
837
  // Prepare image for sandbox deployment (add sandbox-api and entrypoint)
830
838
  const preparedImage = this._prepareForSandbox(sandboxVersion);
831
839
  // Write the image folder
@@ -616,6 +616,17 @@ let tempSourceDir;
616
616
  const { upload } = await buildWith({}, { "x-blaxel-auto-generated": "true", "x-blaxel-build-memory": "8192" }, "none");
617
617
  (0, vitest_1.expect)(upload.headers["x-amz-meta-x-blaxel-build-memory"]).toBeUndefined();
618
618
  });
619
+ (0, vitest_1.it)("sends the build region as a label and signed upload header", async () => {
620
+ const { create, upload } = await buildWith({ buildRegion: "us-was-1", buildMemory: 2048 });
621
+ (0, vitest_1.expect)(create.body.metadata?.labels?.["x-blaxel-build-region"]).toBe("us-was-1");
622
+ (0, vitest_1.expect)(upload.headers["x-amz-meta-x-blaxel-build-region"]).toBe("us-was-1");
623
+ (0, vitest_1.expect)(upload.headers["x-amz-meta-x-blaxel-build-memory"]).toBe("2048");
624
+ });
625
+ (0, vitest_1.it)("asks again when creating a sandbox does not sign the region", async () => {
626
+ const { upload } = await buildWith({ buildRegion: "us-was-1" }, undefined, "update");
627
+ (0, vitest_1.expect)(calls.filter((call) => call.url.includes("upload=true")).map((call) => call.method)).toEqual(["PUT", "POST", "PUT"]);
628
+ (0, vitest_1.expect)(upload.headers["x-amz-meta-x-blaxel-build-region"]).toBe("us-was-1");
629
+ });
619
630
  (0, vitest_1.it)("still accepts the deprecated Mb spellings", async () => {
620
631
  const { create, upload } = await buildWith({ buildMemoryMb: 8192, buildVolumeMb: 0 });
621
632
  (0, vitest_1.expect)(create.body.metadata?.labels?.["x-blaxel-build-memory"]).toBe("8192");
@@ -644,6 +655,11 @@ let tempSourceDir;
644
655
  [{ buildVolumeMb: -1 }, "buildVolumeMb must"],
645
656
  [{ buildMemory: 2048, buildMemoryMb: 2048 }, "not both"],
646
657
  [{ buildVolume: 0, buildVolumeMb: 0 }, "not both"],
658
+ [{ buildRegion: "" }, "buildRegion must"],
659
+ [{ buildRegion: "US-WAS-1" }, "buildRegion must"],
660
+ [{ buildRegion: " us-was-1" }, "buildRegion must"],
661
+ [{ buildRegion: "-us" }, "buildRegion must"],
662
+ [{ buildRegion: "a".repeat(64) }, "buildRegion must"],
647
663
  ])("rejects out-of-range %o before any request", async (options, option) => {
648
664
  const fetchSpy = vitest_1.vi.fn();
649
665
  vitest_1.vi.stubGlobal("fetch", fetchSpy);
@@ -29,6 +29,7 @@ export interface ImageBuildOptions {
29
29
  sandboxVersion?: string;
30
30
  buildMemory?: number;
31
31
  buildVolume?: number;
32
+ buildRegion?: string;
32
33
  /** @deprecated Use `buildMemory`. */
33
34
  buildMemoryMb?: number;
34
35
  /** @deprecated Use `buildVolume`. */
@@ -38,6 +38,11 @@ export interface ImageBuildOptions {
38
38
  * Same as `bl push --volume`; 0 builds in memory.
39
39
  */
40
40
  buildVolume?: number;
41
+ /**
42
+ * Region the image is built in, such as "us-was-1". Same as `[build].region`
43
+ * in blaxel.toml; defaults to the platform's build region.
44
+ */
45
+ buildRegion?: string;
41
46
  /** @deprecated Use `buildMemory`. */
42
47
  buildMemoryMb?: number;
43
48
  /** @deprecated Use `buildVolume`. */