@dropthis/cli 0.3.5 → 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.
- package/dist/cli.cjs +10 -4
- package/dist/cli.cjs.map +1 -1
- package/node_modules/@dropthis/node/README.md +181 -53
- package/node_modules/@dropthis/node/dist/index.cjs +178 -157
- package/node_modules/@dropthis/node/dist/index.cjs.map +1 -1
- package/node_modules/@dropthis/node/dist/index.d.cts +87 -26
- package/node_modules/@dropthis/node/dist/index.d.ts +87 -26
- package/node_modules/@dropthis/node/dist/index.mjs +177 -157
- package/node_modules/@dropthis/node/dist/index.mjs.map +1 -1
- package/node_modules/@dropthis/node/package.json +1 -1
- package/package.json +2 -2
|
@@ -1,90 +1,218 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @dropthis/node
|
|
2
2
|
|
|
3
|
-
Official Node.js SDK for
|
|
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/
|
|
8
|
+
npm install @dropthis/node
|
|
7
9
|
```
|
|
8
10
|
|
|
9
|
-
##
|
|
11
|
+
## Quick start
|
|
10
12
|
|
|
11
|
-
```
|
|
12
|
-
import { Dropthis } from "@dropthis/
|
|
13
|
+
```typescript
|
|
14
|
+
import { Dropthis } from "@dropthis/node";
|
|
13
15
|
|
|
14
|
-
const dropthis = new Dropthis({ apiKey:
|
|
16
|
+
const dropthis = new Dropthis({ apiKey: "sk_..." });
|
|
17
|
+
const { data, error } = await dropthis.publish("<h1>Hello</h1>");
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
visibility: "unlisted",
|
|
19
|
-
});
|
|
19
|
+
console.log(data.url); // https://abc123.dropthis.app
|
|
20
|
+
```
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
console.error(error.message);
|
|
23
|
-
process.exit(1);
|
|
24
|
-
}
|
|
22
|
+
## Usage
|
|
25
23
|
|
|
26
|
-
|
|
24
|
+
### Publish an HTML string
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
const { data } = await dropthis.publish("<h1>Launch page</h1>");
|
|
27
28
|
```
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
### Publish a file
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
const { data } = await dropthis.publish("./report.html");
|
|
34
|
+
```
|
|
30
35
|
|
|
31
|
-
|
|
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
|
-
|
|
36
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
- Explicit `content
|
|
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
|
-
|
|
79
|
+
All inputs are uploaded through staged presigned URLs. The SDK handles this transparently.
|
|
52
80
|
|
|
53
|
-
## Error
|
|
81
|
+
## Error handling
|
|
54
82
|
|
|
55
|
-
|
|
83
|
+
All methods return `{ data, error, headers }`. Check `error` before using `data`.
|
|
56
84
|
|
|
57
|
-
```
|
|
58
|
-
const result = await dropthis.drops.get("
|
|
85
|
+
```typescript
|
|
86
|
+
const result = await dropthis.drops.get("drop_abc123");
|
|
59
87
|
|
|
60
88
|
if (result.error) {
|
|
61
|
-
|
|
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
|
-
|
|
68
|
-
dropthis.auth.requestEmailOtp({ email: "agent@example.com" });
|
|
69
|
-
dropthis.auth.verifyEmailOtp({ email: "agent@example.com", code: "123456" });
|
|
115
|
+
### drops
|
|
70
116
|
|
|
71
|
-
|
|
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
|
-
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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.
|
|
83
|
-
dropthis.uploads.
|
|
84
|
-
|
|
161
|
+
await dropthis.uploads.complete("upl_abc123", { files: {} });
|
|
162
|
+
await dropthis.uploads.cancel("upl_abc123");
|
|
163
|
+
```
|
|
85
164
|
|
|
86
|
-
|
|
87
|
-
dropthis.deployments.get("drop_123", "dep_123");
|
|
165
|
+
### auth
|
|
88
166
|
|
|
89
|
-
|
|
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)
|