@dropthis/cli 0.3.4 → 0.4.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.
@@ -1,90 +1,218 @@
1
- # Dropthis Node SDK
1
+ # @dropthis/node
2
2
 
3
- Official Node.js SDK for Dropthis.
3
+ Official Node.js SDK for [dropthis](https://dropthis.app) -- the publish layer between AI and the internet. One API call in, one URL out.
4
+
5
+ ## Install
4
6
 
5
7
  ```bash
6
- npm install @dropthis/sdk
8
+ npm install @dropthis/node
7
9
  ```
8
10
 
9
- ## Publish Anything
11
+ ## Quick start
10
12
 
11
- ```ts
12
- import { Dropthis } from "@dropthis/sdk";
13
+ ```typescript
14
+ import { Dropthis } from "@dropthis/node";
13
15
 
14
- const dropthis = new Dropthis({ apiKey: process.env.DROPTHIS_API_KEY });
16
+ const dropthis = new Dropthis({ apiKey: "sk_..." });
17
+ const { data, error } = await dropthis.publish("<h1>Hello</h1>");
15
18
 
16
- const { data, error } = await dropthis.publish("./dist", {
17
- title: "Generated launch page",
18
- visibility: "unlisted",
19
- });
19
+ console.log(data.url); // https://abc123.dropthis.app
20
+ ```
20
21
 
21
- if (error) {
22
- console.error(error.message);
23
- process.exit(1);
24
- }
22
+ ## Usage
25
23
 
26
- console.log(data.url);
24
+ ### Publish an HTML string
25
+
26
+ ```typescript
27
+ const { data } = await dropthis.publish("<h1>Launch page</h1>");
27
28
  ```
28
29
 
29
- ## Update A Drop
30
+ ### Publish a file
31
+
32
+ ```typescript
33
+ const { data } = await dropthis.publish("./report.html");
34
+ ```
30
35
 
31
- ```ts
32
- const created = await dropthis.publish("./dist", { title: "Launch" });
33
- if (created.error) throw new Error(created.error.message);
36
+ ### Publish a directory
34
37
 
35
- const updated = await dropthis.update(created.data.id, "./dist", {
36
- ifRevision: created.data.revision,
38
+ ```typescript
39
+ const { data } = await dropthis.publish("./dist");
40
+ ```
41
+
42
+ ### Publish with options
43
+
44
+ ```typescript
45
+ const { data } = await dropthis.publish("./dist", {
46
+ title: "Q4 Report",
47
+ visibility: "unlisted",
48
+ password: "s3cret",
49
+ expiresAt: "2026-12-31T00:00:00Z",
37
50
  });
38
- if (updated.error) throw new Error(updated.error.message);
51
+ ```
52
+
53
+ ### Deploy new content to an existing drop
54
+
55
+ ```typescript
56
+ const created = await dropthis.publish("./dist", { title: "v1" });
39
57
 
40
- const deployments = await dropthis.deployments.list(created.data.id);
58
+ const updated = await dropthis.deploy(created.data.id, "./dist-v2", {
59
+ ifRevision: created.data.revision,
60
+ });
61
+ ```
62
+
63
+ ### Update metadata only
64
+
65
+ ```typescript
66
+ await dropthis.update("drop_abc123", { title: "New title" });
41
67
  ```
42
68
 
43
- Supported inputs:
69
+ ## Supported inputs
70
+
71
+ The `publish()` method accepts:
44
72
 
45
- - HTML strings
46
- - Plain text strings
47
- - HTTP(S) URLs
48
- - Local files and folders, uploaded through staged signed URLs
49
- - Explicit `content`, `files`, `sourceUrl`, and `sourceUrls` objects
73
+ - **HTML string** -- `"<h1>Hello</h1>"`
74
+ - **File path** -- `"./report.html"`
75
+ - **Directory** -- `"./dist"`
76
+ - **Bytes** -- `new Uint8Array(...)`
77
+ - **Explicit object** -- `{ content: "...", contentType: "text/html" }` or `{ files: [...] }`
50
78
 
51
- Large strings, binary inputs, local files, local folders, and explicit `files` are staged through `/uploads`, signed object-store `PUT` requests, upload completion, then a final `upload_id` publish request.
79
+ All inputs are uploaded through staged presigned URLs. The SDK handles this transparently.
52
80
 
53
- ## Error Handling
81
+ ## Error handling
54
82
 
55
- SDK methods return `{ data, error, headers }`.
83
+ All methods return `{ data, error, headers }`. Check `error` before using `data`.
56
84
 
57
- ```ts
58
- const result = await dropthis.drops.get("drop_123");
85
+ ```typescript
86
+ const result = await dropthis.drops.get("drop_abc123");
59
87
 
60
88
  if (result.error) {
61
- console.error(result.error.code, result.error.message);
89
+ console.error(result.error.code, result.error.message);
90
+ // error.statusCode, error.requestId also available
91
+ } else {
92
+ console.log(result.data);
62
93
  }
63
94
  ```
64
95
 
96
+ ## Configuration
97
+
98
+ ```typescript
99
+ const dropthis = new Dropthis({
100
+ apiKey: "sk_...", // Required. Defaults to DROPTHIS_API_KEY env var.
101
+ baseUrl: "https://...", // Override API base URL.
102
+ timeoutMs: 30_000, // Request timeout in milliseconds.
103
+ fetch: customFetch, // Custom fetch implementation.
104
+ });
105
+ ```
106
+
107
+ You can also pass just the API key as a string:
108
+
109
+ ```typescript
110
+ const dropthis = new Dropthis("sk_...");
111
+ ```
112
+
65
113
  ## Resources
66
114
 
67
- ```ts
68
- dropthis.auth.requestEmailOtp({ email: "agent@example.com" });
69
- dropthis.auth.verifyEmailOtp({ email: "agent@example.com", code: "123456" });
115
+ ### drops
70
116
 
71
- dropthis.apiKeys.create({ label: "CI" });
117
+ ```typescript
118
+ await dropthis.drops.list({ limit: 20 });
119
+ await dropthis.drops.get("drop_abc123");
120
+ await dropthis.drops.create({ uploadId: "upl_abc123", options: { title: "New" } });
121
+ await dropthis.drops.createRaw({ upload_id: "upl_abc123" }); // no snake_case conversion
122
+ await dropthis.drops.update("drop_abc123", { title: "Updated" });
123
+ await dropthis.drops.delete("drop_abc123");
124
+ ```
125
+
126
+ List results support auto-pagination:
127
+
128
+ ```typescript
129
+ const page = await dropthis.drops.list();
130
+ const allDrops = await page.data.autoPagingToArray({ limit: 100 });
131
+
132
+ // Or iterate
133
+ for await (const drop of page.data) {
134
+ console.log(drop.url);
135
+ }
136
+ ```
72
137
 
73
- dropthis.drops.list({ limit: 20 });
74
- dropthis.drops.get("drop_123");
75
- dropthis.drops.update("drop_123", { title: "Updated" });
76
- dropthis.drops.delete("drop_123");
138
+ ### deployments
77
139
 
78
- dropthis.uploads.create({
79
- schemaVersion: 1,
80
- files: [{ path: "index.html", contentType: "text/html", sizeBytes: 12 }],
140
+ ```typescript
141
+ await dropthis.deployments.create("drop_abc123", { uploadId: "upl_xyz789" });
142
+ await dropthis.deployments.createRaw("drop_abc123", { upload_id: "upl_xyz789" });
143
+ await dropthis.deployments.list("drop_abc123");
144
+ await dropthis.deployments.get("drop_abc123", "dep_xyz789");
145
+ ```
146
+
147
+ ### uploads
148
+
149
+ Low-level upload session management. Most users should use `publish()` instead.
150
+
151
+ ```typescript
152
+ await dropthis.uploads.create({
153
+ schemaVersion: 1,
154
+ files: [{ path: "index.html", contentType: "text/html", sizeBytes: 1024 }],
155
+ });
156
+ await dropthis.uploads.get("upl_abc123");
157
+ await dropthis.uploads.createPartTargets("upl_abc123", {
158
+ fileId: "file_xyz",
159
+ partNumbers: [1, 2, 3],
81
160
  });
82
- dropthis.uploads.get("upl_123");
83
- dropthis.uploads.complete("upl_123", { files: {} });
84
- dropthis.uploads.cancel("upl_123");
161
+ await dropthis.uploads.complete("upl_abc123", { files: {} });
162
+ await dropthis.uploads.cancel("upl_abc123");
163
+ ```
85
164
 
86
- dropthis.deployments.list("drop_123");
87
- dropthis.deployments.get("drop_123", "dep_123");
165
+ ### auth
88
166
 
89
- dropthis.account.get();
167
+ ```typescript
168
+ await dropthis.auth.requestEmailOtp({ email: "you@example.com" });
169
+ await dropthis.auth.verifyEmailOtp({ email: "you@example.com", code: "123456" });
170
+ await dropthis.auth.logout();
90
171
  ```
172
+
173
+ ### apiKeys
174
+
175
+ ```typescript
176
+ await dropthis.apiKeys.create({ label: "CI" });
177
+ await dropthis.apiKeys.list();
178
+ await dropthis.apiKeys.delete("key_abc123");
179
+ ```
180
+
181
+ ### account
182
+
183
+ ```typescript
184
+ await dropthis.account.get();
185
+ await dropthis.account.update({ displayName: "Jane Doe" });
186
+ await dropthis.account.delete();
187
+ ```
188
+
189
+ ## Types
190
+
191
+ Key types exported from the package:
192
+
193
+ ```typescript
194
+ import type {
195
+ DropthisClientOptions,
196
+ DropthisResult,
197
+ DropthisErrorResponse,
198
+ DropResponse,
199
+ DropDeploymentResponse,
200
+ DropOptions,
201
+ PrepareOptions,
202
+ RequestControls,
203
+ PublishOptions,
204
+ ListPage,
205
+ CreateUploadSessionRequest,
206
+ CreateUploadSessionResponse,
207
+ } from "@dropthis/node";
208
+ ```
209
+
210
+ ## Agent skills
211
+
212
+ For AI coding agents (Cursor, Claude Code, Windsurf, etc.), this SDK ships with a built-in agent skill at `skills/dropthis-node/SKILL.md`. For the CLI skill, see the [CLI repo](https://github.com/dropthis-dev/dropthis-cli).
213
+
214
+ ## Links
215
+
216
+ - [Website](https://dropthis.app)
217
+ - [GitHub](https://github.com/dropthis-dev/dropthis-node)
218
+ - [npm](https://www.npmjs.com/package/@dropthis/node)