@blaxel/core 0.2.64-preview.74 → 0.2.65-dev.77

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.
@@ -9,8 +9,8 @@ const index_js_1 = require("../authentication/index.js");
9
9
  const env_js_1 = require("../common/env.js");
10
10
  const node_js_1 = require("../common/node.js");
11
11
  // Build info - these placeholders are replaced at build time by build:replace-imports
12
- const BUILD_VERSION = "0.2.64-preview.74";
13
- const BUILD_COMMIT = "80ced0a6bfd2a6577a44fd8bedfe81fe25a0a8d4";
12
+ const BUILD_VERSION = "0.2.65-dev.77";
13
+ const BUILD_COMMIT = "e860c9b3329ead5a36f8b3b0a31cd428e3fc513b";
14
14
  const BUILD_SENTRY_DSN = "https://fd5e60e1c9820e1eef5ccebb84a07127@o4508714045276160.ingest.us.sentry.io/4510465864564736";
15
15
  // Cache for config.yaml tracking value
16
16
  let configTrackingValue = null;
@@ -145,7 +145,30 @@ class SandboxPreviews {
145
145
  },
146
146
  throwOnError: true,
147
147
  });
148
+ if (data.status === 'DELETING') {
149
+ await this.waitForDeletion(previewName);
150
+ }
148
151
  return data;
149
152
  }
153
+ async waitForDeletion(previewName, timeoutMs = 10000) {
154
+ console.log(`Waiting for preview deletion: ${previewName}`);
155
+ const pollInterval = 500; // Poll every 500ms
156
+ const startTime = Date.now();
157
+ while (Date.now() - startTime < timeoutMs) {
158
+ const { response } = await (0, index_js_1.getSandboxPreview)({
159
+ path: {
160
+ sandboxName: this.sandboxName,
161
+ previewName,
162
+ },
163
+ });
164
+ if (response.status === 404) {
165
+ return;
166
+ }
167
+ // Preview still exists, wait and retry
168
+ await new Promise(resolve => setTimeout(resolve, pollInterval));
169
+ }
170
+ // Timeout reached, but deletion was initiated
171
+ throw new Error(`Preview deletion timeout: ${previewName} is still in DELETING state after ${timeoutMs}ms`);
172
+ }
150
173
  }
151
174
  exports.SandboxPreviews = SandboxPreviews;
@@ -5,6 +5,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.schemaToZodSchema = void 0;
7
7
  const zod_1 = __importDefault(require("zod"));
8
+ const jsonTypeToZod = (type, param) => {
9
+ switch (type) {
10
+ case "boolean":
11
+ return zod_1.default.boolean();
12
+ case "number":
13
+ case "integer":
14
+ return zod_1.default.number();
15
+ case "null":
16
+ return zod_1.default.null();
17
+ case "array":
18
+ return zod_1.default.array((0, exports.schemaToZodSchema)(param.items || {}));
19
+ case "object":
20
+ return (0, exports.schemaToZodSchema)(param);
21
+ default:
22
+ return zod_1.default.string();
23
+ }
24
+ };
8
25
  /**
9
26
  * Converts an array of `FunctionSchema` objects into a Zod schema for validation.
10
27
  *
@@ -16,25 +33,16 @@ const schemaToZodSchema = (schema) => {
16
33
  if (schema.properties) {
17
34
  Object.entries(schema.properties).forEach(([key, param]) => {
18
35
  let zodType;
19
- switch (param.type) {
20
- case "boolean":
21
- zodType = zod_1.default.boolean();
22
- break;
23
- case "number":
24
- case "integer":
25
- zodType = zod_1.default.number();
26
- break;
27
- case "null":
28
- zodType = zod_1.default.null();
29
- break;
30
- case "array":
31
- zodType = zod_1.default.array((0, exports.schemaToZodSchema)(param.items || {}));
32
- break;
33
- case "object":
34
- zodType = (0, exports.schemaToZodSchema)(param);
35
- break;
36
- default:
37
- zodType = zod_1.default.string();
36
+ if (Array.isArray(param.type)) {
37
+ // Handle union types like ["null", "boolean"]
38
+ const types = param.type.map((t) => jsonTypeToZod(t, param));
39
+ zodType =
40
+ types.length === 1
41
+ ? types[0]
42
+ : zod_1.default.union(types);
43
+ }
44
+ else {
45
+ zodType = jsonTypeToZod(param.type ?? "string", param);
38
46
  }
39
47
  if (param.description) {
40
48
  zodType = zodType.describe(param.description);
@@ -1825,15 +1825,19 @@ export type Ports = Array<Port>;
1825
1825
  * Preview of a Resource
1826
1826
  */
1827
1827
  export type Preview = {
1828
+ events?: CoreEvents;
1828
1829
  metadata: PreviewMetadata;
1829
1830
  spec: PreviewSpec;
1831
+ status?: Status;
1830
1832
  };
1831
1833
  /**
1832
1834
  * Preview of a Resource
1833
1835
  */
1834
1836
  export type PreviewWritable = {
1837
+ events?: CoreEventsWritable;
1835
1838
  metadata: PreviewMetadataWritable;
1836
1839
  spec: PreviewSpecWritable;
1840
+ status?: Status;
1837
1841
  };
1838
1842
  /**
1839
1843
  * PreviewMetadata
@@ -2197,7 +2201,7 @@ export type RevisionMetadataWritable = {
2197
2201
  export type Sandbox = {
2198
2202
  events?: CoreEvents;
2199
2203
  /**
2200
- * Time in seconds until the sandbox is automatically deleted based on TTL and lifecycle policies. Only present for sandboxes with expiration configured.
2204
+ * Time in seconds until the sandbox is automatically deleted based on TTL and lifecycle policies. Only present for sandboxes with lifecycle configured.
2201
2205
  */
2202
2206
  readonly expiresIn?: number;
2203
2207
  /**
@@ -137,9 +137,16 @@ export type ProcessRequest = {
137
137
  env?: {
138
138
  [key: string]: string;
139
139
  };
140
+ /**
141
+ * Disable scale-to-zero while process runs. Default timeout is 600s (10 minutes). Set timeout to 0 for infinite.
142
+ */
143
+ keepAlive?: boolean;
140
144
  maxRestarts?: number;
141
145
  name?: string;
142
146
  restartOnFailure?: boolean;
147
+ /**
148
+ * Timeout in seconds. When keepAlive is true, defaults to 600s (10 minutes). Set to 0 for infinite (no auto-kill).
149
+ */
143
150
  timeout?: number;
144
151
  waitForCompletion?: boolean;
145
152
  waitForPorts?: Array<number>;
@@ -149,6 +156,10 @@ export type ProcessResponse = {
149
156
  command: string;
150
157
  completedAt: string;
151
158
  exitCode: number;
159
+ /**
160
+ * Whether scale-to-zero is disabled for this process
161
+ */
162
+ keepAlive?: boolean;
152
163
  logs: string;
153
164
  maxRestarts?: number;
154
165
  name: string;
@@ -34,4 +34,5 @@ export declare class SandboxPreviews {
34
34
  createIfNotExists(preview: Preview): Promise<SandboxPreview>;
35
35
  get(previewName: string): Promise<SandboxPreview>;
36
36
  delete(previewName: string): Promise<Preview>;
37
+ private waitForDeletion;
37
38
  }
@@ -78,5 +78,5 @@ export type FunctionSchema = {
78
78
  /**
79
79
  * Type of the schema
80
80
  */
81
- type?: string;
81
+ type?: string | string[];
82
82
  };
@@ -157,6 +157,8 @@ class VolumeInstance {
157
157
  status: data.status,
158
158
  terminatedAt: data.terminatedAt,
159
159
  };
160
+ // This is for safe update
161
+ await new Promise(resolve => setTimeout(resolve, 500));
160
162
  return new VolumeInstance(newVolume);
161
163
  }
162
164
  async update(updates) {