@blaxel/core 0.2.19-preview.41 → 0.2.19-preview.43
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/sandbox/index.d.ts +1 -0
- package/dist/sandbox/index.js +1 -0
- package/dist/sandbox/sandbox.js +12 -2
- package/dist/sandbox/types.d.ts +3 -1
- package/dist/sandbox/types.js +27 -0
- package/package.json +1 -1
package/dist/sandbox/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { deleteFilesystemByPath, deleteNetworkProcessByPidMonitor, deleteProcessByIdentifier, deleteProcessByIdentifierKill, Directory, ErrorResponse, File, FileRequest, FileWithContent, getFilesystemByPath, getNetworkProcessByPidPorts, getProcess, getProcessByIdentifier, getProcessByIdentifierLogs, getProcessByIdentifierLogsStream, PortMonitorRequest, postNetworkProcessByPidMonitor, postProcess, ProcessRequest, ProcessResponse, putFilesystemByPath, SuccessResponse } from "./client/index.js";
|
|
2
2
|
export * from "./filesystem/index.js";
|
|
3
3
|
export * from "./sandbox.js";
|
|
4
|
+
export * from "./types.js";
|
package/dist/sandbox/index.js
CHANGED
|
@@ -32,4 +32,5 @@ Object.defineProperty(exports, "postProcess", { enumerable: true, get: function
|
|
|
32
32
|
Object.defineProperty(exports, "putFilesystemByPath", { enumerable: true, get: function () { return index_js_1.putFilesystemByPath; } });
|
|
33
33
|
__exportStar(require("./filesystem/index.js"), exports);
|
|
34
34
|
__exportStar(require("./sandbox.js"), exports);
|
|
35
|
+
__exportStar(require("./types.js"), exports);
|
|
35
36
|
// Re-export everything from client except ClientOptions to avoid conflict
|
package/dist/sandbox/sandbox.js
CHANGED
|
@@ -9,6 +9,7 @@ const index_js_3 = require("./network/index.js");
|
|
|
9
9
|
const preview_js_1 = require("./preview.js");
|
|
10
10
|
const index_js_4 = require("./process/index.js");
|
|
11
11
|
const session_js_1 = require("./session.js");
|
|
12
|
+
const types_js_1 = require("./types.js");
|
|
12
13
|
class SandboxInstance {
|
|
13
14
|
sandbox;
|
|
14
15
|
fs;
|
|
@@ -65,7 +66,8 @@ class SandboxInstance {
|
|
|
65
66
|
const defaultName = `sandbox-${(0, uuid_1.v4)().replace(/-/g, '').substring(0, 8)}`;
|
|
66
67
|
const defaultImage = "blaxel/prod-base:latest";
|
|
67
68
|
const defaultMemory = 4096;
|
|
68
|
-
|
|
69
|
+
// Handle SandboxCreateConfiguration or simple dict with name/image/memory/ports keys
|
|
70
|
+
if (!sandbox || 'name' in sandbox || 'image' in sandbox || 'memory' in sandbox || 'ports' in sandbox) {
|
|
69
71
|
if (!sandbox)
|
|
70
72
|
sandbox = {};
|
|
71
73
|
if (!sandbox.name)
|
|
@@ -74,9 +76,17 @@ class SandboxInstance {
|
|
|
74
76
|
sandbox.image = defaultImage;
|
|
75
77
|
if (!sandbox.memory)
|
|
76
78
|
sandbox.memory = defaultMemory;
|
|
79
|
+
const ports = (0, types_js_1.normalizePorts)(sandbox.ports);
|
|
77
80
|
sandbox = {
|
|
78
81
|
metadata: { name: sandbox.name },
|
|
79
|
-
spec: {
|
|
82
|
+
spec: {
|
|
83
|
+
runtime: {
|
|
84
|
+
image: sandbox.image,
|
|
85
|
+
memory: sandbox.memory,
|
|
86
|
+
ports: ports,
|
|
87
|
+
generation: "mk3"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
80
90
|
};
|
|
81
91
|
}
|
|
82
92
|
sandbox = sandbox;
|
package/dist/sandbox/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Sandbox } from "../client/types.gen";
|
|
1
|
+
import { Port, Sandbox } from "../client/types.gen";
|
|
2
2
|
export interface SessionCreateOptions {
|
|
3
3
|
expiresAt?: Date;
|
|
4
4
|
responseHeaders?: Record<string, string>;
|
|
@@ -19,4 +19,6 @@ export type SandboxCreateConfiguration = {
|
|
|
19
19
|
name?: string;
|
|
20
20
|
image?: string;
|
|
21
21
|
memory?: number;
|
|
22
|
+
ports?: (Port | Record<string, any>)[];
|
|
22
23
|
};
|
|
24
|
+
export declare function normalizePorts(ports?: (Port | Record<string, any>)[]): Port[] | undefined;
|
package/dist/sandbox/types.js
CHANGED
|
@@ -1,2 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizePorts = normalizePorts;
|
|
4
|
+
function normalizePorts(ports) {
|
|
5
|
+
if (!ports || ports.length === 0) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
const portObjects = [];
|
|
9
|
+
for (const port of ports) {
|
|
10
|
+
if (typeof port === 'object' && port !== null) {
|
|
11
|
+
if ('name' in port || 'target' in port || 'protocol' in port) {
|
|
12
|
+
// It's a Port-like object, ensure protocol defaults to HTTP
|
|
13
|
+
const normalizedPort = {
|
|
14
|
+
name: typeof port.name === 'string' ? port.name : undefined,
|
|
15
|
+
target: typeof port.target === 'number' ? port.target : undefined,
|
|
16
|
+
protocol: typeof port.protocol === 'string' ? port.protocol : "HTTP"
|
|
17
|
+
};
|
|
18
|
+
portObjects.push(normalizedPort);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
throw new Error(`Invalid port type: ${typeof port}. Expected Port object or object with port properties.`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
throw new Error(`Invalid port type: ${typeof port}. Expected Port object or object with port properties.`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return portObjects;
|
|
29
|
+
}
|