@dropthis/cli 0.9.3 → 0.11.0

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.
@@ -153,6 +153,17 @@ type ApiKeyCreatedResponse = ApiKeyResponse & {
153
153
  accountId?: string | null;
154
154
  isNewAccount?: boolean;
155
155
  };
156
+ /** Active plan tier limits — use these to size a publish before uploading. */
157
+ type AccountLimits = {
158
+ /** Plan tier the limits apply to. */
159
+ name: string;
160
+ /** Maximum size of a single drop in bytes. */
161
+ maxSizeBytes: number;
162
+ /** Drop lifetime in seconds before expiry; null means drops are permanent. */
163
+ defaultTtlSeconds: number | null;
164
+ /** Total account storage cap in bytes; null means no account-level cap. */
165
+ maxStorageBytes: number | null;
166
+ };
156
167
  type AccountResponse = {
157
168
  id: string;
158
169
  email: string;
@@ -160,6 +171,7 @@ type AccountResponse = {
160
171
  plan: string;
161
172
  status: string;
162
173
  createdAt: string;
174
+ limits: AccountLimits;
163
175
  };
164
176
  type ListDropsParams = {
165
177
  cursor?: string | null;
@@ -177,7 +189,8 @@ type CreateUploadSessionRequest = {
177
189
  entry?: string | null;
178
190
  };
179
191
  type UploadTarget = {
180
- strategy: "single_put" | "multipart";
192
+ /** Always `single_put` one signed PUT per file is the upload contract. */
193
+ strategy: "single_put";
181
194
  url: string;
182
195
  headers: Record<string, string>;
183
196
  expiresAt: string;
@@ -210,14 +223,6 @@ type CreateUploadSessionResponse = {
210
223
  files: CreateUploadSessionFileResponse[];
211
224
  nextAction?: Action | null;
212
225
  };
213
- type CompleteUploadSessionRequest = {
214
- files?: Record<string, {
215
- parts?: Array<{
216
- partNumber: number;
217
- etag: string;
218
- }> | null;
219
- }>;
220
- };
221
226
  type DropOptions = {
222
227
  /** Drop title. */
223
228
  title?: string;
@@ -233,6 +238,20 @@ type DropOptions = {
233
238
  entry?: string;
234
239
  /** Attach JSON key-value pairs, e.g. `{ source: "ci" }`. */
235
240
  metadata?: Record<string, unknown>;
241
+ /**
242
+ * Hostname of a custom domain connected to this account (must be live — see
243
+ * `client.domains`). Path-mode domains serve the drop at `https://{domain}/{slug}/`;
244
+ * dedicated domains serve it at the root and conflict (409) once occupied. Omit to
245
+ * use the account's default path domain if one exists, else the shared pool.
246
+ */
247
+ domain?: string | null;
248
+ /**
249
+ * Vanity slug — only valid when the target is a path-mode custom domain. 1–63
250
+ * lowercase letters/digits/hyphens (no leading/trailing/double hyphen). Taken slugs
251
+ * are auto-suffixed; omit for a random slug. Setting this on the shared pool returns
252
+ * 422.
253
+ */
254
+ slug?: string | null;
236
255
  };
237
256
  type PrepareOptions = {
238
257
  /** Glob patterns to ignore when publishing directories. */
@@ -281,6 +300,119 @@ type PublishInput = string | string[] | URL | Uint8Array | {
281
300
  files: PublishFileInput[];
282
301
  entry?: string;
283
302
  };
303
+ /** Structured next-step hint returned by domain operations (and publish). */
304
+ type NextHint = {
305
+ action: string;
306
+ message: string;
307
+ };
308
+ /** One DNS record instruction or diagnostic for a custom domain. */
309
+ type DnsRecord = {
310
+ /** Purpose of the record, e.g. "routing". */
311
+ purpose: string;
312
+ /** DNS record type, e.g. "CNAME". */
313
+ type: string;
314
+ /** The DNS name to create the record for. */
315
+ name: string;
316
+ /** The value the record must point at. */
317
+ value: string;
318
+ /** Current DNS status: "missing" | "ok" | "mismatch". */
319
+ status: "missing" | "ok" | "mismatch";
320
+ /** What DoH currently resolves for this record (verify only). */
321
+ observed?: string | null;
322
+ /** Specific guidance for fixing this record. */
323
+ hint?: string | null;
324
+ /** Seconds to wait before retrying verify while DNS/cert propagates. */
325
+ retryAfter?: number | null;
326
+ };
327
+ /** Full domain resource representation. */
328
+ type DomainResponse = {
329
+ object: "domain";
330
+ /** Stable domain identifier. */
331
+ id: string;
332
+ /** Canonical hostname registered with dropthis. */
333
+ hostname: string;
334
+ /** Mount mode: "path" (many drops at hostname/{slug}/) or "dedicated" (one drop at hostname/). */
335
+ mode: "path" | "dedicated";
336
+ /** Lifecycle status: "pending_dns" | "verifying" | "live" | "failed". */
337
+ status: "pending_dns" | "verifying" | "live" | "failed";
338
+ /** Reason for failure status. */
339
+ failureReason?: string | null;
340
+ /** Whether this is the account's default publish domain. */
341
+ default: boolean;
342
+ /** Mounted drop id (dedicated mode only). */
343
+ dropId?: string | null;
344
+ /** DNS records required for this domain. */
345
+ dns: DnsRecord[];
346
+ /** Creation timestamp. */
347
+ createdAt: string;
348
+ /** When the domain first reached "live" status. */
349
+ verifiedAt?: string | null;
350
+ /** Structured next-step hints for the agent. */
351
+ next: NextHint[];
352
+ };
353
+ /** List of domains for the account. */
354
+ type DomainListResponse = {
355
+ object: "domain.list";
356
+ /** Domains connected to this account. */
357
+ domains: DomainResponse[];
358
+ };
359
+ /** Response body for a successful domain deletion. */
360
+ type DomainDeletedResponse = {
361
+ object: "domain.deleted";
362
+ /** Id of the deleted domain. */
363
+ id: string;
364
+ /** Hostname of the deleted domain. */
365
+ hostname: string;
366
+ /** Dangling-CNAME risk warning (always present; instructs you to remove the DNS record). */
367
+ warning: string;
368
+ };
369
+ /** One readable file in a deployment's content manifest. */
370
+ type DeploymentContentFile = {
371
+ /** File path within the deployment, relative to its root. */
372
+ path: string;
373
+ /** Stored MIME type the file is served with. */
374
+ contentType: string;
375
+ /** Stored file size in bytes. */
376
+ sizeBytes: number;
377
+ };
378
+ /**
379
+ * Manifest of one deployment's readable files (content read-back).
380
+ * Fetch a single file's bytes with `drops.getContent(dropId, { path })`.
381
+ */
382
+ type DeploymentContentManifest = {
383
+ /** Parent drop identifier. */
384
+ dropId: string;
385
+ /** Deployment identifier. */
386
+ deploymentId: string;
387
+ /** Content revision of this deployment. */
388
+ revision: number;
389
+ /** Deployment lifecycle status. */
390
+ status: string;
391
+ /** Total deployment size in bytes. */
392
+ sizeBytes: number;
393
+ /** Entry path served at the drop root. */
394
+ entry?: string | null;
395
+ /** Readable files in this deployment; pass files[].path as `path` to download one. */
396
+ files: DeploymentContentFile[];
397
+ };
398
+ /** Options for `drops.getContent()`. */
399
+ type GetContentOptions = {
400
+ /** Read a historical deployment instead of the current one. */
401
+ deploymentId?: string;
402
+ /** Download this single file's raw stored bytes instead of the JSON manifest. */
403
+ path?: string;
404
+ };
405
+ /** A single file downloaded via `drops.getContent(dropId, { path })`. */
406
+ type DropContentFile = {
407
+ /** The requested file path. */
408
+ path: string;
409
+ /** Stored MIME type the file is served with (from the response Content-Type). */
410
+ contentType: string | null;
411
+ /** Exact stored bytes. */
412
+ bytes: Uint8Array;
413
+ /** Decode the bytes as UTF-8 text. */
414
+ text(): string;
415
+ };
284
416
 
285
417
  declare class Transport {
286
418
  readonly apiKey: string | undefined;
@@ -292,6 +424,17 @@ declare class Transport {
292
424
  putSignedUrl(url: string, body: Uint8Array | Blob | ReadableStream, headers: Record<string, string>): Promise<DropthisResult<{
293
425
  etag: string | null;
294
426
  }>>;
427
+ /**
428
+ * Authenticated GET that returns the raw response bytes untouched (no JSON parsing,
429
+ * no case conversion). Error responses are still parsed as problem+json. Used for
430
+ * content read-back (`drops.getContent` with a file path).
431
+ */
432
+ requestBytes(path: string, options?: RequestOptions & {
433
+ params?: Record<string, string | number | boolean | null | undefined>;
434
+ }): Promise<DropthisResult<{
435
+ bytes: Uint8Array;
436
+ contentType: string | null;
437
+ }>>;
295
438
  request<T>(method: string, path: string, options?: RequestOptions & {
296
439
  body?: unknown;
297
440
  bodyCase?: "snake" | "raw";
@@ -372,9 +515,8 @@ declare class ApiKeysResource {
372
515
  create(input: {
373
516
  label: string;
374
517
  }): Promise<DropthisResult<ApiKeyCreatedResponse>>;
375
- delete(keyId: string): Promise<DropthisResult<{
376
- ok: true;
377
- }>>;
518
+ /** Revoke an API key. 204 No Content — data is null on success. */
519
+ delete(keyId: string): Promise<DropthisResult<null>>;
378
520
  }
379
521
 
380
522
  declare class DeploymentsResource {
@@ -384,6 +526,45 @@ declare class DeploymentsResource {
384
526
  get(dropId: string, deploymentId: string): Promise<DropthisResult<DropDeploymentResponse>>;
385
527
  }
386
528
 
529
+ declare class DomainsResource {
530
+ private readonly transport;
531
+ constructor(transport: Transport);
532
+ /**
533
+ * Connect a custom domain to the account. Returns the domain in `pending_dns` status with
534
+ * DNS instructions. Idempotent on (account, hostname) — re-connecting an already-connected
535
+ * domain returns the existing row. POST /domains.
536
+ */
537
+ connect(input: {
538
+ hostname: string;
539
+ mode: "path" | "dedicated";
540
+ }): Promise<DropthisResult<DomainResponse>>;
541
+ /** List all custom domains connected to this account. GET /domains. */
542
+ list(): Promise<DropthisResult<DomainListResponse>>;
543
+ /** Get a domain by its stable id or hostname. GET /domains/{id_or_hostname}. */
544
+ get(idOrHostname: string): Promise<DropthisResult<DomainResponse>>;
545
+ /**
546
+ * Trigger a DNS + Cloudflare verification check. Returns the domain with updated status and
547
+ * per-record diagnostics. If DNS is still propagating, `dns[].retryAfter` tells you when to
548
+ * re-call. POST /domains/{id_or_hostname}/verify.
549
+ */
550
+ verify(idOrHostname: string): Promise<DropthisResult<DomainResponse>>;
551
+ /**
552
+ * Update a domain's `dropId` (dedicated mode: repoint to a different drop) or `default`
553
+ * flag (path mode only: set/clear the account's default publish domain). Mode is immutable
554
+ * — delete and reconnect to change it. PATCH /domains/{id_or_hostname}.
555
+ */
556
+ update(idOrHostname: string, input: {
557
+ dropId?: string | null;
558
+ default?: boolean | null;
559
+ }): Promise<DropthisResult<DomainResponse>>;
560
+ /**
561
+ * Delete a custom domain and remove all its routes. The response includes a dangling-CNAME
562
+ * warning — remove the DNS record after deleting so another account cannot re-claim the
563
+ * hostname. DELETE /domains/{id_or_hostname}.
564
+ */
565
+ delete(idOrHostname: string): Promise<DropthisResult<DomainDeletedResponse>>;
566
+ }
567
+
387
568
  declare class CursorPage<T> implements ListPage<T> {
388
569
  readonly object: "list";
389
570
  readonly data: T[];
@@ -410,8 +591,15 @@ declare class CursorPage<T> implements ListPage<T> {
410
591
  */
411
592
  declare class DropsResource<TInput = PublishInput> {
412
593
  private readonly transport;
413
- private readonly resolve;
414
- constructor(transport: Transport, resolve: PublishInputResolver<TInput>);
594
+ private readonly resolveInput;
595
+ private parentHosts?;
596
+ constructor(transport: Transport, resolveInput: PublishInputResolver<TInput>);
597
+ /**
598
+ * Hostnames the SDK can attribute to dropthis for slug parsing: the canonical
599
+ * viewer domain plus the configured baseUrl's host (covers staging/self-hosted
600
+ * setups where drops are served under the API's own domain).
601
+ */
602
+ private allowedParentHosts;
415
603
  /**
416
604
  * Publish content to a NEW permanent public URL; returns the created drop (with its `drop_…` id).
417
605
  * Use to publish / share / post / put online / make public a report, dashboard, site, or file.
@@ -432,14 +620,44 @@ declare class DropsResource<TInput = PublishInput> {
432
620
  list(params?: ListDropsParams): Promise<DropthisResult<CursorPage<DropResponse>>>;
433
621
  /** Fetch one drop by its `drop_…` id (not the slug/URL). GET /drops/{id}. */
434
622
  get(dropId: string): Promise<DropthisResult<DropResponse>>;
623
+ /**
624
+ * Resolve a drop URL (or bare slug) back to the drop — the way to recover a lost
625
+ * `drop_…` id. The slug is parsed client-side from the first hostname label of a
626
+ * dropthis-attributable hostname (`https://<slug>.dropthis.app/…`, or `<slug>.` +
627
+ * the configured baseUrl's host), then matched owner-scoped via GET /drops?slug=.
628
+ * Returns the drop, or `data: null` when no drop of yours has that slug.
629
+ * Custom-domain URLs are rejected client-side with `invalid_drop_url` — they are
630
+ * not resolvable yet.
631
+ */
632
+ resolve(urlOrSlug: string): Promise<DropthisResult<DropResponse | null>>;
633
+ /**
634
+ * Read back what a drop is serving (owner-only; works regardless of any viewer
635
+ * password). By default returns the JSON manifest of the CURRENT deployment's files;
636
+ * pass `deploymentId` to read a historical (even superseded) deployment — downloading
637
+ * an old version's files and republishing them via {@link updateContent} is the
638
+ * rollback path. Pass `path` (one of the manifest's `files[].path` values) to download
639
+ * that file's exact stored bytes instead. GET /drops/{id}/content.
640
+ */
641
+ getContent(dropId: string, options: GetContentOptions & {
642
+ path: string;
643
+ }): Promise<DropthisResult<DropContentFile>>;
644
+ getContent(dropId: string, options?: Omit<GetContentOptions, "path">): Promise<DropthisResult<DeploymentContentManifest>>;
435
645
  /**
436
646
  * Change an EXISTING drop's settings — title, visibility, password, noindex, expiry,
437
- * metadata — by its `drop_…` id. Does not touch content; replace that with {@link updateContent}.
438
- * Idempotent. PATCH /drops/{id}.
647
+ * metadata, domain, or slug — by its `drop_…` id. Does not touch content; replace that
648
+ * with {@link updateContent}. Idempotent. PATCH /drops/{id}.
649
+ *
650
+ * **`domain`** — move the drop to a different custom domain (must be live). Pass `null` to
651
+ * move the drop back to the shared pool (unmount from its current domain).
652
+ *
653
+ * **`slug`** — rename the vanity slug on a path-mode custom domain. Only valid when the drop
654
+ * lives on a path-mode domain. Unlike {@link publish} (which auto-suffixes taken slugs),
655
+ * `updateSettings` returns 409 on a slug conflict and never auto-suffixes — your code must
656
+ * catch 409 and retry with a different slug. Passing `slug` on the shared pool returns 422.
439
657
  */
440
658
  updateSettings(dropId: string, options?: DropOptions & RequestControls): Promise<DropthisResult<DropResponse>>;
441
659
  /** Permanently delete a drop and its public URL by its `drop_…` id. DELETE /drops/{id}. */
442
660
  delete(dropId: string): Promise<DropthisResult<null>>;
443
661
  }
444
662
 
445
- export { AccountResource as A, type UploadTarget as B, type CompleteUploadSessionRequest as C, DeploymentsResource as D, type EmailOtpResponse as E, type InMemoryPublishInput as I, type Limitations as L, type PrepareOptions as P, type RequestControls as R, type SessionResponse as S, type TierInfo as T, type UpdateContentOptions as U, type ActionResolve as a, ApiKeysResource as b, type CreateUploadSessionRequest as c, type CreateUploadSessionResponse as d, CursorPage as e, type DropAction as f, type DropDeploymentResponse as g, type DropOptions as h, type DropResponse as i, DropsResource as j, type DropthisClientOptions as k, type DropthisErrorResponse as l, type DropthisResult as m, type ListDeploymentsParams as n, type ListDeploymentsResponse as o, type ListPage as p, type PreparedPublishRequest as q, type PreparedUploadFile as r, type PublishFileInput as s, type PublishInput as t, type PublishOptions as u, type RequestOptions as v, Transport as w, type UploadManifestFile as x, type UploadSessionFileResponse as y, type UploadSessionResponse as z };
663
+ export { type AccountLimits as A, type PreparedUploadFile as B, type CreateUploadSessionRequest as C, type DeploymentContentFile as D, type EmailOtpResponse as E, type PublishFileInput as F, type GetContentOptions as G, type PublishInput as H, type InMemoryPublishInput as I, type PublishOptions as J, type RequestOptions as K, type Limitations as L, Transport as M, type NextHint as N, type UploadManifestFile as O, type PrepareOptions as P, type UploadSessionFileResponse as Q, type RequestControls as R, type SessionResponse as S, type TierInfo as T, type UpdateContentOptions as U, type UploadSessionResponse as V, type UploadTarget as W, AccountResource as a, type AccountResponse as b, type ActionResolve as c, ApiKeysResource as d, type CreateUploadSessionResponse as e, CursorPage as f, type DeploymentContentManifest as g, DeploymentsResource as h, type DnsRecord as i, type DomainDeletedResponse as j, type DomainListResponse as k, type DomainResponse as l, DomainsResource as m, type DropAction as n, type DropContentFile as o, type DropDeploymentResponse as p, type DropOptions as q, type DropResponse as r, DropsResource as s, type DropthisClientOptions as t, type DropthisErrorResponse as u, type DropthisResult as v, type ListDeploymentsParams as w, type ListDeploymentsResponse as x, type ListPage as y, type PreparedPublishRequest as z };