@blaxel/core 0.3.27 → 0.3.29-preview.319
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/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/common/settings.js +2 -2
- package/dist/cjs/image/image.js +12 -7
- package/dist/cjs/image/image.test.js +18 -9
- package/dist/cjs/types/image/image.browser.d.ts +4 -0
- package/dist/cjs/types/image/image.d.ts +9 -5
- package/dist/cjs-browser/.tsbuildinfo +1 -1
- package/dist/cjs-browser/common/settings.js +2 -2
- package/dist/cjs-browser/image/image.test.js +18 -9
- package/dist/cjs-browser/types/image/image.browser.d.ts +4 -0
- package/dist/cjs-browser/types/image/image.d.ts +9 -5
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/common/settings.js +2 -2
- package/dist/esm/image/image.js +12 -7
- package/dist/esm/image/image.test.js +18 -9
- package/dist/esm-browser/.tsbuildinfo +1 -1
- package/dist/esm-browser/common/settings.js +2 -2
- package/dist/esm-browser/image/image.test.js +18 -9
- package/package.json +1 -1
|
@@ -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.
|
|
28
|
-
const BUILD_COMMIT = "
|
|
27
|
+
const BUILD_VERSION = "0.3.29-preview.319";
|
|
28
|
+
const BUILD_COMMIT = "643251a25f011082e6849e55e91f3b06e3a1efb3";
|
|
29
29
|
const BUILD_SENTRY_DSN = "https://fd5e60e1c9820e1eef5ccebb84a07127@o4508714045276160.ingest.us.sentry.io/4510465864564736";
|
|
30
30
|
const BLAXEL_API_VERSION = "2026-09-22";
|
|
31
31
|
// Bun < 1.3.11 never sends connection-level WINDOW_UPDATE: the pooled h2
|
package/dist/esm/image/image.js
CHANGED
|
@@ -23,14 +23,19 @@ const BUILD_UPLOAD_LABELS = [
|
|
|
23
23
|
"x-blaxel-build-cache",
|
|
24
24
|
];
|
|
25
25
|
const MAX_BUILD_UPLOAD_LABEL_VALUE = 64;
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
// Reads an option that also has a deprecated `...Mb` spelling.
|
|
27
|
+
function buildSizeLabel(option, value, deprecatedValue, min, max) {
|
|
28
|
+
if (value !== undefined && deprecatedValue !== undefined) {
|
|
29
|
+
throw new Error(`Set ${option} or ${option}Mb, not both`);
|
|
30
|
+
}
|
|
31
|
+
const size = value ?? deprecatedValue;
|
|
32
|
+
if (size === undefined) {
|
|
28
33
|
return undefined;
|
|
29
34
|
}
|
|
30
|
-
if (!Number.isInteger(
|
|
31
|
-
throw new Error(`${option} must be an integer between ${min} and ${max}
|
|
35
|
+
if (!Number.isInteger(size) || size < min || size > max) {
|
|
36
|
+
throw new Error(`${value !== undefined ? option : `${option}Mb`} must be an integer between ${min} and ${max} MB`);
|
|
32
37
|
}
|
|
33
|
-
return String(
|
|
38
|
+
return String(size);
|
|
34
39
|
}
|
|
35
40
|
function buildUploadMetadata(labels) {
|
|
36
41
|
const metadata = {};
|
|
@@ -806,12 +811,12 @@ export class ImageInstance {
|
|
|
806
811
|
async build(options) {
|
|
807
812
|
const { name, memory = 4096, timeout = 900000, onStatusChange, sandboxVersion = "latest" } = options;
|
|
808
813
|
const buildLabels = {};
|
|
809
|
-
const buildMemory = buildSizeLabel("
|
|
814
|
+
const buildMemory = buildSizeLabel("buildMemory", options.buildMemory, options.buildMemoryMb, 1, 32768);
|
|
810
815
|
if (buildMemory !== undefined) {
|
|
811
816
|
buildLabels["x-blaxel-build-memory"] = buildMemory;
|
|
812
817
|
}
|
|
813
818
|
// Keep an explicit 0: it asks for memory-backed scratch instead of the default.
|
|
814
|
-
const buildVolume = buildSizeLabel("
|
|
819
|
+
const buildVolume = buildSizeLabel("buildVolume", options.buildVolume, options.buildVolumeMb, 0, 131072);
|
|
815
820
|
if (buildVolume !== undefined) {
|
|
816
821
|
buildLabels["x-blaxel-build-volume"] = buildVolume;
|
|
817
822
|
}
|
|
@@ -592,7 +592,7 @@ describe("ImageInstance.build worker resources", () => {
|
|
|
592
592
|
vi.unstubAllGlobals();
|
|
593
593
|
});
|
|
594
594
|
it("sends build memory and volume as labels and signed upload headers", async () => {
|
|
595
|
-
const { create, upload } = await buildWith({
|
|
595
|
+
const { create, upload } = await buildWith({ buildMemory: 16384, buildVolume: 32768 });
|
|
596
596
|
const labels = create.body.metadata?.labels;
|
|
597
597
|
expect(labels?.["x-blaxel-build-memory"]).toBe("16384");
|
|
598
598
|
expect(labels?.["x-blaxel-build-volume"]).toBe("32768");
|
|
@@ -602,20 +602,25 @@ describe("ImageInstance.build worker resources", () => {
|
|
|
602
602
|
expect(upload.headers["x-amz-meta-x-blaxel-auto-generated"]).toBeUndefined();
|
|
603
603
|
});
|
|
604
604
|
it("asks again when creating a sandbox does not sign the settings", async () => {
|
|
605
|
-
const { upload } = await buildWith({
|
|
605
|
+
const { upload } = await buildWith({ buildMemory: 2048 }, undefined, "update");
|
|
606
606
|
expect(calls.filter((call) => call.url.includes("upload=true")).map((call) => call.method)).toEqual(["PUT", "POST", "PUT"]);
|
|
607
607
|
expect(upload.headers["x-amz-meta-x-blaxel-build-memory"]).toBe("2048");
|
|
608
608
|
});
|
|
609
609
|
it("fails clearly when the settings are never signed", async () => {
|
|
610
|
-
await expect(buildWith({
|
|
610
|
+
await expect(buildWith({ buildVolume: 32768 }, undefined, "none")).rejects.toThrow("x-blaxel-build-volume");
|
|
611
611
|
expect(calls.some((call) => call.url.startsWith("https://upload.test"))).toBe(false);
|
|
612
612
|
});
|
|
613
613
|
it("drops stored labels the upload URL was not signed for", async () => {
|
|
614
614
|
const { upload } = await buildWith({}, { "x-blaxel-auto-generated": "true", "x-blaxel-build-memory": "8192" }, "none");
|
|
615
615
|
expect(upload.headers["x-amz-meta-x-blaxel-build-memory"]).toBeUndefined();
|
|
616
616
|
});
|
|
617
|
+
it("still accepts the deprecated Mb spellings", async () => {
|
|
618
|
+
const { create, upload } = await buildWith({ buildMemoryMb: 8192, buildVolumeMb: 0 });
|
|
619
|
+
expect(create.body.metadata?.labels?.["x-blaxel-build-memory"]).toBe("8192");
|
|
620
|
+
expect(upload.headers["x-amz-meta-x-blaxel-build-volume"]).toBe("0");
|
|
621
|
+
});
|
|
617
622
|
it("keeps an explicit zero volume", async () => {
|
|
618
|
-
const { upload } = await buildWith({
|
|
623
|
+
const { upload } = await buildWith({ buildVolume: 0 });
|
|
619
624
|
expect(upload.headers["x-amz-meta-x-blaxel-build-volume"]).toBe("0");
|
|
620
625
|
expect(upload.headers["x-amz-meta-x-blaxel-build-memory"]).toBeUndefined();
|
|
621
626
|
});
|
|
@@ -628,11 +633,15 @@ describe("ImageInstance.build worker resources", () => {
|
|
|
628
633
|
expect(upload.headers["x-amz-meta-x-blaxel-build-memory"]).toBe("8192");
|
|
629
634
|
});
|
|
630
635
|
it.each([
|
|
631
|
-
[{
|
|
632
|
-
[{
|
|
633
|
-
[{
|
|
634
|
-
[{
|
|
635
|
-
[{
|
|
636
|
+
[{ buildMemory: 0 }, "buildMemory must"],
|
|
637
|
+
[{ buildMemory: 32769 }, "buildMemory must"],
|
|
638
|
+
[{ buildMemory: 1.5 }, "buildMemory must"],
|
|
639
|
+
[{ buildVolume: -1 }, "buildVolume must"],
|
|
640
|
+
[{ buildVolume: 131073 }, "buildVolume must"],
|
|
641
|
+
[{ buildMemoryMb: 0 }, "buildMemoryMb must"],
|
|
642
|
+
[{ buildVolumeMb: -1 }, "buildVolumeMb must"],
|
|
643
|
+
[{ buildMemory: 2048, buildMemoryMb: 2048 }, "not both"],
|
|
644
|
+
[{ buildVolume: 0, buildVolumeMb: 0 }, "not both"],
|
|
636
645
|
])("rejects out-of-range %o before any request", async (options, option) => {
|
|
637
646
|
const fetchSpy = vi.fn();
|
|
638
647
|
vi.stubGlobal("fetch", fetchSpy);
|