disk 0.8.19 → 0.8.20

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/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { c as listDisks, i as deleteApiKey, n as createApiKey, o as getDisk, r as createDisk, s as listApiKeys, t as configure, y as ArchilApiError } from "./src--b7LHPh_.mjs";
2
+ import { c as listDisks, i as deleteApiKey, n as createApiKey, o as getDisk, r as createDisk, s as listApiKeys, t as configure, y as ArchilApiError } from "./src-BuqSzAcO.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import { Command, Option } from "commander";
5
5
  //#region bin/cli.ts
package/dist/index.cjs CHANGED
@@ -134,7 +134,7 @@ function deriveS3BaseUrl(controlBaseUrl) {
134
134
  }
135
135
  //#endregion
136
136
  //#region src/version.ts
137
- const VERSION = "0.8.19";
137
+ const VERSION = "0.8.20";
138
138
  const USER_AGENT = `archil-js/${VERSION}`;
139
139
  //#endregion
140
140
  //#region src/client.ts
@@ -153,10 +153,21 @@ function createApiClient(opts) {
153
153
  * Unwrap the API envelope: return data on success, throw ArchilApiError on failure.
154
154
  */
155
155
  async function unwrap(promise) {
156
+ return (await unwrapPage(promise)).data;
157
+ }
158
+ /**
159
+ * Unwrap a paginated list envelope: like {@link unwrap}, but also surface the
160
+ * envelope's `nextCursor` (undefined on the last page or from a server that
161
+ * doesn't paginate).
162
+ */
163
+ async function unwrapPage(promise) {
156
164
  const { data: body, error, response } = await promise;
157
165
  if (error || !body) throw new ArchilApiError(error?.error ?? `API request failed with status ${response.status}`, response.status);
158
166
  if (!body.success) throw new ArchilApiError(body.error ?? "Unknown API error", response.status);
159
- return body.data;
167
+ return {
168
+ data: body.data,
169
+ nextCursor: body.nextCursor
170
+ };
160
171
  }
161
172
  /**
162
173
  * Unwrap an API response that has no data payload (e.g., delete operations).
@@ -995,6 +1006,8 @@ function parseListMultipartUploadsResult(xml) {
995
1006
  }
996
1007
  //#endregion
997
1008
  //#region src/disks.ts
1009
+ /** Server-side maximum page size for GET /api/disks. */
1010
+ const DISK_PAGE_LIMIT = 100;
998
1011
  var Disks = class {
999
1012
  /** @internal */
1000
1013
  _client;
@@ -1008,12 +1021,45 @@ var Disks = class {
1008
1021
  this._region = region;
1009
1022
  this._s3BaseUrl = s3BaseUrl;
1010
1023
  }
1024
+ /**
1025
+ * List the account's disks. Fetches in cursor-driven pages (bounded server
1026
+ * work per request) and follows `nextCursor` until exhausted, so the result
1027
+ * is complete even for very large accounts. Use `limit` to cap the total, or
1028
+ * {@link listPage} to walk pages yourself.
1029
+ */
1011
1030
  async list(opts) {
1012
- return (await unwrap(this._client.GET("/api/disks", { params: { query: {
1031
+ if (opts?.name !== void 0) return (await this.listPage(opts)).disks;
1032
+ const limit = opts?.limit;
1033
+ let cursor = opts?.cursor;
1034
+ const disks = [];
1035
+ for (;;) {
1036
+ const remaining = limit === void 0 ? void 0 : limit - disks.length;
1037
+ if (remaining !== void 0 && remaining <= 0) return disks;
1038
+ const pageLimit = remaining === void 0 ? DISK_PAGE_LIMIT : Math.min(remaining, DISK_PAGE_LIMIT);
1039
+ const page = await this.listPage({
1040
+ limit: pageLimit,
1041
+ cursor
1042
+ });
1043
+ disks.push(...remaining === void 0 ? page.disks : page.disks.slice(0, remaining));
1044
+ if (!page.nextCursor || page.nextCursor === cursor) return disks;
1045
+ cursor = page.nextCursor;
1046
+ }
1047
+ }
1048
+ /**
1049
+ * Fetch a single page of disks. `nextCursor` on the result resumes the
1050
+ * listing (it can also be persisted, e.g. across requests of a paginated UI).
1051
+ */
1052
+ async listPage(opts) {
1053
+ const { data, nextCursor } = await unwrapPage(this._client.GET("/api/disks", { params: { query: {
1013
1054
  limit: opts?.limit,
1014
1055
  cursor: opts?.cursor,
1015
1056
  name: opts?.name
1016
- } } }))).map((d) => new Disk(d, this._client, this._region, this._s3BaseUrl));
1057
+ } } }));
1058
+ const disks = (data ?? []).map((d) => new Disk(d, this._client, this._region, this._s3BaseUrl));
1059
+ return nextCursor ? {
1060
+ disks,
1061
+ nextCursor
1062
+ } : { disks };
1017
1063
  }
1018
1064
  async get(id) {
1019
1065
  return new Disk(await unwrap(this._client.GET("/api/disks/{id}", { params: { path: { id } } })), this._client, this._region, this._s3BaseUrl);
package/dist/index.d.cts CHANGED
@@ -2,10 +2,20 @@ import { A as AwsStsUser, B as ExecRequest, C as S3Object, D as effectiveUploadP
2
2
 
3
3
  //#region src/disks.d.ts
4
4
  interface ListDisksOptions {
5
+ /** Cap on the total number of disks returned. */
5
6
  limit?: number;
7
+ /** Resume listing from a previous page's `nextCursor`. */
6
8
  cursor?: string;
7
9
  name?: string;
8
10
  }
11
+ interface DiskListPage {
12
+ disks: Disk[];
13
+ /**
14
+ * Set when more disks remain beyond this page; pass it back as `cursor` to
15
+ * fetch the next one. Undefined on the last page.
16
+ */
17
+ nextCursor?: string;
18
+ }
9
19
  interface CreateDiskResult {
10
20
  disk: Disk;
11
21
  token: string | null;
@@ -21,7 +31,18 @@ declare class Disks {
21
31
  private readonly _s3BaseUrl?;
22
32
  /** @internal */
23
33
  constructor(client: ApiClient, region: string, s3BaseUrl?: string);
34
+ /**
35
+ * List the account's disks. Fetches in cursor-driven pages (bounded server
36
+ * work per request) and follows `nextCursor` until exhausted, so the result
37
+ * is complete even for very large accounts. Use `limit` to cap the total, or
38
+ * {@link listPage} to walk pages yourself.
39
+ */
24
40
  list(opts?: ListDisksOptions): Promise<Disk[]>;
41
+ /**
42
+ * Fetch a single page of disks. `nextCursor` on the result resumes the
43
+ * listing (it can also be persisted, e.g. across requests of a paginated UI).
44
+ */
45
+ listPage(opts?: ListDisksOptions): Promise<DiskListPage>;
25
46
  get(id: string): Promise<Disk>;
26
47
  /**
27
48
  * Create a new disk with an auto-generated mount token.
@@ -263,4 +284,4 @@ declare function exec(opts: ExecOptions): Promise<ExecDiskResult>;
263
284
  */
264
285
  declare function workspace(mounts: Record<string, ExecMount>): Workspace;
265
286
  //#endregion
266
- export { type ApiTokenResponse, Archil, ArchilApiError, ArchilError, type ArchilOptions, ArchilS3Error, type AuthorizedUser, type AwsStsUser, type AzureBlobMount, type CompletedMultipartUpload, type ConnectedClient, type CreateApiTokenRequest, type CreateDiskRequest, type CreateDiskResult, type DeleteObjectsError, type DeleteObjectsOptions, type DeleteObjectsResult, Disk, type DiskMetrics, DiskMultipart, type DiskResponse, type DiskStatus, type DiskUser, Disks, type ExecMount, type ExecMountSpec, type ExecOptions, type ExecRequest, type ExecResult, type FileSystem, type GCSMount, type GrepMatch, type GrepOptions, type GrepResult, type GrepStoppedReason, type ListDisksOptions, type ListMultipartUploadsOptions, type ListObjectsOptions, type ListObjectsResult, type ListPartsOptions, type ListTokensOptions, type MountConfig, type MountConfigResponse, type MountOptions, type MountResponse, type MultipartUpload, type MultipartUploadListing, type MultipartUploadSummary, type ObjectMetadata, type PartInfo, type PartListing, type PutObjectOptions, type PutObjectResult, type R2Mount, type S3CompatibleMount, type S3Mount, type S3Object, type ShareUrlOptions, type ShareUrlResult, type TokenUser, Tokens, USER_AGENT, type UploadPart, VERSION, Workspace, configure, createApiKey, createDisk, deleteApiKey, effectiveUploadPartSize, exec, getDisk, listApiKeys, listDisks, workspace };
287
+ export { type ApiTokenResponse, Archil, ArchilApiError, ArchilError, type ArchilOptions, ArchilS3Error, type AuthorizedUser, type AwsStsUser, type AzureBlobMount, type CompletedMultipartUpload, type ConnectedClient, type CreateApiTokenRequest, type CreateDiskRequest, type CreateDiskResult, type DeleteObjectsError, type DeleteObjectsOptions, type DeleteObjectsResult, Disk, type DiskListPage, type DiskMetrics, DiskMultipart, type DiskResponse, type DiskStatus, type DiskUser, Disks, type ExecMount, type ExecMountSpec, type ExecOptions, type ExecRequest, type ExecResult, type FileSystem, type GCSMount, type GrepMatch, type GrepOptions, type GrepResult, type GrepStoppedReason, type ListDisksOptions, type ListMultipartUploadsOptions, type ListObjectsOptions, type ListObjectsResult, type ListPartsOptions, type ListTokensOptions, type MountConfig, type MountConfigResponse, type MountOptions, type MountResponse, type MultipartUpload, type MultipartUploadListing, type MultipartUploadSummary, type ObjectMetadata, type PartInfo, type PartListing, type PutObjectOptions, type PutObjectResult, type R2Mount, type S3CompatibleMount, type S3Mount, type S3Object, type ShareUrlOptions, type ShareUrlResult, type TokenUser, Tokens, USER_AGENT, type UploadPart, VERSION, Workspace, configure, createApiKey, createDisk, deleteApiKey, effectiveUploadPartSize, exec, getDisk, listApiKeys, listDisks, workspace };
package/dist/index.d.mts CHANGED
@@ -2,10 +2,20 @@ import { A as AwsStsUser, B as ExecRequest, C as S3Object, D as effectiveUploadP
2
2
 
3
3
  //#region src/disks.d.ts
4
4
  interface ListDisksOptions {
5
+ /** Cap on the total number of disks returned. */
5
6
  limit?: number;
7
+ /** Resume listing from a previous page's `nextCursor`. */
6
8
  cursor?: string;
7
9
  name?: string;
8
10
  }
11
+ interface DiskListPage {
12
+ disks: Disk[];
13
+ /**
14
+ * Set when more disks remain beyond this page; pass it back as `cursor` to
15
+ * fetch the next one. Undefined on the last page.
16
+ */
17
+ nextCursor?: string;
18
+ }
9
19
  interface CreateDiskResult {
10
20
  disk: Disk;
11
21
  token: string | null;
@@ -21,7 +31,18 @@ declare class Disks {
21
31
  private readonly _s3BaseUrl?;
22
32
  /** @internal */
23
33
  constructor(client: ApiClient, region: string, s3BaseUrl?: string);
34
+ /**
35
+ * List the account's disks. Fetches in cursor-driven pages (bounded server
36
+ * work per request) and follows `nextCursor` until exhausted, so the result
37
+ * is complete even for very large accounts. Use `limit` to cap the total, or
38
+ * {@link listPage} to walk pages yourself.
39
+ */
24
40
  list(opts?: ListDisksOptions): Promise<Disk[]>;
41
+ /**
42
+ * Fetch a single page of disks. `nextCursor` on the result resumes the
43
+ * listing (it can also be persisted, e.g. across requests of a paginated UI).
44
+ */
45
+ listPage(opts?: ListDisksOptions): Promise<DiskListPage>;
25
46
  get(id: string): Promise<Disk>;
26
47
  /**
27
48
  * Create a new disk with an auto-generated mount token.
@@ -263,4 +284,4 @@ declare function exec(opts: ExecOptions): Promise<ExecDiskResult>;
263
284
  */
264
285
  declare function workspace(mounts: Record<string, ExecMount>): Workspace;
265
286
  //#endregion
266
- export { type ApiTokenResponse, Archil, ArchilApiError, ArchilError, type ArchilOptions, ArchilS3Error, type AuthorizedUser, type AwsStsUser, type AzureBlobMount, type CompletedMultipartUpload, type ConnectedClient, type CreateApiTokenRequest, type CreateDiskRequest, type CreateDiskResult, type DeleteObjectsError, type DeleteObjectsOptions, type DeleteObjectsResult, Disk, type DiskMetrics, DiskMultipart, type DiskResponse, type DiskStatus, type DiskUser, Disks, type ExecMount, type ExecMountSpec, type ExecOptions, type ExecRequest, type ExecResult, type FileSystem, type GCSMount, type GrepMatch, type GrepOptions, type GrepResult, type GrepStoppedReason, type ListDisksOptions, type ListMultipartUploadsOptions, type ListObjectsOptions, type ListObjectsResult, type ListPartsOptions, type ListTokensOptions, type MountConfig, type MountConfigResponse, type MountOptions, type MountResponse, type MultipartUpload, type MultipartUploadListing, type MultipartUploadSummary, type ObjectMetadata, type PartInfo, type PartListing, type PutObjectOptions, type PutObjectResult, type R2Mount, type S3CompatibleMount, type S3Mount, type S3Object, type ShareUrlOptions, type ShareUrlResult, type TokenUser, Tokens, USER_AGENT, type UploadPart, VERSION, Workspace, configure, createApiKey, createDisk, deleteApiKey, effectiveUploadPartSize, exec, getDisk, listApiKeys, listDisks, workspace };
287
+ export { type ApiTokenResponse, Archil, ArchilApiError, ArchilError, type ArchilOptions, ArchilS3Error, type AuthorizedUser, type AwsStsUser, type AzureBlobMount, type CompletedMultipartUpload, type ConnectedClient, type CreateApiTokenRequest, type CreateDiskRequest, type CreateDiskResult, type DeleteObjectsError, type DeleteObjectsOptions, type DeleteObjectsResult, Disk, type DiskListPage, type DiskMetrics, DiskMultipart, type DiskResponse, type DiskStatus, type DiskUser, Disks, type ExecMount, type ExecMountSpec, type ExecOptions, type ExecRequest, type ExecResult, type FileSystem, type GCSMount, type GrepMatch, type GrepOptions, type GrepResult, type GrepStoppedReason, type ListDisksOptions, type ListMultipartUploadsOptions, type ListObjectsOptions, type ListObjectsResult, type ListPartsOptions, type ListTokensOptions, type MountConfig, type MountConfigResponse, type MountOptions, type MountResponse, type MultipartUpload, type MultipartUploadListing, type MultipartUploadSummary, type ObjectMetadata, type PartInfo, type PartListing, type PutObjectOptions, type PutObjectResult, type R2Mount, type S3CompatibleMount, type S3Mount, type S3Object, type ShareUrlOptions, type ShareUrlResult, type TokenUser, Tokens, USER_AGENT, type UploadPart, VERSION, Workspace, configure, createApiKey, createDisk, deleteApiKey, effectiveUploadPartSize, exec, getDisk, listApiKeys, listDisks, workspace };
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { _ as USER_AGENT, a as exec, b as ArchilError, c as listDisks, d as Workspace, f as Tokens, g as effectiveUploadPartSize, h as DiskMultipart, i as deleteApiKey, l as workspace, m as Disk, n as createApiKey, o as getDisk, p as Disks, r as createDisk, s as listApiKeys, t as configure, u as Archil, v as VERSION, x as ArchilS3Error, y as ArchilApiError } from "./src--b7LHPh_.mjs";
1
+ import { _ as USER_AGENT, a as exec, b as ArchilError, c as listDisks, d as Workspace, f as Tokens, g as effectiveUploadPartSize, h as DiskMultipart, i as deleteApiKey, l as workspace, m as Disk, n as createApiKey, o as getDisk, p as Disks, r as createDisk, s as listApiKeys, t as configure, u as Archil, v as VERSION, x as ArchilS3Error, y as ArchilApiError } from "./src-BuqSzAcO.mjs";
2
2
  export { Archil, ArchilApiError, ArchilError, ArchilS3Error, Disk, DiskMultipart, Disks, Tokens, USER_AGENT, VERSION, Workspace, configure, createApiKey, createDisk, deleteApiKey, effectiveUploadPartSize, exec, getDisk, listApiKeys, listDisks, workspace };
@@ -111,7 +111,7 @@ function deriveS3BaseUrl(controlBaseUrl) {
111
111
  }
112
112
  //#endregion
113
113
  //#region src/version.ts
114
- const VERSION = "0.8.19";
114
+ const VERSION = "0.8.20";
115
115
  const USER_AGENT = `archil-js/${VERSION}`;
116
116
  //#endregion
117
117
  //#region src/client.ts
@@ -130,10 +130,21 @@ function createApiClient(opts) {
130
130
  * Unwrap the API envelope: return data on success, throw ArchilApiError on failure.
131
131
  */
132
132
  async function unwrap(promise) {
133
+ return (await unwrapPage(promise)).data;
134
+ }
135
+ /**
136
+ * Unwrap a paginated list envelope: like {@link unwrap}, but also surface the
137
+ * envelope's `nextCursor` (undefined on the last page or from a server that
138
+ * doesn't paginate).
139
+ */
140
+ async function unwrapPage(promise) {
133
141
  const { data: body, error, response } = await promise;
134
142
  if (error || !body) throw new ArchilApiError(error?.error ?? `API request failed with status ${response.status}`, response.status);
135
143
  if (!body.success) throw new ArchilApiError(body.error ?? "Unknown API error", response.status);
136
- return body.data;
144
+ return {
145
+ data: body.data,
146
+ nextCursor: body.nextCursor
147
+ };
137
148
  }
138
149
  /**
139
150
  * Unwrap an API response that has no data payload (e.g., delete operations).
@@ -972,6 +983,8 @@ function parseListMultipartUploadsResult(xml) {
972
983
  }
973
984
  //#endregion
974
985
  //#region src/disks.ts
986
+ /** Server-side maximum page size for GET /api/disks. */
987
+ const DISK_PAGE_LIMIT = 100;
975
988
  var Disks = class {
976
989
  /** @internal */
977
990
  _client;
@@ -985,12 +998,45 @@ var Disks = class {
985
998
  this._region = region;
986
999
  this._s3BaseUrl = s3BaseUrl;
987
1000
  }
1001
+ /**
1002
+ * List the account's disks. Fetches in cursor-driven pages (bounded server
1003
+ * work per request) and follows `nextCursor` until exhausted, so the result
1004
+ * is complete even for very large accounts. Use `limit` to cap the total, or
1005
+ * {@link listPage} to walk pages yourself.
1006
+ */
988
1007
  async list(opts) {
989
- return (await unwrap(this._client.GET("/api/disks", { params: { query: {
1008
+ if (opts?.name !== void 0) return (await this.listPage(opts)).disks;
1009
+ const limit = opts?.limit;
1010
+ let cursor = opts?.cursor;
1011
+ const disks = [];
1012
+ for (;;) {
1013
+ const remaining = limit === void 0 ? void 0 : limit - disks.length;
1014
+ if (remaining !== void 0 && remaining <= 0) return disks;
1015
+ const pageLimit = remaining === void 0 ? DISK_PAGE_LIMIT : Math.min(remaining, DISK_PAGE_LIMIT);
1016
+ const page = await this.listPage({
1017
+ limit: pageLimit,
1018
+ cursor
1019
+ });
1020
+ disks.push(...remaining === void 0 ? page.disks : page.disks.slice(0, remaining));
1021
+ if (!page.nextCursor || page.nextCursor === cursor) return disks;
1022
+ cursor = page.nextCursor;
1023
+ }
1024
+ }
1025
+ /**
1026
+ * Fetch a single page of disks. `nextCursor` on the result resumes the
1027
+ * listing (it can also be persisted, e.g. across requests of a paginated UI).
1028
+ */
1029
+ async listPage(opts) {
1030
+ const { data, nextCursor } = await unwrapPage(this._client.GET("/api/disks", { params: { query: {
990
1031
  limit: opts?.limit,
991
1032
  cursor: opts?.cursor,
992
1033
  name: opts?.name
993
- } } }))).map((d) => new Disk(d, this._client, this._region, this._s3BaseUrl));
1034
+ } } }));
1035
+ const disks = (data ?? []).map((d) => new Disk(d, this._client, this._region, this._s3BaseUrl));
1036
+ return nextCursor ? {
1037
+ disks,
1038
+ nextCursor
1039
+ } : { disks };
994
1040
  }
995
1041
  async get(id) {
996
1042
  return new Disk(await unwrap(this._client.GET("/api/disks/{id}", { params: { path: { id } } })), this._client, this._region, this._s3BaseUrl);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "disk",
3
- "version": "0.8.19",
3
+ "version": "0.8.20",
4
4
  "description": "Pure-JS client and CLI for Archil disks",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -29,7 +29,7 @@
29
29
  "dependencies": {
30
30
  "@archildata/api-types": "^0.0.1",
31
31
  "commander": "^14.0.3",
32
- "fast-xml-parser": "^4.5.1",
32
+ "fast-xml-parser": "^5.7.0",
33
33
  "openapi-fetch": "^0.13.5",
34
34
  "zod": "^4.4.3"
35
35
  },