@blaxel/core 0.2.86-preview.165 → 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.
Files changed (108) hide show
  1. package/README.md +37 -2
  2. package/dist/cjs/.tsbuildinfo +1 -1
  3. package/dist/cjs/authentication/credentials.js +11 -1
  4. package/dist/cjs/authentication/index.js +3 -1
  5. package/dist/cjs/client/sdk.gen.js +63 -12
  6. package/dist/cjs/common/credentials.test.js +71 -0
  7. package/dist/cjs/common/errors.js +15 -0
  8. package/dist/cjs/common/h2fetch.js +101 -50
  9. package/dist/cjs/common/h2pool.js +9 -0
  10. package/dist/cjs/common/pagination.js +87 -0
  11. package/dist/cjs/common/pagination.test.js +62 -0
  12. package/dist/cjs/common/settings.js +41 -3
  13. package/dist/cjs/common/settings.test.js +12 -3
  14. package/dist/cjs/drive/index.js +39 -3
  15. package/dist/cjs/index.js +1 -0
  16. package/dist/cjs/jobs/jobs.js +42 -9
  17. package/dist/cjs/sandbox/client/sdk.gen.js +1 -1
  18. package/dist/cjs/sandbox/preview.js +8 -3
  19. package/dist/cjs/sandbox/sandbox.js +41 -4
  20. package/dist/cjs/types/authentication/credentials.d.ts +9 -0
  21. package/dist/cjs/types/client/sdk.gen.d.ts +34 -19
  22. package/dist/cjs/types/client/types.gen.d.ts +704 -22
  23. package/dist/cjs/types/common/credentials.test.d.ts +1 -0
  24. package/dist/cjs/types/common/errors.d.ts +10 -0
  25. package/dist/cjs/types/common/h2fetch.d.ts +9 -4
  26. package/dist/cjs/types/common/pagination.d.ts +35 -0
  27. package/dist/cjs/types/common/pagination.test.d.ts +1 -0
  28. package/dist/cjs/types/common/settings.d.ts +9 -0
  29. package/dist/cjs/types/drive/index.d.ts +35 -4
  30. package/dist/cjs/types/index.d.ts +1 -0
  31. package/dist/cjs/types/jobs/jobs.d.ts +33 -3
  32. package/dist/cjs/types/sandbox/client/sdk.gen.d.ts +1 -1
  33. package/dist/cjs/types/sandbox/client/types.gen.d.ts +24 -0
  34. package/dist/cjs/types/sandbox/preview.d.ts +2 -2
  35. package/dist/cjs/types/sandbox/sandbox.d.ts +36 -2
  36. package/dist/cjs/types/volume/index.d.ts +37 -4
  37. package/dist/cjs/volume/index.js +41 -3
  38. package/dist/cjs-browser/.tsbuildinfo +1 -1
  39. package/dist/cjs-browser/authentication/credentials.js +11 -1
  40. package/dist/cjs-browser/authentication/index.js +3 -1
  41. package/dist/cjs-browser/client/sdk.gen.js +63 -12
  42. package/dist/cjs-browser/common/credentials.test.js +71 -0
  43. package/dist/cjs-browser/common/errors.js +15 -0
  44. package/dist/cjs-browser/common/pagination.js +87 -0
  45. package/dist/cjs-browser/common/pagination.test.js +62 -0
  46. package/dist/cjs-browser/common/settings.js +41 -3
  47. package/dist/cjs-browser/common/settings.test.js +12 -3
  48. package/dist/cjs-browser/drive/index.js +39 -3
  49. package/dist/cjs-browser/index.js +1 -0
  50. package/dist/cjs-browser/jobs/jobs.js +42 -9
  51. package/dist/cjs-browser/sandbox/client/sdk.gen.js +1 -1
  52. package/dist/cjs-browser/sandbox/preview.js +8 -3
  53. package/dist/cjs-browser/sandbox/sandbox.js +41 -4
  54. package/dist/cjs-browser/types/authentication/credentials.d.ts +9 -0
  55. package/dist/cjs-browser/types/client/sdk.gen.d.ts +34 -19
  56. package/dist/cjs-browser/types/client/types.gen.d.ts +704 -22
  57. package/dist/cjs-browser/types/common/credentials.test.d.ts +1 -0
  58. package/dist/cjs-browser/types/common/errors.d.ts +10 -0
  59. package/dist/cjs-browser/types/common/h2fetch.d.ts +9 -4
  60. package/dist/cjs-browser/types/common/pagination.d.ts +35 -0
  61. package/dist/cjs-browser/types/common/pagination.test.d.ts +1 -0
  62. package/dist/cjs-browser/types/common/settings.d.ts +9 -0
  63. package/dist/cjs-browser/types/drive/index.d.ts +35 -4
  64. package/dist/cjs-browser/types/index.d.ts +1 -0
  65. package/dist/cjs-browser/types/jobs/jobs.d.ts +33 -3
  66. package/dist/cjs-browser/types/sandbox/client/sdk.gen.d.ts +1 -1
  67. package/dist/cjs-browser/types/sandbox/client/types.gen.d.ts +24 -0
  68. package/dist/cjs-browser/types/sandbox/preview.d.ts +2 -2
  69. package/dist/cjs-browser/types/sandbox/sandbox.d.ts +36 -2
  70. package/dist/cjs-browser/types/volume/index.d.ts +37 -4
  71. package/dist/cjs-browser/volume/index.js +41 -3
  72. package/dist/esm/.tsbuildinfo +1 -1
  73. package/dist/esm/authentication/credentials.js +9 -0
  74. package/dist/esm/authentication/index.js +4 -2
  75. package/dist/esm/client/sdk.gen.js +57 -9
  76. package/dist/esm/common/credentials.test.js +69 -0
  77. package/dist/esm/common/errors.js +13 -0
  78. package/dist/esm/common/h2fetch.js +101 -50
  79. package/dist/esm/common/h2pool.js +9 -0
  80. package/dist/esm/common/pagination.js +83 -0
  81. package/dist/esm/common/pagination.test.js +60 -0
  82. package/dist/esm/common/settings.js +41 -3
  83. package/dist/esm/common/settings.test.js +12 -3
  84. package/dist/esm/drive/index.js +39 -3
  85. package/dist/esm/index.js +1 -0
  86. package/dist/esm/jobs/jobs.js +42 -9
  87. package/dist/esm/sandbox/client/sdk.gen.js +1 -1
  88. package/dist/esm/sandbox/preview.js +8 -3
  89. package/dist/esm/sandbox/sandbox.js +41 -4
  90. package/dist/esm/volume/index.js +41 -3
  91. package/dist/esm-browser/.tsbuildinfo +1 -1
  92. package/dist/esm-browser/authentication/credentials.js +9 -0
  93. package/dist/esm-browser/authentication/index.js +4 -2
  94. package/dist/esm-browser/client/sdk.gen.js +57 -9
  95. package/dist/esm-browser/common/credentials.test.js +69 -0
  96. package/dist/esm-browser/common/errors.js +13 -0
  97. package/dist/esm-browser/common/pagination.js +83 -0
  98. package/dist/esm-browser/common/pagination.test.js +60 -0
  99. package/dist/esm-browser/common/settings.js +41 -3
  100. package/dist/esm-browser/common/settings.test.js +12 -3
  101. package/dist/esm-browser/drive/index.js +39 -3
  102. package/dist/esm-browser/index.js +1 -0
  103. package/dist/esm-browser/jobs/jobs.js +42 -9
  104. package/dist/esm-browser/sandbox/client/sdk.gen.js +1 -1
  105. package/dist/esm-browser/sandbox/preview.js +8 -3
  106. package/dist/esm-browser/sandbox/sandbox.js +41 -4
  107. package/dist/esm-browser/volume/index.js +41 -3
  108. package/package.json +1 -1
@@ -1 +1,11 @@
1
+ /**
2
+ * Thrown when Blaxel credentials are missing or incomplete.
3
+ *
4
+ * Surfaced eagerly with an actionable message (which env var / login step is
5
+ * missing) instead of silently sending empty workspace/authorization headers
6
+ * and letting the user hit a misleading server-side "workspace is required".
7
+ */
8
+ export declare class CredentialsError extends Error {
9
+ constructor(message: string);
10
+ }
1
11
  export declare function handleDynamicImportError(err: any): void;
@@ -10,13 +10,18 @@ import type { H2Pool } from "./h2pool.js";
10
10
  */
11
11
  export declare function createH2Fetch(session: http2.ClientHttp2Session): (input: Request) => Promise<Response>;
12
12
  /**
13
- * Creates a fetch()-compatible function backed by the H2 session pool.
13
+ * Creates a fetch()-compatible function backed by the H2 session pool, routed
14
+ * through the single gateway. Used as the generated client's `fetch`.
14
15
  *
15
- * The pool validates idle sessions before reuse. If no usable H2 session is
16
- * available, the request falls back to regular fetch before any H2 frames
17
- * are sent.
16
+ * If no usable H2 session is available, the request falls back to regular fetch
17
+ * before any H2 frames are sent.
18
18
  */
19
19
  export declare function createPoolBackedH2Fetch(pool: H2Pool, domain: string): (input: Request) => Promise<Response>;
20
+ /**
21
+ * Pool-backed H2 request taking raw url + init (skips Request allocation),
22
+ * routed through the same single gateway. Used by `SandboxAction.h2Fetch` and
23
+ * the code interpreter.
24
+ */
20
25
  export declare function h2RequestDirectFromPool(pool: H2Pool, domain: string, url: string, init?: RequestInit): Promise<Response>;
21
26
  /**
22
27
  * Low-level H2 request that takes raw URL + init, skipping Request construction.
@@ -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 {};
@@ -63,6 +63,15 @@ declare class Settings {
63
63
  get disableH2(): boolean;
64
64
  get maxConcurrentH2Requests(): number;
65
65
  get fsPartRetries(): number;
66
+ /**
67
+ * Fail fast with a clear, actionable error when credentials are missing or
68
+ * incomplete, instead of sending empty workspace/authorization headers and
69
+ * surfacing a misleading server-side "workspace is required". Skipped for
70
+ * `forceUrl` sandbox sessions, which carry their own headers and never read
71
+ * `settings.headers`. Leaves `workspace` itself non-throwing so telemetry
72
+ * tagging stays safe.
73
+ */
74
+ private assertCredentials;
66
75
  authenticate(): Promise<void>;
67
76
  }
68
77
  export declare const settings: Settings;
@@ -1,11 +1,12 @@
1
- import { Drive } from "../client/index.js";
2
- export interface DriveCreateConfiguration {
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,37 @@ 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
- static list(): Promise<DriveInstance[]>;
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
+ anchor?: "end";
53
+ }>>;
23
54
  static delete(driveName: string): Promise<{
24
55
  message?: string;
25
56
  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 all executions for this job
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
  */
@@ -61,7 +61,7 @@ export declare const getCodegenRerankingByPath: <ThrowOnError extends boolean =
61
61
  export declare const getDrivesMount: <ThrowOnError extends boolean = false>(options?: Options<GetDrivesMountData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").DriveListResponse, import("./types.gen").ErrorResponse, ThrowOnError>;
62
62
  /**
63
63
  * Attach a drive to a local path
64
- * Mounts an agent drive using the blfs binary to a local path, optionally mounting a subpath within the drive
64
+ * Mounts an agent drive using the blfs binary to a local path, optionally mounting a subpath within the drive. Supports optional UID/GID mapping to remap file ownership between the local sandbox and the filer (always mapped to filer UID/GID 0). Mapping values can be set per-request via uidMap/gidMap fields, or globally via BLFS_UID_MAP/BLFS_GID_MAP environment variables (request values take precedence).
65
65
  */
66
66
  export declare const postDrivesMount: <ThrowOnError extends boolean = false>(options: Options<PostDrivesMountData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").DriveMountResponse, import("./types.gen").ErrorResponse, ThrowOnError>;
67
67
  /**
@@ -37,8 +37,16 @@ export type DriveListResponse = {
37
37
  export type DriveMountInfo = {
38
38
  driveName?: string;
39
39
  drivePath?: string;
40
+ /**
41
+ * The local GID used for this mount
42
+ */
43
+ gidMap?: string;
40
44
  mountPath?: string;
41
45
  readOnly?: boolean;
46
+ /**
47
+ * The local UID used for this mount
48
+ */
49
+ uidMap?: string;
42
50
  };
43
51
  export type DriveMountRequest = {
44
52
  driveName: string;
@@ -46,19 +54,35 @@ export type DriveMountRequest = {
46
54
  * Optional, defaults to "/"
47
55
  */
48
56
  drivePath?: string;
57
+ /**
58
+ * Optional, local GID to map (filer GID is always 0)
59
+ */
60
+ gidMap?: string;
49
61
  mountPath: string;
50
62
  /**
51
63
  * Optional, defaults to false
52
64
  */
53
65
  readOnly?: boolean;
66
+ /**
67
+ * Optional, local UID to map (filer UID is always 0)
68
+ */
69
+ uidMap?: string;
54
70
  };
55
71
  export type DriveMountResponse = {
56
72
  driveName?: string;
57
73
  drivePath?: string;
74
+ /**
75
+ * The local GID used for this mount
76
+ */
77
+ gidMap?: string;
58
78
  message?: string;
59
79
  mountPath?: string;
60
80
  readOnly?: boolean;
61
81
  success?: boolean;
82
+ /**
83
+ * The local UID used for this mount
84
+ */
85
+ uidMap?: string;
62
86
  };
63
87
  export type DriveUnmountResponse = {
64
88
  message?: string;
@@ -30,8 +30,8 @@ export declare class SandboxPreviews {
30
30
  constructor(sandbox: Sandbox);
31
31
  get sandboxName(): string;
32
32
  list(): Promise<SandboxPreview[]>;
33
- create(preview: Preview): Promise<SandboxPreview>;
34
- createIfNotExists(preview: Preview): Promise<SandboxPreview>;
33
+ create(preview: Preview, force?: boolean): Promise<SandboxPreview>;
34
+ createIfNotExists(preview: Preview, force?: boolean): Promise<SandboxPreview>;
35
35
  get(previewName: string): Promise<SandboxPreview>;
36
36
  delete(previewName: string): Promise<Preview>;
37
37
  private waitForDeletion;
@@ -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, SandboxUpdateNetwork, 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,40 @@ export declare class SandboxInstance {
51
52
  createIfNotExist?: boolean;
52
53
  }): Promise<SandboxInstance>;
53
54
  static get(sandboxName: string): Promise<SandboxInstance>;
54
- static list(): Promise<SandboxInstance[]>;
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
+ anchor?: "end";
88
+ }>>;
55
89
  static delete(sandboxName: string): Promise<SandboxModel>;
56
90
  delete(): Promise<SandboxModel>;
57
91
  static updateMetadata(sandboxName: string, metadata: SandboxUpdateMetadata): Promise<SandboxInstance>;
@@ -1,12 +1,13 @@
1
- import { Volume } from "../client/index.js";
2
- export interface VolumeCreateConfiguration {
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,39 @@ 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
- static list(): Promise<VolumeInstance[]>;
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
+ anchor?: "end";
55
+ }>>;
23
56
  static delete(volumeName: string): Promise<Volume>;
24
57
  delete(): Promise<Volume>;
25
58
  static update(volumeName: string, updates: VolumeCreateConfiguration | Volume): Promise<VolumeInstance>;
@@ -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
- static async list() {
92
- const { data } = await (0, index_js_1.listVolumes)({ throwOnError: true });
93
- return data.map((volume) => new VolumeInstance(volume));
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)({