@blaxel/core 0.2.85-preview.159 → 0.2.86-dev.162
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/client/sdk.gen.js +63 -12
- package/dist/cjs/common/h2fetch.js +102 -22
- package/dist/cjs/common/pagination.js +87 -0
- package/dist/cjs/common/pagination.test.js +62 -0
- package/dist/cjs/common/settings.js +29 -3
- package/dist/cjs/common/settings.test.js +3 -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/filesystem/filesystem.js +89 -1
- package/dist/cjs/sandbox/sandbox.js +41 -4
- package/dist/cjs/types/client/sdk.gen.d.ts +34 -19
- package/dist/cjs/types/client/types.gen.d.ts +614 -21
- 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 +12 -0
- package/dist/cjs/types/drive/index.d.ts +34 -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/sandbox.d.ts +35 -2
- package/dist/cjs/types/volume/index.d.ts +36 -4
- package/dist/cjs/volume/index.js +41 -3
- package/dist/cjs-browser/.tsbuildinfo +1 -1
- package/dist/cjs-browser/client/sdk.gen.js +63 -12
- 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 +29 -3
- package/dist/cjs-browser/common/settings.test.js +3 -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/filesystem/filesystem.js +89 -1
- package/dist/cjs-browser/sandbox/sandbox.js +41 -4
- package/dist/cjs-browser/types/client/sdk.gen.d.ts +34 -19
- package/dist/cjs-browser/types/client/types.gen.d.ts +614 -21
- 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 +12 -0
- package/dist/cjs-browser/types/drive/index.d.ts +34 -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/sandbox.d.ts +35 -2
- package/dist/cjs-browser/types/volume/index.d.ts +36 -4
- package/dist/cjs-browser/volume/index.js +41 -3
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/client/sdk.gen.js +57 -9
- package/dist/esm/common/h2fetch.js +102 -22
- package/dist/esm/common/pagination.js +83 -0
- package/dist/esm/common/pagination.test.js +60 -0
- package/dist/esm/common/settings.js +29 -3
- package/dist/esm/common/settings.test.js +3 -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/filesystem/filesystem.js +89 -1
- 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/client/sdk.gen.js +57 -9
- 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 +29 -3
- package/dist/esm-browser/common/settings.test.js +3 -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/filesystem/filesystem.js +89 -1
- package/dist/esm-browser/sandbox/sandbox.js +41 -4
- package/dist/esm-browser/volume/index.js +41 -3
- package/package.json +1 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type PaginatedListMeta = {
|
|
2
|
+
hasMore?: boolean;
|
|
3
|
+
nextCursor?: string;
|
|
4
|
+
total?: number;
|
|
5
|
+
};
|
|
6
|
+
export type CursorPaginationQuery = {
|
|
7
|
+
cursor?: string;
|
|
8
|
+
};
|
|
9
|
+
export type ListResponse<T> = T[] | {
|
|
10
|
+
data?: T[] | null;
|
|
11
|
+
meta?: PaginatedListMeta | null;
|
|
12
|
+
} | null | undefined;
|
|
13
|
+
export type AutoPagingEachCallback<T> = (item: T) => boolean | void | Promise<boolean | void>;
|
|
14
|
+
export type AutoPagingToArrayOptions = {
|
|
15
|
+
limit: number;
|
|
16
|
+
};
|
|
17
|
+
export type PaginatedList<T, TQuery extends CursorPaginationQuery = CursorPaginationQuery> = AsyncIterable<T> & {
|
|
18
|
+
data: T[];
|
|
19
|
+
meta: PaginatedListMeta;
|
|
20
|
+
hasMore: boolean;
|
|
21
|
+
nextCursor?: string;
|
|
22
|
+
nextPage(): Promise<PaginatedList<T, TQuery> | null>;
|
|
23
|
+
autoPagingEach(onItem: AutoPagingEachCallback<T>): Promise<void>;
|
|
24
|
+
autoPagingToArray(options: AutoPagingToArrayOptions): Promise<T[]>;
|
|
25
|
+
};
|
|
26
|
+
type CreatePaginatedListOptions<TRaw, TItem, TQuery extends CursorPaginationQuery> = {
|
|
27
|
+
response: ListResponse<TRaw>;
|
|
28
|
+
fetchPage: (query?: TQuery) => Promise<ListResponse<TRaw>>;
|
|
29
|
+
mapItem: (item: TRaw) => TItem | Promise<TItem>;
|
|
30
|
+
query?: TQuery;
|
|
31
|
+
seenCursors?: Set<string>;
|
|
32
|
+
};
|
|
33
|
+
export declare function unwrapListData<T>(response: ListResponse<T>): T[];
|
|
34
|
+
export declare function createPaginatedList<TRaw, TItem, TQuery extends CursorPaginationQuery = CursorPaginationQuery>({ response, fetchPage, mapItem, query, seenCursors, }: CreatePaginatedListOptions<TRaw, TItem, TQuery>): Promise<PaginatedList<TItem, TQuery>>;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -12,6 +12,16 @@ export type Config = {
|
|
|
12
12
|
apikey?: string;
|
|
13
13
|
workspace?: string;
|
|
14
14
|
disableH2?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Maximum number of concurrent in-flight HTTP/2 requests across the shared
|
|
17
|
+
* H2 session pool. `0` or `undefined` means unlimited (current behavior).
|
|
18
|
+
*/
|
|
19
|
+
maxConcurrentH2Requests?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Number of retry attempts for transient resets on multipart part uploads.
|
|
22
|
+
* `0` or `undefined` disables retry (current behavior).
|
|
23
|
+
*/
|
|
24
|
+
fsPartRetries?: number;
|
|
15
25
|
/**
|
|
16
26
|
* Client credentials for OAuth2 client_credentials flow.
|
|
17
27
|
*
|
|
@@ -51,6 +61,8 @@ declare class Settings {
|
|
|
51
61
|
get tracking(): boolean;
|
|
52
62
|
get region(): string | undefined;
|
|
53
63
|
get disableH2(): boolean;
|
|
64
|
+
get maxConcurrentH2Requests(): number;
|
|
65
|
+
get fsPartRetries(): number;
|
|
54
66
|
authenticate(): Promise<void>;
|
|
55
67
|
}
|
|
56
68
|
export declare const settings: Settings;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { Drive } from "../client/index.js";
|
|
2
|
-
export
|
|
1
|
+
import { type Drive, type ListDrivesData } from "../client/index.js";
|
|
2
|
+
export type DriveListQuery = NonNullable<ListDrivesData["query"]>;
|
|
3
|
+
export type DriveCreateConfiguration = {
|
|
3
4
|
name?: string;
|
|
4
5
|
displayName?: string;
|
|
5
6
|
labels?: Record<string, string>;
|
|
6
7
|
size?: number;
|
|
7
8
|
region?: string;
|
|
8
|
-
}
|
|
9
|
+
};
|
|
9
10
|
export declare class DriveInstance {
|
|
10
11
|
private drive;
|
|
11
12
|
constructor(drive: Drive);
|
|
@@ -19,7 +20,36 @@ export declare class DriveInstance {
|
|
|
19
20
|
get region(): string | undefined;
|
|
20
21
|
static create(config: DriveCreateConfiguration | Drive): Promise<DriveInstance>;
|
|
21
22
|
static get(driveName: string): Promise<DriveInstance>;
|
|
22
|
-
|
|
23
|
+
/**
|
|
24
|
+
* List one page of drives.
|
|
25
|
+
*
|
|
26
|
+
* The returned page exposes `data` for the current page, `meta` for cursor
|
|
27
|
+
* metadata, and helpers to fetch more pages only when you need them.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const page = await DriveInstance.list({ limit: 50 });
|
|
32
|
+
*
|
|
33
|
+
* for (const drive of page.data) {
|
|
34
|
+
* console.log(drive.name);
|
|
35
|
+
* }
|
|
36
|
+
*
|
|
37
|
+
* const nextPage = await page.nextPage();
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* const allDrives = await (await DriveInstance.list()).autoPagingToArray({
|
|
43
|
+
* limit: 1000,
|
|
44
|
+
* });
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
static list(query?: DriveListQuery): Promise<import("../common/pagination.js").PaginatedList<DriveInstance, {
|
|
48
|
+
cursor?: string;
|
|
49
|
+
limit?: number;
|
|
50
|
+
sort?: "createdAt:desc" | "createdAt:asc" | "name:asc" | "name:desc";
|
|
51
|
+
q?: string;
|
|
52
|
+
}>>;
|
|
23
53
|
static delete(driveName: string): Promise<{
|
|
24
54
|
message?: string;
|
|
25
55
|
name?: string;
|
|
@@ -7,6 +7,7 @@ export * from "./common/node.js";
|
|
|
7
7
|
export * from "./common/errors.js";
|
|
8
8
|
export * from "./common/internal.js";
|
|
9
9
|
export * from "./common/logger.js";
|
|
10
|
+
export * from "./common/pagination.js";
|
|
10
11
|
export * from "./common/settings.js";
|
|
11
12
|
export * from "./common/webhook.js";
|
|
12
13
|
export * from "./drive/index.js";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { CreateJobExecutionRequest, JobExecution } from "../client/index.js";
|
|
1
|
+
import { type CreateJobExecutionRequest, type JobExecution, type ListJobExecutionsData } from "../client/index.js";
|
|
2
|
+
export type JobExecutionListQuery = NonNullable<ListJobExecutionsData["query"]>;
|
|
2
3
|
declare class BlJob {
|
|
3
4
|
jobName: string;
|
|
4
5
|
constructor(jobName: string);
|
|
@@ -16,9 +17,38 @@ declare class BlJob {
|
|
|
16
17
|
*/
|
|
17
18
|
getExecution(executionId: string): Promise<JobExecution>;
|
|
18
19
|
/**
|
|
19
|
-
* List
|
|
20
|
+
* List one page of executions for this job.
|
|
21
|
+
*
|
|
22
|
+
* The returned page exposes `data` for the current page, `meta` for cursor
|
|
23
|
+
* metadata, and helpers to fetch more pages only when you need them.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* const job = blJob("daily-import");
|
|
28
|
+
* const page = await job.listExecutions({ limit: 50 });
|
|
29
|
+
*
|
|
30
|
+
* for (const execution of page.data) {
|
|
31
|
+
* console.log(execution.status);
|
|
32
|
+
* }
|
|
33
|
+
*
|
|
34
|
+
* const nextPage = await page.nextPage();
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* const job = blJob("daily-import");
|
|
40
|
+
* const executions = await (await job.listExecutions()).autoPagingToArray({
|
|
41
|
+
* limit: 1000,
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
20
44
|
*/
|
|
21
|
-
listExecutions(): Promise<JobExecution
|
|
45
|
+
listExecutions(query?: JobExecutionListQuery): Promise<import("../common/pagination.js").PaginatedList<JobExecution, {
|
|
46
|
+
limit?: number;
|
|
47
|
+
offset?: number;
|
|
48
|
+
cursor?: string;
|
|
49
|
+
sort?: "createdAt:desc" | "createdAt:asc" | "name:asc" | "name:desc";
|
|
50
|
+
q?: string;
|
|
51
|
+
}>>;
|
|
22
52
|
/**
|
|
23
53
|
* Get the status of a specific execution
|
|
24
54
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type http2 from "http2";
|
|
2
|
-
import { SandboxLifecycle, Sandbox as SandboxModel } from "../client/index.js";
|
|
2
|
+
import { type ListSandboxesData, type SandboxLifecycle, type Sandbox as SandboxModel } from "../client/index.js";
|
|
3
3
|
import { SandboxCodegen } from "./codegen/index.js";
|
|
4
4
|
import { SandboxDrive } from "./drive/index.js";
|
|
5
5
|
import { SandboxFileSystem } from "./filesystem/index.js";
|
|
@@ -9,6 +9,7 @@ import { SandboxProcess } from "./process/index.js";
|
|
|
9
9
|
import { SandboxSessions } from "./session.js";
|
|
10
10
|
import { SandboxSystem } from "./system.js";
|
|
11
11
|
import { SandboxConfiguration, SandboxCreateConfiguration, SandboxUpdateMetadata, SessionWithToken } from "./types.js";
|
|
12
|
+
export type SandboxListQuery = NonNullable<ListSandboxesData["query"]>;
|
|
12
13
|
export declare class SandboxInstance {
|
|
13
14
|
private sandbox;
|
|
14
15
|
fs: SandboxFileSystem;
|
|
@@ -51,7 +52,39 @@ export declare class SandboxInstance {
|
|
|
51
52
|
createIfNotExist?: boolean;
|
|
52
53
|
}): Promise<SandboxInstance>;
|
|
53
54
|
static get(sandboxName: string): Promise<SandboxInstance>;
|
|
54
|
-
|
|
55
|
+
/**
|
|
56
|
+
* List one page of sandboxes.
|
|
57
|
+
*
|
|
58
|
+
* The returned page exposes `data` for the current page, `meta` for cursor
|
|
59
|
+
* metadata, and helpers to fetch more pages only when you need them.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* const page = await SandboxInstance.list({ limit: 50 });
|
|
64
|
+
*
|
|
65
|
+
* for (const sandbox of page.data) {
|
|
66
|
+
* console.log(sandbox.metadata.name);
|
|
67
|
+
* }
|
|
68
|
+
*
|
|
69
|
+
* const nextPage = await page.nextPage();
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* const page = await SandboxInstance.list({ limit: 100 });
|
|
75
|
+
*
|
|
76
|
+
* for await (const sandbox of page) {
|
|
77
|
+
* console.log(sandbox.metadata.name);
|
|
78
|
+
* }
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
static list(query?: SandboxListQuery): Promise<import("../common/pagination.js").PaginatedList<SandboxInstance, {
|
|
82
|
+
showTerminated?: boolean;
|
|
83
|
+
cursor?: string;
|
|
84
|
+
limit?: number;
|
|
85
|
+
sort?: "createdAt:desc" | "createdAt:asc" | "name:asc" | "name:desc";
|
|
86
|
+
q?: string;
|
|
87
|
+
}>>;
|
|
55
88
|
static delete(sandboxName: string): Promise<SandboxModel>;
|
|
56
89
|
delete(): Promise<SandboxModel>;
|
|
57
90
|
static updateMetadata(sandboxName: string, metadata: SandboxUpdateMetadata): Promise<SandboxInstance>;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { Volume } from "../client/index.js";
|
|
2
|
-
export
|
|
1
|
+
import { type ListVolumesData, type Volume } from "../client/index.js";
|
|
2
|
+
export type VolumeListQuery = NonNullable<ListVolumesData["query"]>;
|
|
3
|
+
export type VolumeCreateConfiguration = {
|
|
3
4
|
name?: string;
|
|
4
5
|
displayName?: string;
|
|
5
6
|
labels?: Record<string, string>;
|
|
6
7
|
size?: number;
|
|
7
8
|
region?: string;
|
|
8
9
|
template?: string;
|
|
9
|
-
}
|
|
10
|
+
};
|
|
10
11
|
export declare class VolumeInstance {
|
|
11
12
|
private volume;
|
|
12
13
|
constructor(volume: Volume);
|
|
@@ -19,7 +20,38 @@ export declare class VolumeInstance {
|
|
|
19
20
|
get region(): string | undefined;
|
|
20
21
|
static create(config: VolumeCreateConfiguration | Volume): Promise<VolumeInstance>;
|
|
21
22
|
static get(volumeName: string): Promise<VolumeInstance>;
|
|
22
|
-
|
|
23
|
+
/**
|
|
24
|
+
* List one page of volumes.
|
|
25
|
+
*
|
|
26
|
+
* The returned page exposes `data` for the current page, `meta` for cursor
|
|
27
|
+
* metadata, and helpers to fetch more pages only when you need them.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const page = await VolumeInstance.list({ limit: 50 });
|
|
32
|
+
*
|
|
33
|
+
* for (const volume of page.data) {
|
|
34
|
+
* console.log(volume.name);
|
|
35
|
+
* }
|
|
36
|
+
*
|
|
37
|
+
* const nextPage = await page.nextPage();
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* const page = await VolumeInstance.list({ limit: 100 });
|
|
43
|
+
*
|
|
44
|
+
* for await (const volume of page) {
|
|
45
|
+
* console.log(volume.name);
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
static list(query?: VolumeListQuery): Promise<import("../common/pagination.js").PaginatedList<VolumeInstance, {
|
|
50
|
+
cursor?: string;
|
|
51
|
+
limit?: number;
|
|
52
|
+
sort?: "createdAt:desc" | "createdAt:asc" | "name:asc" | "name:desc";
|
|
53
|
+
q?: string;
|
|
54
|
+
}>>;
|
|
23
55
|
static delete(volumeName: string): Promise<Volume>;
|
|
24
56
|
delete(): Promise<Volume>;
|
|
25
57
|
static update(volumeName: string, updates: VolumeCreateConfiguration | Volume): Promise<VolumeInstance>;
|
package/dist/cjs/volume/index.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.VolumeInstance = void 0;
|
|
4
4
|
const uuid_1 = require("uuid");
|
|
5
5
|
const index_js_1 = require("../client/index.js");
|
|
6
|
+
const pagination_js_1 = require("../common/pagination.js");
|
|
6
7
|
const settings_js_1 = require("../common/settings.js");
|
|
7
8
|
class VolumeInstance {
|
|
8
9
|
volume;
|
|
@@ -88,9 +89,46 @@ class VolumeInstance {
|
|
|
88
89
|
});
|
|
89
90
|
return new VolumeInstance(data);
|
|
90
91
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
/**
|
|
93
|
+
* List one page of volumes.
|
|
94
|
+
*
|
|
95
|
+
* The returned page exposes `data` for the current page, `meta` for cursor
|
|
96
|
+
* metadata, and helpers to fetch more pages only when you need them.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* const page = await VolumeInstance.list({ limit: 50 });
|
|
101
|
+
*
|
|
102
|
+
* for (const volume of page.data) {
|
|
103
|
+
* console.log(volume.name);
|
|
104
|
+
* }
|
|
105
|
+
*
|
|
106
|
+
* const nextPage = await page.nextPage();
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```ts
|
|
111
|
+
* const page = await VolumeInstance.list({ limit: 100 });
|
|
112
|
+
*
|
|
113
|
+
* for await (const volume of page) {
|
|
114
|
+
* console.log(volume.name);
|
|
115
|
+
* }
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
static async list(query) {
|
|
119
|
+
const fetchPage = async (pageQuery) => {
|
|
120
|
+
const { data } = await (0, index_js_1.listVolumes)({
|
|
121
|
+
query: pageQuery,
|
|
122
|
+
throwOnError: true,
|
|
123
|
+
});
|
|
124
|
+
return data;
|
|
125
|
+
};
|
|
126
|
+
return (0, pagination_js_1.createPaginatedList)({
|
|
127
|
+
response: await fetchPage(query),
|
|
128
|
+
fetchPage,
|
|
129
|
+
mapItem: (volume) => new VolumeInstance(volume),
|
|
130
|
+
query,
|
|
131
|
+
});
|
|
94
132
|
}
|
|
95
133
|
static async delete(volumeName) {
|
|
96
134
|
const { data } = await (0, index_js_1.deleteVolume)({
|