@blaxel/core 0.2.86 → 0.2.87-dev.173
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/README.md +37 -2
- package/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/authentication/credentials.js +11 -1
- package/dist/cjs/authentication/index.js +3 -1
- package/dist/cjs/client/sdk.gen.js +63 -12
- package/dist/cjs/common/credentials.test.js +71 -0
- package/dist/cjs/common/errors.js +15 -0
- package/dist/cjs/common/h2fetch.js +101 -50
- package/dist/cjs/common/h2pool.js +9 -0
- package/dist/cjs/common/pagination.js +87 -0
- package/dist/cjs/common/pagination.test.js +62 -0
- package/dist/cjs/common/settings.js +41 -3
- package/dist/cjs/common/settings.test.js +12 -3
- package/dist/cjs/drive/index.js +39 -3
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/jobs/jobs.js +42 -9
- package/dist/cjs/sandbox/client/sdk.gen.js +1 -1
- package/dist/cjs/sandbox/preview.js +8 -3
- package/dist/cjs/sandbox/sandbox.js +41 -4
- package/dist/cjs/types/authentication/credentials.d.ts +9 -0
- package/dist/cjs/types/client/sdk.gen.d.ts +34 -19
- package/dist/cjs/types/client/types.gen.d.ts +704 -22
- package/dist/cjs/types/common/credentials.test.d.ts +1 -0
- package/dist/cjs/types/common/errors.d.ts +10 -0
- package/dist/cjs/types/common/h2fetch.d.ts +9 -4
- package/dist/cjs/types/common/pagination.d.ts +35 -0
- package/dist/cjs/types/common/pagination.test.d.ts +1 -0
- package/dist/cjs/types/common/settings.d.ts +9 -0
- package/dist/cjs/types/drive/index.d.ts +35 -4
- package/dist/cjs/types/index.d.ts +1 -0
- package/dist/cjs/types/jobs/jobs.d.ts +33 -3
- package/dist/cjs/types/sandbox/client/sdk.gen.d.ts +1 -1
- package/dist/cjs/types/sandbox/client/types.gen.d.ts +24 -0
- package/dist/cjs/types/sandbox/preview.d.ts +2 -2
- package/dist/cjs/types/sandbox/sandbox.d.ts +36 -2
- package/dist/cjs/types/volume/index.d.ts +37 -4
- package/dist/cjs/volume/index.js +41 -3
- package/dist/cjs-browser/.tsbuildinfo +1 -1
- package/dist/cjs-browser/authentication/credentials.js +11 -1
- package/dist/cjs-browser/authentication/index.js +3 -1
- package/dist/cjs-browser/client/sdk.gen.js +63 -12
- package/dist/cjs-browser/common/credentials.test.js +71 -0
- package/dist/cjs-browser/common/errors.js +15 -0
- package/dist/cjs-browser/common/pagination.js +87 -0
- package/dist/cjs-browser/common/pagination.test.js +62 -0
- package/dist/cjs-browser/common/settings.js +41 -3
- package/dist/cjs-browser/common/settings.test.js +12 -3
- package/dist/cjs-browser/drive/index.js +39 -3
- package/dist/cjs-browser/index.js +1 -0
- package/dist/cjs-browser/jobs/jobs.js +42 -9
- package/dist/cjs-browser/sandbox/client/sdk.gen.js +1 -1
- package/dist/cjs-browser/sandbox/preview.js +8 -3
- package/dist/cjs-browser/sandbox/sandbox.js +41 -4
- package/dist/cjs-browser/types/authentication/credentials.d.ts +9 -0
- package/dist/cjs-browser/types/client/sdk.gen.d.ts +34 -19
- package/dist/cjs-browser/types/client/types.gen.d.ts +704 -22
- package/dist/cjs-browser/types/common/credentials.test.d.ts +1 -0
- package/dist/cjs-browser/types/common/errors.d.ts +10 -0
- package/dist/cjs-browser/types/common/h2fetch.d.ts +9 -4
- package/dist/cjs-browser/types/common/pagination.d.ts +35 -0
- package/dist/cjs-browser/types/common/pagination.test.d.ts +1 -0
- package/dist/cjs-browser/types/common/settings.d.ts +9 -0
- package/dist/cjs-browser/types/drive/index.d.ts +35 -4
- package/dist/cjs-browser/types/index.d.ts +1 -0
- package/dist/cjs-browser/types/jobs/jobs.d.ts +33 -3
- package/dist/cjs-browser/types/sandbox/client/sdk.gen.d.ts +1 -1
- package/dist/cjs-browser/types/sandbox/client/types.gen.d.ts +24 -0
- package/dist/cjs-browser/types/sandbox/preview.d.ts +2 -2
- package/dist/cjs-browser/types/sandbox/sandbox.d.ts +36 -2
- package/dist/cjs-browser/types/volume/index.d.ts +37 -4
- package/dist/cjs-browser/volume/index.js +41 -3
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/authentication/credentials.js +9 -0
- package/dist/esm/authentication/index.js +4 -2
- package/dist/esm/client/sdk.gen.js +57 -9
- package/dist/esm/common/credentials.test.js +69 -0
- package/dist/esm/common/errors.js +13 -0
- package/dist/esm/common/h2fetch.js +101 -50
- package/dist/esm/common/h2pool.js +9 -0
- package/dist/esm/common/pagination.js +83 -0
- package/dist/esm/common/pagination.test.js +60 -0
- package/dist/esm/common/settings.js +41 -3
- package/dist/esm/common/settings.test.js +12 -3
- package/dist/esm/drive/index.js +39 -3
- package/dist/esm/index.js +1 -0
- package/dist/esm/jobs/jobs.js +42 -9
- package/dist/esm/sandbox/client/sdk.gen.js +1 -1
- package/dist/esm/sandbox/preview.js +8 -3
- package/dist/esm/sandbox/sandbox.js +41 -4
- package/dist/esm/volume/index.js +41 -3
- package/dist/esm-browser/.tsbuildinfo +1 -1
- package/dist/esm-browser/authentication/credentials.js +9 -0
- package/dist/esm-browser/authentication/index.js +4 -2
- package/dist/esm-browser/client/sdk.gen.js +57 -9
- package/dist/esm-browser/common/credentials.test.js +69 -0
- package/dist/esm-browser/common/errors.js +13 -0
- package/dist/esm-browser/common/pagination.js +83 -0
- package/dist/esm-browser/common/pagination.test.js +60 -0
- package/dist/esm-browser/common/settings.js +41 -3
- package/dist/esm-browser/common/settings.test.js +12 -3
- package/dist/esm-browser/drive/index.js +39 -3
- package/dist/esm-browser/index.js +1 -0
- package/dist/esm-browser/jobs/jobs.js +42 -9
- package/dist/esm-browser/sandbox/client/sdk.gen.js +1 -1
- package/dist/esm-browser/sandbox/preview.js +8 -3
- package/dist/esm-browser/sandbox/sandbox.js +41 -4
- package/dist/esm-browser/volume/index.js +41 -3
- package/package.json +1 -1
|
@@ -99,24 +99,29 @@ export class SandboxPreviews {
|
|
|
99
99
|
});
|
|
100
100
|
return data.map((preview) => new SandboxPreview(preview));
|
|
101
101
|
}
|
|
102
|
-
async create(preview) {
|
|
102
|
+
async create(preview, force) {
|
|
103
|
+
const query = {};
|
|
104
|
+
if (force) {
|
|
105
|
+
query['force'] = 'true';
|
|
106
|
+
}
|
|
103
107
|
const { data } = await createSandboxPreview({
|
|
104
108
|
path: {
|
|
105
109
|
sandboxName: this.sandboxName,
|
|
106
110
|
},
|
|
111
|
+
query,
|
|
107
112
|
body: preview,
|
|
108
113
|
throwOnError: true,
|
|
109
114
|
});
|
|
110
115
|
return new SandboxPreview(data);
|
|
111
116
|
}
|
|
112
|
-
async createIfNotExists(preview) {
|
|
117
|
+
async createIfNotExists(preview, force) {
|
|
113
118
|
try {
|
|
114
119
|
const previewInstance = await this.get(preview.metadata.name);
|
|
115
120
|
return previewInstance;
|
|
116
121
|
}
|
|
117
122
|
catch (e) {
|
|
118
123
|
if (typeof e === "object" && e !== null && "code" in e && e.code === 404) {
|
|
119
|
-
return this.create(preview);
|
|
124
|
+
return this.create(preview, force);
|
|
120
125
|
}
|
|
121
126
|
throw e;
|
|
122
127
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from "uuid";
|
|
2
2
|
import { createSandbox, deleteSandbox, getSandbox, listSandboxes, updateSandbox } from "../client/index.js";
|
|
3
3
|
import { logger } from "../common/logger.js";
|
|
4
|
+
import { createPaginatedList } from "../common/pagination.js";
|
|
4
5
|
import { settings } from "../common/settings.js";
|
|
5
6
|
import { SandboxCodegen } from "./codegen/index.js";
|
|
6
7
|
import { SandboxDrive } from "./drive/index.js";
|
|
@@ -219,10 +220,46 @@ export class SandboxInstance {
|
|
|
219
220
|
const instance = new SandboxInstance(data);
|
|
220
221
|
return SandboxInstance.attachH2Session(instance);
|
|
221
222
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
223
|
+
/**
|
|
224
|
+
* List one page of sandboxes.
|
|
225
|
+
*
|
|
226
|
+
* The returned page exposes `data` for the current page, `meta` for cursor
|
|
227
|
+
* metadata, and helpers to fetch more pages only when you need them.
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```ts
|
|
231
|
+
* const page = await SandboxInstance.list({ limit: 50 });
|
|
232
|
+
*
|
|
233
|
+
* for (const sandbox of page.data) {
|
|
234
|
+
* console.log(sandbox.metadata.name);
|
|
235
|
+
* }
|
|
236
|
+
*
|
|
237
|
+
* const nextPage = await page.nextPage();
|
|
238
|
+
* ```
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* ```ts
|
|
242
|
+
* const page = await SandboxInstance.list({ limit: 100 });
|
|
243
|
+
*
|
|
244
|
+
* for await (const sandbox of page) {
|
|
245
|
+
* console.log(sandbox.metadata.name);
|
|
246
|
+
* }
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
static async list(query) {
|
|
250
|
+
const fetchPage = async (pageQuery) => {
|
|
251
|
+
const { data } = await listSandboxes({
|
|
252
|
+
query: pageQuery,
|
|
253
|
+
throwOnError: true,
|
|
254
|
+
});
|
|
255
|
+
return data;
|
|
256
|
+
};
|
|
257
|
+
return createPaginatedList({
|
|
258
|
+
response: await fetchPage(query),
|
|
259
|
+
fetchPage,
|
|
260
|
+
mapItem: (sandbox) => SandboxInstance.attachH2Session(new SandboxInstance(sandbox)),
|
|
261
|
+
query,
|
|
262
|
+
});
|
|
226
263
|
}
|
|
227
264
|
static async delete(sandboxName) {
|
|
228
265
|
const { data } = await deleteSandbox({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from "uuid";
|
|
2
2
|
import { createVolume, deleteVolume, getVolume, listVolumes, updateVolume } from "../client/index.js";
|
|
3
|
+
import { createPaginatedList } from "../common/pagination.js";
|
|
3
4
|
import { settings } from "../common/settings.js";
|
|
4
5
|
export class VolumeInstance {
|
|
5
6
|
volume;
|
|
@@ -85,9 +86,46 @@ export class VolumeInstance {
|
|
|
85
86
|
});
|
|
86
87
|
return new VolumeInstance(data);
|
|
87
88
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
/**
|
|
90
|
+
* List one page of volumes.
|
|
91
|
+
*
|
|
92
|
+
* The returned page exposes `data` for the current page, `meta` for cursor
|
|
93
|
+
* metadata, and helpers to fetch more pages only when you need them.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```ts
|
|
97
|
+
* const page = await VolumeInstance.list({ limit: 50 });
|
|
98
|
+
*
|
|
99
|
+
* for (const volume of page.data) {
|
|
100
|
+
* console.log(volume.name);
|
|
101
|
+
* }
|
|
102
|
+
*
|
|
103
|
+
* const nextPage = await page.nextPage();
|
|
104
|
+
* ```
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* const page = await VolumeInstance.list({ limit: 100 });
|
|
109
|
+
*
|
|
110
|
+
* for await (const volume of page) {
|
|
111
|
+
* console.log(volume.name);
|
|
112
|
+
* }
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
static async list(query) {
|
|
116
|
+
const fetchPage = async (pageQuery) => {
|
|
117
|
+
const { data } = await listVolumes({
|
|
118
|
+
query: pageQuery,
|
|
119
|
+
throwOnError: true,
|
|
120
|
+
});
|
|
121
|
+
return data;
|
|
122
|
+
};
|
|
123
|
+
return createPaginatedList({
|
|
124
|
+
response: await fetchPage(query),
|
|
125
|
+
fetchPage,
|
|
126
|
+
mapItem: (volume) => new VolumeInstance(volume),
|
|
127
|
+
query,
|
|
128
|
+
});
|
|
91
129
|
}
|
|
92
130
|
static async delete(volumeName) {
|
|
93
131
|
const { data } = await deleteVolume({
|