@dropthis/cli 0.23.0 → 0.24.1

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.
@@ -1,5 +1,5 @@
1
- import { O as Transport, v as DropthisResult, E as EmailOtpResponse, M as SessionResponse, C as CreateUploadSessionRequest, e as CreateUploadSessionResponse, W as UploadSessionResponse, t as DropthisClientOptions, d as ApiKeysResource, a as AccountResource, s as DropsResource, H as PublishInput, h as DeploymentsResource, m as DomainsResource, J as PublishOptions, z as PreparedPublishRequest } from './drops-DNwOp7g_.cjs';
2
- export { A as AccountLimits, b as AccountResponse, c as ActionResolve, f as CursorPage, D as DeploymentContentFile, g as DeploymentContentManifest, i as DnsRecord, j as DomainDeletedResponse, k as DomainListResponse, l as DomainResponse, n as DropAction, o as DropContentFile, p as DropDeploymentResponse, q as DropOptions, r as DropResponse, u as DropthisErrorResponse, G as GetContentOptions, I as InMemoryPublishInput, L as Limitations, w as ListDeploymentsParams, x as ListDeploymentsResponse, y as ListPage, N as NextHint, P as PrepareOptions, B as PreparedUploadFile, F as PublishFileInput, R as RequestControls, K as RequestOptions, S as SHARED_POOL, T as TierInfo, U as UpdateContentOptions, Q as UploadManifestFile, V as UploadSessionFileResponse, X as UploadTarget } from './drops-DNwOp7g_.cjs';
1
+ import { U as Transport, v as DropthisResult, E as EmailOtpResponse, Q as SessionResponse, C as CreateUploadSessionRequest, e as CreateUploadSessionResponse, Y as UploadSessionResponse, t as DropthisClientOptions, d as ApiKeysResource, a as AccountResource, s as DropsResource, H as PublishInput, h as DeploymentsResource, m as DomainsResource, J as PublishOptions, z as PreparedPublishRequest } from './drops-BVoN5MaZ.cjs';
2
+ export { A as AccountLimits, b as AccountResponse, c as ActionResolve, f as CursorPage, D as DeploymentContentFile, g as DeploymentContentManifest, i as DnsRecord, j as DomainDeletedResponse, k as DomainListResponse, l as DomainResponse, n as DropAction, o as DropContentFile, p as DropDeploymentResponse, q as DropOptions, r as DropResponse, u as DropthisErrorResponse, G as GetContentOptions, I as InMemoryPublishInput, K as KeyType, L as Limitations, w as ListDeploymentsParams, x as ListDeploymentsResponse, y as ListPage, N as NextHint, P as PrepareOptions, B as PreparedUploadFile, F as PublishFileInput, R as RequestControls, M as RequestOptions, O as RevokeImpact, S as SHARED_POOL, T as TierInfo, V as UpdateContentOptions, W as UploadManifestFile, X as UploadSessionFileResponse, Z as UploadTarget } from './drops-BVoN5MaZ.cjs';
3
3
 
4
4
  declare class AuthResource {
5
5
  private readonly transport;
@@ -7,6 +7,12 @@ declare class AuthResource {
7
7
  requestEmailOtp(input: {
8
8
  email: string;
9
9
  }): Promise<DropthisResult<EmailOtpResponse>>;
10
+ /**
11
+ * Verify an email OTP and exchange it for a short-lived `at_` session token.
12
+ * On failure the error `code` distinguishes `otp_expired` (no active code —
13
+ * request a new one) from `otp_invalid` (wrong digits — re-check, do not
14
+ * auto-resend). 401 on either. See dropthis#80.
15
+ */
10
16
  verifyEmailOtp(input: {
11
17
  email: string;
12
18
  code: string;
@@ -1,5 +1,5 @@
1
- import { O as Transport, v as DropthisResult, E as EmailOtpResponse, M as SessionResponse, C as CreateUploadSessionRequest, e as CreateUploadSessionResponse, W as UploadSessionResponse, t as DropthisClientOptions, d as ApiKeysResource, a as AccountResource, s as DropsResource, H as PublishInput, h as DeploymentsResource, m as DomainsResource, J as PublishOptions, z as PreparedPublishRequest } from './drops-DNwOp7g_.js';
2
- export { A as AccountLimits, b as AccountResponse, c as ActionResolve, f as CursorPage, D as DeploymentContentFile, g as DeploymentContentManifest, i as DnsRecord, j as DomainDeletedResponse, k as DomainListResponse, l as DomainResponse, n as DropAction, o as DropContentFile, p as DropDeploymentResponse, q as DropOptions, r as DropResponse, u as DropthisErrorResponse, G as GetContentOptions, I as InMemoryPublishInput, L as Limitations, w as ListDeploymentsParams, x as ListDeploymentsResponse, y as ListPage, N as NextHint, P as PrepareOptions, B as PreparedUploadFile, F as PublishFileInput, R as RequestControls, K as RequestOptions, S as SHARED_POOL, T as TierInfo, U as UpdateContentOptions, Q as UploadManifestFile, V as UploadSessionFileResponse, X as UploadTarget } from './drops-DNwOp7g_.js';
1
+ import { U as Transport, v as DropthisResult, E as EmailOtpResponse, Q as SessionResponse, C as CreateUploadSessionRequest, e as CreateUploadSessionResponse, Y as UploadSessionResponse, t as DropthisClientOptions, d as ApiKeysResource, a as AccountResource, s as DropsResource, H as PublishInput, h as DeploymentsResource, m as DomainsResource, J as PublishOptions, z as PreparedPublishRequest } from './drops-BVoN5MaZ.js';
2
+ export { A as AccountLimits, b as AccountResponse, c as ActionResolve, f as CursorPage, D as DeploymentContentFile, g as DeploymentContentManifest, i as DnsRecord, j as DomainDeletedResponse, k as DomainListResponse, l as DomainResponse, n as DropAction, o as DropContentFile, p as DropDeploymentResponse, q as DropOptions, r as DropResponse, u as DropthisErrorResponse, G as GetContentOptions, I as InMemoryPublishInput, K as KeyType, L as Limitations, w as ListDeploymentsParams, x as ListDeploymentsResponse, y as ListPage, N as NextHint, P as PrepareOptions, B as PreparedUploadFile, F as PublishFileInput, R as RequestControls, M as RequestOptions, O as RevokeImpact, S as SHARED_POOL, T as TierInfo, V as UpdateContentOptions, W as UploadManifestFile, X as UploadSessionFileResponse, Z as UploadTarget } from './drops-BVoN5MaZ.js';
3
3
 
4
4
  declare class AuthResource {
5
5
  private readonly transport;
@@ -7,6 +7,12 @@ declare class AuthResource {
7
7
  requestEmailOtp(input: {
8
8
  email: string;
9
9
  }): Promise<DropthisResult<EmailOtpResponse>>;
10
+ /**
11
+ * Verify an email OTP and exchange it for a short-lived `at_` session token.
12
+ * On failure the error `code` distinguishes `otp_expired` (no active code —
13
+ * request a new one) from `otp_invalid` (wrong digits — re-check, do not
14
+ * auto-resend). 401 on either. See dropthis#80.
15
+ */
10
16
  verifyEmailOtp(input: {
11
17
  email: string;
12
18
  code: string;
@@ -710,6 +710,12 @@ var AuthResource = class {
710
710
  authenticated: false
711
711
  });
712
712
  }
713
+ /**
714
+ * Verify an email OTP and exchange it for a short-lived `at_` session token.
715
+ * On failure the error `code` distinguishes `otp_expired` (no active code —
716
+ * request a new one) from `otp_invalid` (wrong digits — re-check, do not
717
+ * auto-resend). 401 on either. See dropthis#80.
718
+ */
713
719
  verifyEmailOtp(input) {
714
720
  return this.transport.request("POST", "/auth/email/verify", {
715
721
  body: input,
@@ -810,30 +816,50 @@ var CursorPage = class {
810
816
  data;
811
817
  hasMore;
812
818
  nextCursor;
819
+ /** Response headers from the fetch that produced this page. */
820
+ headers;
813
821
  fetchNextPage;
814
822
  constructor(input) {
815
823
  this.data = input.data;
816
824
  this.hasMore = input.hasMore;
817
825
  this.nextCursor = input.nextCursor;
826
+ this.headers = input.headers ?? {};
818
827
  this.fetchNextPage = input.fetchNextPage;
819
828
  }
829
+ /**
830
+ * Collect items across every page into a single array.
831
+ *
832
+ * No-throw, consistent with the rest of the SDK's {@link DropthisResult}
833
+ * contract: returns `{ data: items, error: null }` on success, or
834
+ * `{ data: null, error }` if fetching a later page fails — never a thrown
835
+ * exception, and never a silently truncated list. Inspect `.error`
836
+ * (`code`/`statusCode`/`retryable`/`requestId`) exactly as you would for any
837
+ * other call. Pass `limit` to stop once that many items are collected.
838
+ */
820
839
  async autoPagingToArray(options = {}) {
821
- const items = [];
822
- for await (const item of this) {
823
- items.push(item);
824
- if (options.limit !== void 0 && items.length >= options.limit) break;
840
+ const { limit } = options;
841
+ if (limit !== void 0 && limit <= 0) {
842
+ return { data: [], error: null, headers: this.headers };
825
843
  }
826
- return items;
827
- }
828
- async *[Symbol.asyncIterator]() {
829
- for (const item of this.data) yield item;
844
+ const items = [];
830
845
  let current = this;
831
- while (current.hasMore && current.fetchNextPage) {
846
+ let lastHeaders = this.headers;
847
+ while (current) {
848
+ for (const item of current.data) {
849
+ items.push(item);
850
+ if (limit !== void 0 && items.length >= limit) {
851
+ return { data: items, error: null, headers: lastHeaders };
852
+ }
853
+ }
854
+ if (!current.hasMore || !current.fetchNextPage) break;
832
855
  const next = await current.fetchNextPage();
833
- if (next.error) break;
856
+ if (next.error) {
857
+ return { data: null, error: next.error, headers: next.headers };
858
+ }
859
+ lastHeaders = next.headers;
834
860
  current = next.data;
835
- for (const item of current.data) yield item;
836
861
  }
862
+ return { data: items, error: null, headers: lastHeaders };
837
863
  }
838
864
  };
839
865
 
@@ -902,6 +928,7 @@ var DropsResource = class {
902
928
  data: result.data.drops,
903
929
  nextCursor: result.data.nextCursor,
904
930
  hasMore: result.data.nextCursor !== null,
931
+ headers: result.headers,
905
932
  fetchNextPage: result.data.nextCursor ? () => this.list({ ...params, cursor: result.data.nextCursor }) : void 0
906
933
  });
907
934
  return { data: page, error: null, headers: result.headers };
@@ -1085,7 +1112,7 @@ function toSnakeCase(value) {
1085
1112
 
1086
1113
  // src/transport.ts
1087
1114
  var DEFAULT_BASE_URL = "https://api.dropthis.app";
1088
- var SDK_VERSION = "0.20.0";
1115
+ var SDK_VERSION = "0.22.0";
1089
1116
  var Transport = class {
1090
1117
  apiKey;
1091
1118
  baseUrl;
@@ -1124,7 +1151,10 @@ var Transport = class {
1124
1151
  `signed_upload_${response.status}`,
1125
1152
  text || response.statusText,
1126
1153
  response.status,
1127
- { headers: responseHeaders }
1154
+ // A 5xx from object storage is a transient upstream failure — safe to
1155
+ // re-PUT. A 4xx (e.g. 403 expired/denied signed URL) won't fix itself on
1156
+ // a blind retry, so leave it unmarked.
1157
+ { headers: responseHeaders, retryable: response.status >= 500 }
1128
1158
  );
1129
1159
  }
1130
1160
  return {
@@ -1139,7 +1169,8 @@ var Transport = class {
1139
1169
  return createErrorResult(
1140
1170
  error instanceof Error && error.name === "AbortError" ? "timeout" : "network_error",
1141
1171
  message,
1142
- null
1172
+ null,
1173
+ { retryable: true }
1143
1174
  );
1144
1175
  } finally {
1145
1176
  clearTimeout(timeout);
@@ -1196,7 +1227,8 @@ var Transport = class {
1196
1227
  return createErrorResult(
1197
1228
  error instanceof Error && error.name === "AbortError" ? "timeout" : "network_error",
1198
1229
  message,
1199
- null
1230
+ null,
1231
+ { retryable: true }
1200
1232
  );
1201
1233
  } finally {
1202
1234
  clearTimeout(timeout);
@@ -1257,10 +1289,12 @@ var Transport = class {
1257
1289
  };
1258
1290
  } catch (error) {
1259
1291
  const message = error instanceof Error && error.name === "AbortError" ? "Request timed out" : error instanceof Error ? error.message : "Network error";
1292
+ const retrySafe = method.toUpperCase() === "GET" || options.idempotencyKey !== void 0;
1260
1293
  return createErrorResult(
1261
1294
  error instanceof Error && error.name === "AbortError" ? "timeout" : "network_error",
1262
1295
  message,
1263
- null
1296
+ null,
1297
+ retrySafe ? { retryable: true } : {}
1264
1298
  );
1265
1299
  } finally {
1266
1300
  clearTimeout(timeout);