@dropthis/cli 0.8.0 → 0.9.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.
@@ -14,7 +14,7 @@ npm install @dropthis/node
14
14
  import { Dropthis } from "@dropthis/node";
15
15
 
16
16
  const dropthis = new Dropthis({ apiKey: "sk_..." });
17
- const { data, error } = await dropthis.publish("<h1>Hello</h1>");
17
+ const { data, error } = await dropthis.drops.publish("<h1>Hello</h1>");
18
18
 
19
19
  console.log(data.url); // https://abc123.dropthis.app
20
20
  ```
@@ -24,25 +24,25 @@ console.log(data.url); // https://abc123.dropthis.app
24
24
  ### Publish an HTML string
25
25
 
26
26
  ```typescript
27
- const { data } = await dropthis.publish("<h1>Launch page</h1>");
27
+ const { data } = await dropthis.drops.publish("<h1>Launch page</h1>");
28
28
  ```
29
29
 
30
30
  ### Publish a file
31
31
 
32
32
  ```typescript
33
- const { data } = await dropthis.publish("./report.html");
33
+ const { data } = await dropthis.drops.publish("./report.html");
34
34
  ```
35
35
 
36
36
  ### Publish a directory
37
37
 
38
38
  ```typescript
39
- const { data } = await dropthis.publish("./dist");
39
+ const { data } = await dropthis.drops.publish("./dist");
40
40
  ```
41
41
 
42
42
  ### Publish with options
43
43
 
44
44
  ```typescript
45
- const { data } = await dropthis.publish("./dist", {
45
+ const { data } = await dropthis.drops.publish("./dist", {
46
46
  title: "Q4 Report",
47
47
  visibility: "unlisted",
48
48
  password: "s3cret",
@@ -50,25 +50,25 @@ const { data } = await dropthis.publish("./dist", {
50
50
  });
51
51
  ```
52
52
 
53
- ### Deploy new content to an existing drop
53
+ ### Update the content of an existing drop
54
54
 
55
55
  ```typescript
56
- const created = await dropthis.publish("./dist", { title: "v1" });
56
+ const created = await dropthis.drops.publish("./dist", { title: "v1" });
57
57
 
58
- const updated = await dropthis.deploy(created.data.id, "./dist-v2", {
58
+ const updated = await dropthis.drops.updateContent(created.data.id, "./dist-v2", {
59
59
  ifRevision: created.data.revision,
60
60
  });
61
61
  ```
62
62
 
63
- ### Update metadata only
63
+ ### Update settings only
64
64
 
65
65
  ```typescript
66
- await dropthis.update("drop_abc123", { title: "New title" });
66
+ await dropthis.drops.updateSettings("drop_abc123", { title: "New title" });
67
67
  ```
68
68
 
69
69
  ## Supported inputs
70
70
 
71
- The `publish()` and `deploy()` methods accept:
71
+ The `drops.publish()` and `drops.updateContent()` methods accept:
72
72
 
73
73
  - **HTML/text string** -- `"<h1>Hello</h1>"` (auto-detected as inline content)
74
74
  - **File path** -- `"./report.html"` (local file)
@@ -88,20 +88,20 @@ All inputs are uploaded through staged presigned URLs. The SDK handles this tran
88
88
 
89
89
  ```typescript
90
90
  // Inline content with explicit MIME type
91
- await dropthis.publish({
91
+ await dropthis.drops.publish({
92
92
  kind: "content",
93
93
  content: "<h1>Hello</h1>",
94
94
  contentType: "text/html",
95
95
  });
96
96
 
97
97
  // Fetch and re-publish a remote URL
98
- await dropthis.publish({
98
+ await dropthis.drops.publish({
99
99
  kind: "source_url",
100
100
  sourceUrl: "https://example.com/report",
101
101
  });
102
102
 
103
103
  // Multi-file bundle with explicit entry point
104
- await dropthis.publish(
104
+ await dropthis.drops.publish(
105
105
  {
106
106
  kind: "files",
107
107
  files: [
@@ -174,7 +174,7 @@ const dropthis = new Dropthis("sk_...");
174
174
  ```typescript
175
175
  await dropthis.drops.list({ limit: 20 });
176
176
  await dropthis.drops.get("drop_abc123");
177
- await dropthis.drops.update("drop_abc123", { title: "Updated" });
177
+ await dropthis.drops.updateSettings("drop_abc123", { title: "Updated" });
178
178
  await dropthis.drops.delete("drop_abc123");
179
179
  ```
180
180
 
@@ -190,7 +190,7 @@ for await (const drop of page.data) {
190
190
  }
191
191
  ```
192
192
 
193
- > To change a drop's content, use `client.deploy(dropId, newInput)`. `drops.update()` is for settings only (title, visibility, password, noindex, expiresAt, slug, metadata).
193
+ > To change a drop's content, use `client.drops.updateContent(dropId, newInput)`. `drops.updateSettings()` is for settings only (title, visibility, password, noindex, expiresAt, slug, metadata).
194
194
 
195
195
  ### deployments
196
196
 
@@ -245,12 +245,12 @@ Use the fs-free entry point for Cloudflare Workers and other edge runtimes. It d
245
245
  import { DropthisEdge } from "@dropthis/node/edge";
246
246
 
247
247
  const dropthis = new DropthisEdge({ apiKey: env.DROPTHIS_API_KEY });
248
- const { data, error } = await dropthis.publish("<h1>Hello from the edge</h1>");
248
+ const { data, error } = await dropthis.drops.publish("<h1>Hello from the edge</h1>");
249
249
  ```
250
250
 
251
251
  `DropthisEdge` accepts the in-memory subset of `PublishInput`: inline strings, `Uint8Array`, `URL`, and the explicit `{ kind: "content" }`, `{ kind: "source_url" }`, and `{ kind: "files" }` forms. Local file paths and `string[]` path arrays are not supported (no filesystem on the edge).
252
252
 
253
- `DropthisEdge` exposes the same `publish(input, options?)` and `deploy(dropId, input, options?)` methods, plus the `drops`, `deployments`, `account`, and `apiKeys` resource accessors.
253
+ `DropthisEdge` exposes the drop lifecycle through `drops.publish(input, options?)`, `drops.updateContent(dropId, input, options?)`, `drops.updateSettings`, `drops.get`, `drops.list`, and `drops.delete`, plus the `deployments`, `account`, and `apiKeys` resource accessors — the same surface as the Node client.
254
254
 
255
255
  ## Types
256
256
 
@@ -254,11 +254,12 @@ type RequestControls = {
254
254
  };
255
255
  type PublishOptions = DropOptions & PrepareOptions & RequestControls;
256
256
  /**
257
- * Options for `deploy()` — content-only. A deployment ships a new content version and never
258
- * changes drop settings (title, visibility, password, noindex, expiry, metadata); those belong
259
- * on `update()`. Carries only content-prep + request controls + the bundle `entry`.
257
+ * Options for `drops.updateContent()` — content-only. A content update ships a new content version
258
+ * and never changes drop settings (title, visibility, password, noindex, expiry, metadata); those
259
+ * belong on `drops.updateSettings()`. Carries only content-prep + request controls + the bundle
260
+ * `entry`.
260
261
  */
261
- type DeployOptions = PrepareOptions & RequestControls & {
262
+ type UpdateContentOptions = PrepareOptions & RequestControls & {
262
263
  /** Entry file for multi-file bundles (default: index.html). */
263
264
  entry?: string;
264
265
  };
@@ -313,6 +314,15 @@ type PreparedUploadFile = {
313
314
  checksumSha256?: string;
314
315
  getBody(): Promise<Uint8Array | Blob | ReadableStream>;
315
316
  };
317
+ /**
318
+ * Resolves a publish input into a {@link PreparedPublishRequest}. Two implementations exist:
319
+ * the fs-free {@link resolveInMemory} (Workers-safe) and the fs-capable `resolveInput` in
320
+ * `publish/node.ts`. `DropsResource` takes one by injection so it can power both the Node client
321
+ * and the edge client WITHOUT statically importing the Node-only pipeline (which would poison the
322
+ * Workers bundle with `node:fs`/`fast-glob`). `TInput` is the input type the chosen resolver
323
+ * accepts ({@link InMemoryPublishInput} on the edge, the full `PublishInput` on Node).
324
+ */
325
+ type PublishInputResolver<TInput> = (input: TInput, options: PublishOptions) => Promise<PreparedPublishRequest>;
316
326
  type PreparedPublishRequest = {
317
327
  kind: "staged";
318
328
  manifest: CreateUploadSessionRequest;
@@ -394,13 +404,29 @@ declare class CursorPage<T> implements ListPage<T> {
394
404
  [Symbol.asyncIterator](): AsyncIterableIterator<T>;
395
405
  }
396
406
 
397
- declare class DropsResource {
407
+ /**
408
+ * The drop lifecycle resource. `TInput` is the publish-input type the injected resolver accepts:
409
+ * the full `PublishInput` on the Node client, the fs-free `InMemoryPublishInput` on the edge. The
410
+ * resolver is injected (not statically imported) so this module never pulls in the Node-only
411
+ * publish pipeline and stays Workers-safe.
412
+ */
413
+ declare class DropsResource<TInput = PublishInput> {
398
414
  private readonly transport;
399
- constructor(transport: Transport);
415
+ private readonly resolve;
416
+ constructor(transport: Transport, resolve: PublishInputResolver<TInput>);
417
+ /** Publish a NEW drop. Returns the created drop. Hits POST /drops. */
418
+ publish(input: TInput, options?: PublishOptions): Promise<DropthisResult<DropResponse>>;
419
+ /**
420
+ * Publish a NEW content version to an existing drop, keeping its URL.
421
+ * Content-only: drop settings/metadata are stripped BEFORE prepare so they are never
422
+ * validated, sent, or applied. Settings are owned by updateSettings(). Hits
423
+ * POST /drops/{id}/deployments.
424
+ */
425
+ updateContent(dropId: string, input: TInput, options?: UpdateContentOptions): Promise<DropthisResult<DropResponse>>;
400
426
  list(params?: ListDropsParams): Promise<DropthisResult<CursorPage<DropResponse>>>;
401
427
  get(dropId: string): Promise<DropthisResult<DropResponse>>;
402
- update(dropId: string, options?: DropOptions & RequestControls): Promise<DropthisResult<DropResponse>>;
428
+ updateSettings(dropId: string, options?: DropOptions & RequestControls): Promise<DropthisResult<DropResponse>>;
403
429
  delete(dropId: string): Promise<DropthisResult<null>>;
404
430
  }
405
431
 
406
- export { AccountResource as A, type UploadTarget as B, type CompleteUploadSessionRequest as C, type DeployOptions 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 UploadManifestFile as U, type ActionResolve as a, ApiKeysResource as b, type CreateUploadSessionRequest as c, type CreateUploadSessionResponse as d, CursorPage as e, DeploymentsResource as f, type DropAction as g, type DropDeploymentResponse as h, type DropOptions as i, type DropResponse as j, DropsResource as k, type DropthisClientOptions as l, type DropthisErrorResponse as m, type DropthisResult as n, type ListDeploymentsParams as o, type ListDeploymentsResponse as p, type ListPage as q, type PreparedPublishRequest as r, type PreparedUploadFile as s, type PublishFileInput as t, type PublishInput as u, type PublishOptions as v, type RequestOptions as w, Transport as x, type UploadSessionFileResponse as y, type UploadSessionResponse as z };
432
+ 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 };
@@ -254,11 +254,12 @@ type RequestControls = {
254
254
  };
255
255
  type PublishOptions = DropOptions & PrepareOptions & RequestControls;
256
256
  /**
257
- * Options for `deploy()` — content-only. A deployment ships a new content version and never
258
- * changes drop settings (title, visibility, password, noindex, expiry, metadata); those belong
259
- * on `update()`. Carries only content-prep + request controls + the bundle `entry`.
257
+ * Options for `drops.updateContent()` — content-only. A content update ships a new content version
258
+ * and never changes drop settings (title, visibility, password, noindex, expiry, metadata); those
259
+ * belong on `drops.updateSettings()`. Carries only content-prep + request controls + the bundle
260
+ * `entry`.
260
261
  */
261
- type DeployOptions = PrepareOptions & RequestControls & {
262
+ type UpdateContentOptions = PrepareOptions & RequestControls & {
262
263
  /** Entry file for multi-file bundles (default: index.html). */
263
264
  entry?: string;
264
265
  };
@@ -313,6 +314,15 @@ type PreparedUploadFile = {
313
314
  checksumSha256?: string;
314
315
  getBody(): Promise<Uint8Array | Blob | ReadableStream>;
315
316
  };
317
+ /**
318
+ * Resolves a publish input into a {@link PreparedPublishRequest}. Two implementations exist:
319
+ * the fs-free {@link resolveInMemory} (Workers-safe) and the fs-capable `resolveInput` in
320
+ * `publish/node.ts`. `DropsResource` takes one by injection so it can power both the Node client
321
+ * and the edge client WITHOUT statically importing the Node-only pipeline (which would poison the
322
+ * Workers bundle with `node:fs`/`fast-glob`). `TInput` is the input type the chosen resolver
323
+ * accepts ({@link InMemoryPublishInput} on the edge, the full `PublishInput` on Node).
324
+ */
325
+ type PublishInputResolver<TInput> = (input: TInput, options: PublishOptions) => Promise<PreparedPublishRequest>;
316
326
  type PreparedPublishRequest = {
317
327
  kind: "staged";
318
328
  manifest: CreateUploadSessionRequest;
@@ -394,13 +404,29 @@ declare class CursorPage<T> implements ListPage<T> {
394
404
  [Symbol.asyncIterator](): AsyncIterableIterator<T>;
395
405
  }
396
406
 
397
- declare class DropsResource {
407
+ /**
408
+ * The drop lifecycle resource. `TInput` is the publish-input type the injected resolver accepts:
409
+ * the full `PublishInput` on the Node client, the fs-free `InMemoryPublishInput` on the edge. The
410
+ * resolver is injected (not statically imported) so this module never pulls in the Node-only
411
+ * publish pipeline and stays Workers-safe.
412
+ */
413
+ declare class DropsResource<TInput = PublishInput> {
398
414
  private readonly transport;
399
- constructor(transport: Transport);
415
+ private readonly resolve;
416
+ constructor(transport: Transport, resolve: PublishInputResolver<TInput>);
417
+ /** Publish a NEW drop. Returns the created drop. Hits POST /drops. */
418
+ publish(input: TInput, options?: PublishOptions): Promise<DropthisResult<DropResponse>>;
419
+ /**
420
+ * Publish a NEW content version to an existing drop, keeping its URL.
421
+ * Content-only: drop settings/metadata are stripped BEFORE prepare so they are never
422
+ * validated, sent, or applied. Settings are owned by updateSettings(). Hits
423
+ * POST /drops/{id}/deployments.
424
+ */
425
+ updateContent(dropId: string, input: TInput, options?: UpdateContentOptions): Promise<DropthisResult<DropResponse>>;
400
426
  list(params?: ListDropsParams): Promise<DropthisResult<CursorPage<DropResponse>>>;
401
427
  get(dropId: string): Promise<DropthisResult<DropResponse>>;
402
- update(dropId: string, options?: DropOptions & RequestControls): Promise<DropthisResult<DropResponse>>;
428
+ updateSettings(dropId: string, options?: DropOptions & RequestControls): Promise<DropthisResult<DropResponse>>;
403
429
  delete(dropId: string): Promise<DropthisResult<null>>;
404
430
  }
405
431
 
406
- export { AccountResource as A, type UploadTarget as B, type CompleteUploadSessionRequest as C, type DeployOptions 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 UploadManifestFile as U, type ActionResolve as a, ApiKeysResource as b, type CreateUploadSessionRequest as c, type CreateUploadSessionResponse as d, CursorPage as e, DeploymentsResource as f, type DropAction as g, type DropDeploymentResponse as h, type DropOptions as i, type DropResponse as j, DropsResource as k, type DropthisClientOptions as l, type DropthisErrorResponse as m, type DropthisResult as n, type ListDeploymentsParams as o, type ListDeploymentsResponse as p, type ListPage as q, type PreparedPublishRequest as r, type PreparedUploadFile as s, type PublishFileInput as t, type PublishInput as u, type PublishOptions as v, type RequestOptions as w, Transport as x, type UploadSessionFileResponse as y, type UploadSessionResponse as z };
432
+ 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 };
@@ -207,7 +207,7 @@ function optionsBody(options) {
207
207
  }
208
208
  return body;
209
209
  }
210
- function deployOptions(options) {
210
+ function updateContentOptions(options) {
211
211
  const out = {};
212
212
  if (options.entry !== void 0) out.entry = options.entry;
213
213
  if (options.contentType !== void 0) out.contentType = options.contentType;
@@ -498,10 +498,39 @@ var CursorPage = class {
498
498
 
499
499
  // src/resources/drops.ts
500
500
  var DropsResource = class {
501
- constructor(transport) {
501
+ constructor(transport, resolve) {
502
502
  this.transport = transport;
503
+ this.resolve = resolve;
503
504
  }
504
505
  transport;
506
+ resolve;
507
+ /** Publish a NEW drop. Returns the created drop. Hits POST /drops. */
508
+ async publish(input, options = {}) {
509
+ let prepared;
510
+ try {
511
+ prepared = await this.resolve(input, options);
512
+ } catch (e) {
513
+ return toErrorResult(e);
514
+ }
515
+ return prepared.kind === "source" ? publishSource(this.transport, prepared, "/drops", options) : publishStaged(this.transport, prepared, "/drops", options);
516
+ }
517
+ /**
518
+ * Publish a NEW content version to an existing drop, keeping its URL.
519
+ * Content-only: drop settings/metadata are stripped BEFORE prepare so they are never
520
+ * validated, sent, or applied. Settings are owned by updateSettings(). Hits
521
+ * POST /drops/{id}/deployments.
522
+ */
523
+ async updateContent(dropId, input, options = {}) {
524
+ const opts = updateContentOptions(options);
525
+ let prepared;
526
+ try {
527
+ prepared = await this.resolve(input, opts);
528
+ } catch (e) {
529
+ return toErrorResult(e);
530
+ }
531
+ const path = `/drops/${encodeURIComponent(dropId)}/deployments`;
532
+ return prepared.kind === "source" ? publishSource(this.transport, prepared, path, opts) : publishStaged(this.transport, prepared, path, opts);
533
+ }
505
534
  async list(params = {}) {
506
535
  const result = await this.transport.request("GET", "/drops", {
507
536
  params
@@ -521,7 +550,7 @@ var DropsResource = class {
521
550
  `/drops/${encodeURIComponent(dropId)}`
522
551
  );
523
552
  }
524
- update(dropId, options = {}) {
553
+ updateSettings(dropId, options = {}) {
525
554
  const requestOptions = {
526
555
  body: updateBody(options)
527
556
  };
@@ -778,7 +807,7 @@ var DropthisEdge = class {
778
807
  }
779
808
  get drops() {
780
809
  if (!this.dropsResource)
781
- this.dropsResource = new DropsResource(this.transport);
810
+ this.dropsResource = new DropsResource(this.transport, resolveInMemory);
782
811
  return this.dropsResource;
783
812
  }
784
813
  get account() {
@@ -796,28 +825,6 @@ var DropthisEdge = class {
796
825
  this.deploymentsResource = new DeploymentsResource(this.transport);
797
826
  return this.deploymentsResource;
798
827
  }
799
- /** Publish a NEW drop from in-memory content. */
800
- async publish(input, options = {}) {
801
- let prepared;
802
- try {
803
- prepared = await resolveInMemory(input, options);
804
- } catch (e) {
805
- return toErrorResult(e);
806
- }
807
- return prepared.kind === "source" ? publishSource(this.transport, prepared, "/drops", options) : publishStaged(this.transport, prepared, "/drops", options);
808
- }
809
- /** Publish a NEW content version to an existing drop, keeping its URL. */
810
- async deploy(dropId, input, options = {}) {
811
- const opts = deployOptions(options);
812
- let prepared;
813
- try {
814
- prepared = await resolveInMemory(input, opts);
815
- } catch (e) {
816
- return toErrorResult(e);
817
- }
818
- const path = `/drops/${encodeURIComponent(dropId)}/deployments`;
819
- return prepared.kind === "source" ? publishSource(this.transport, prepared, path, opts) : publishStaged(this.transport, prepared, path, opts);
820
- }
821
828
  };
822
829
  // Annotate the CommonJS export names for ESM import in node:
823
830
  0 && (module.exports = {