@blaxel/core 0.3.11-preview.245 → 0.3.11-preview.247
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/h2fetch.js +19 -0
- package/dist/cjs/common/settings.js +2 -2
- package/dist/cjs/tools/zodSchema.test.js +74 -0
- package/dist/cjs/types/tools/zodSchema.test.d.ts +1 -0
- package/dist/cjs-browser/.tsbuildinfo +1 -1
- package/dist/cjs-browser/common/settings.js +2 -2
- package/dist/cjs-browser/tools/zodSchema.test.js +74 -0
- package/dist/cjs-browser/types/tools/zodSchema.test.d.ts +1 -0
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/common/h2fetch.js +19 -0
- package/dist/esm/common/settings.js +2 -2
- package/dist/esm/tools/zodSchema.test.js +72 -0
- package/dist/esm-browser/.tsbuildinfo +1 -1
- package/dist/esm-browser/common/settings.js +2 -2
- package/dist/esm-browser/tools/zodSchema.test.js +72 -0
- package/package.json +2 -2
|
@@ -12,6 +12,9 @@ exports.h2RequestDirect = h2RequestDirect;
|
|
|
12
12
|
const http2_1 = __importDefault(require("http2"));
|
|
13
13
|
const settings_js_1 = require("./settings.js");
|
|
14
14
|
const h2ref_js_1 = require("./h2ref.js");
|
|
15
|
+
// Statuses the Response constructor refuses to pair with a body. Handing it one
|
|
16
|
+
// throws, so a 204 (e.g. from a DELETE) would blow up instead of resolving.
|
|
17
|
+
const NULL_BODY_STATUSES = new Set([101, 103, 204, 205, 304]);
|
|
15
18
|
const MIN_H2_SESSION_MAX_LISTENERS = 64;
|
|
16
19
|
const sessionsWithListenerBudget = new WeakSet();
|
|
17
20
|
// Number of transparent re-sends the gateway performs for a request the peer
|
|
@@ -523,6 +526,22 @@ function _h2Send(session, h2Headers, body, signal, fallbackUrl, fallbackInit, op
|
|
|
523
526
|
continue;
|
|
524
527
|
resHeaders.set(k, Array.isArray(v) ? v.join(", ") : String(v));
|
|
525
528
|
}
|
|
529
|
+
if (NULL_BODY_STATUSES.has(status)) {
|
|
530
|
+
// Drain instead of wrapping: the stream still has to end for the h2 slot
|
|
531
|
+
// to be released, but the response must carry no body.
|
|
532
|
+
req.resume();
|
|
533
|
+
// `close` rather than `end`: it also fires when the drain ends on an
|
|
534
|
+
// error (RST_STREAM), which `end` does not, and the outer error handler
|
|
535
|
+
// cannot cover since the request is already settled.
|
|
536
|
+
req.once("close", () => {
|
|
537
|
+
if (streamClosed)
|
|
538
|
+
return;
|
|
539
|
+
streamClosed = true;
|
|
540
|
+
cleanupActiveRequest();
|
|
541
|
+
});
|
|
542
|
+
resolve(new Response(null, { status, headers: resHeaders }));
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
526
545
|
const readable = new ReadableStream({
|
|
527
546
|
start(controller) {
|
|
528
547
|
streamController = controller;
|
|
@@ -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.11-preview.
|
|
34
|
-
const BUILD_COMMIT = "
|
|
33
|
+
const BUILD_VERSION = "0.3.11-preview.247";
|
|
34
|
+
const BUILD_COMMIT = "2f0b2eea01b33051dbb8b73fed58f043aed16ed0";
|
|
35
35
|
const BUILD_SENTRY_DSN = "https://fd5e60e1c9820e1eef5ccebb84a07127@o4508714045276160.ingest.us.sentry.io/4510465864564736";
|
|
36
36
|
const BLAXEL_API_VERSION = "2026-04-28";
|
|
37
37
|
// Bun < 1.3.11 never sends connection-level WINDOW_UPDATE: the pooled h2
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const zodSchema_js_1 = require("./zodSchema.js");
|
|
5
|
+
// zod v3 and v4 are both supported (see the "zod" range in package.json), so
|
|
6
|
+
// these assertions only rely on behaviour that is identical across the two.
|
|
7
|
+
(0, vitest_1.describe)("schemaToZodSchema", () => {
|
|
8
|
+
(0, vitest_1.it)("maps json types onto their zod counterparts", () => {
|
|
9
|
+
const schema = (0, zodSchema_js_1.schemaToZodSchema)({
|
|
10
|
+
type: "object",
|
|
11
|
+
properties: {
|
|
12
|
+
name: { type: "string", description: "the name" },
|
|
13
|
+
count: { type: "integer" },
|
|
14
|
+
ratio: { type: "number" },
|
|
15
|
+
enabled: { type: "boolean" },
|
|
16
|
+
tags: {
|
|
17
|
+
type: "array",
|
|
18
|
+
items: { type: "object", properties: { id: { type: "string" } } },
|
|
19
|
+
},
|
|
20
|
+
nested: { type: "object", properties: { id: { type: "string" } } },
|
|
21
|
+
},
|
|
22
|
+
required: ["name", "count"],
|
|
23
|
+
});
|
|
24
|
+
const parsed = schema.parse({
|
|
25
|
+
name: "tool",
|
|
26
|
+
count: 2,
|
|
27
|
+
ratio: 0.5,
|
|
28
|
+
enabled: true,
|
|
29
|
+
tags: [{ id: "a" }],
|
|
30
|
+
nested: { id: "x" },
|
|
31
|
+
});
|
|
32
|
+
(0, vitest_1.expect)(parsed).toEqual({
|
|
33
|
+
name: "tool",
|
|
34
|
+
count: 2,
|
|
35
|
+
ratio: 0.5,
|
|
36
|
+
enabled: true,
|
|
37
|
+
tags: [{ id: "a" }],
|
|
38
|
+
nested: { id: "x" },
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
(0, vitest_1.it)("keeps non-required properties optional", () => {
|
|
42
|
+
const schema = (0, zodSchema_js_1.schemaToZodSchema)({
|
|
43
|
+
type: "object",
|
|
44
|
+
properties: {
|
|
45
|
+
name: { type: "string" },
|
|
46
|
+
optional: { type: "string" },
|
|
47
|
+
},
|
|
48
|
+
required: ["name"],
|
|
49
|
+
});
|
|
50
|
+
(0, vitest_1.expect)(schema.parse({ name: "tool" })).toEqual({ name: "tool" });
|
|
51
|
+
(0, vitest_1.expect)(() => schema.parse({ optional: "value" })).toThrow();
|
|
52
|
+
});
|
|
53
|
+
(0, vitest_1.it)("turns a list of types into a union", () => {
|
|
54
|
+
const schema = (0, zodSchema_js_1.schemaToZodSchema)({
|
|
55
|
+
type: "object",
|
|
56
|
+
properties: {
|
|
57
|
+
value: { type: ["null", "boolean"] },
|
|
58
|
+
},
|
|
59
|
+
required: ["value"],
|
|
60
|
+
});
|
|
61
|
+
(0, vitest_1.expect)(schema.parse({ value: null })).toEqual({ value: null });
|
|
62
|
+
(0, vitest_1.expect)(schema.parse({ value: false })).toEqual({ value: false });
|
|
63
|
+
(0, vitest_1.expect)(() => schema.parse({ value: "nope" })).toThrow();
|
|
64
|
+
});
|
|
65
|
+
(0, vitest_1.it)("falls back to a string for unknown or missing types", () => {
|
|
66
|
+
const schema = (0, zodSchema_js_1.schemaToZodSchema)({
|
|
67
|
+
type: "object",
|
|
68
|
+
properties: { value: {} },
|
|
69
|
+
required: ["value"],
|
|
70
|
+
});
|
|
71
|
+
(0, vitest_1.expect)(schema.parse({ value: "anything" })).toEqual({ value: "anything" });
|
|
72
|
+
(0, vitest_1.expect)(() => schema.parse({ value: 1 })).toThrow();
|
|
73
|
+
});
|
|
74
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|