@dropthis/cli 0.5.0 → 0.6.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.
- package/README.md +0 -1
- package/dist/cli.cjs +330 -346
- package/dist/cli.cjs.map +1 -1
- package/node_modules/@dropthis/node/README.md +88 -20
- package/node_modules/@dropthis/node/dist/{drops-fK63OCk6.d.cts → drops-BPdmUPCT.d.cts} +65 -56
- package/node_modules/@dropthis/node/dist/{drops-fK63OCk6.d.ts → drops-BPdmUPCT.d.ts} +65 -56
- package/node_modules/@dropthis/node/dist/edge.cjs +389 -168
- package/node_modules/@dropthis/node/dist/edge.cjs.map +1 -1
- package/node_modules/@dropthis/node/dist/edge.d.cts +4 -32
- package/node_modules/@dropthis/node/dist/edge.d.ts +4 -32
- package/node_modules/@dropthis/node/dist/edge.mjs +389 -168
- package/node_modules/@dropthis/node/dist/edge.mjs.map +1 -1
- package/node_modules/@dropthis/node/dist/index.cjs +449 -429
- package/node_modules/@dropthis/node/dist/index.cjs.map +1 -1
- package/node_modules/@dropthis/node/dist/index.d.cts +13 -39
- package/node_modules/@dropthis/node/dist/index.d.ts +13 -39
- package/node_modules/@dropthis/node/dist/index.mjs +448 -429
- 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
|
@@ -68,39 +68,96 @@ await dropthis.update("drop_abc123", { title: "New title" });
|
|
|
68
68
|
|
|
69
69
|
## Supported inputs
|
|
70
70
|
|
|
71
|
-
The `publish()`
|
|
71
|
+
The `publish()` and `deploy()` methods accept:
|
|
72
72
|
|
|
73
|
-
- **HTML string** -- `"<h1>Hello</h1>"`
|
|
74
|
-
- **File path** -- `"./report.html"`
|
|
75
|
-
- **Directory** -- `"./dist"`
|
|
76
|
-
- **
|
|
77
|
-
- **
|
|
73
|
+
- **HTML/text string** -- `"<h1>Hello</h1>"` (auto-detected as inline content)
|
|
74
|
+
- **File path** -- `"./report.html"` (local file)
|
|
75
|
+
- **Directory** -- `"./dist"` (local directory, bundled)
|
|
76
|
+
- **Array of paths** -- `["./dist", "./extra.css"]` (multi-path bundle)
|
|
77
|
+
- **URL object** -- `new URL("https://example.com/page")` (source fetch)
|
|
78
|
+
- **Bytes** -- `new Uint8Array(...)` (raw bytes)
|
|
79
|
+
- **Explicit content** -- `{ kind: "content", content: "...", contentType?: "text/html", path?: "page.html" }`
|
|
80
|
+
- **Source URL** -- `{ kind: "source_url", sourceUrl: "https://example.com/page" }`
|
|
81
|
+
- **File bundle** -- `{ kind: "files", files: [{ path, content?, contentBase64?, bytes?, contentType? }], entry? }`
|
|
82
|
+
|
|
83
|
+
Drop **settings** (title, visibility, password, noindex, expiresAt, slug, metadata) go in the second `options` argument, not in the input object.
|
|
78
84
|
|
|
79
85
|
All inputs are uploaded through staged presigned URLs. The SDK handles this transparently.
|
|
80
86
|
|
|
87
|
+
### Explicit input examples
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
// Inline content with explicit MIME type
|
|
91
|
+
await dropthis.publish({
|
|
92
|
+
kind: "content",
|
|
93
|
+
content: "<h1>Hello</h1>",
|
|
94
|
+
contentType: "text/html",
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// Fetch and re-publish a remote URL
|
|
98
|
+
await dropthis.publish({
|
|
99
|
+
kind: "source_url",
|
|
100
|
+
sourceUrl: "https://example.com/report",
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// Multi-file bundle with explicit entry point
|
|
104
|
+
await dropthis.publish(
|
|
105
|
+
{
|
|
106
|
+
kind: "files",
|
|
107
|
+
files: [
|
|
108
|
+
{ path: "index.html", content: "<h1>Hello</h1>" },
|
|
109
|
+
{ path: "style.css", content: "body { margin: 0; }" },
|
|
110
|
+
],
|
|
111
|
+
entry: "index.html",
|
|
112
|
+
},
|
|
113
|
+
{ title: "My Site" },
|
|
114
|
+
);
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Prepare (validate without sending)
|
|
118
|
+
|
|
119
|
+
`prepare()` resolves and validates the input locally, returning the prepared request object without making any API calls. It throws `PublishInputError` on invalid input (e.g. missing file).
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
import { Dropthis, PublishInputError } from "@dropthis/node";
|
|
123
|
+
|
|
124
|
+
try {
|
|
125
|
+
const prepared = await dropthis.prepare("./dist");
|
|
126
|
+
console.log("Ready to publish:", prepared.kind);
|
|
127
|
+
} catch (e) {
|
|
128
|
+
if (e instanceof PublishInputError) {
|
|
129
|
+
console.error("Bad input:", e.message);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
81
134
|
## Error handling
|
|
82
135
|
|
|
83
|
-
All methods return `{ data, error, headers }`.
|
|
136
|
+
All methods return `DropthisResult<T>` -- either `{ data: T, error: null, headers }` or `{ data: null, error, headers }`. API errors never throw; check `error` before using `data`.
|
|
84
137
|
|
|
85
138
|
```typescript
|
|
86
139
|
const result = await dropthis.drops.get("drop_abc123");
|
|
87
140
|
|
|
88
141
|
if (result.error) {
|
|
89
142
|
console.error(result.error.code, result.error.message);
|
|
90
|
-
// error.statusCode, error.requestId
|
|
143
|
+
// Also available: error.statusCode, error.requestId, error.suggestion,
|
|
144
|
+
// error.retryable, error.param, error.currentRevision
|
|
91
145
|
} else {
|
|
92
146
|
console.log(result.data);
|
|
93
147
|
}
|
|
94
148
|
```
|
|
95
149
|
|
|
150
|
+
Local input validation errors (e.g. `file_not_found`) are also returned as `{ error: { code: "file_not_found", ... } }` rather than thrown -- except for `prepare()`, which throws `PublishInputError`.
|
|
151
|
+
|
|
96
152
|
## Configuration
|
|
97
153
|
|
|
98
154
|
```typescript
|
|
99
155
|
const dropthis = new Dropthis({
|
|
100
|
-
apiKey: "sk_...",
|
|
101
|
-
baseUrl: "https://...",
|
|
102
|
-
timeoutMs: 30_000,
|
|
103
|
-
|
|
156
|
+
apiKey: "sk_...", // Required. Defaults to DROPTHIS_API_KEY env var.
|
|
157
|
+
baseUrl: "https://...", // Override API base URL.
|
|
158
|
+
timeoutMs: 30_000, // Request timeout in milliseconds (default: 30s).
|
|
159
|
+
uploadTimeoutMs: 120_000, // Timeout for signed-PUT file uploads (default: 120s).
|
|
160
|
+
fetch: customFetch, // Custom fetch implementation.
|
|
104
161
|
});
|
|
105
162
|
```
|
|
106
163
|
|
|
@@ -117,8 +174,6 @@ const dropthis = new Dropthis("sk_...");
|
|
|
117
174
|
```typescript
|
|
118
175
|
await dropthis.drops.list({ limit: 20 });
|
|
119
176
|
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
177
|
await dropthis.drops.update("drop_abc123", { title: "Updated" });
|
|
123
178
|
await dropthis.drops.delete("drop_abc123");
|
|
124
179
|
```
|
|
@@ -135,11 +190,11 @@ for await (const drop of page.data) {
|
|
|
135
190
|
}
|
|
136
191
|
```
|
|
137
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).
|
|
194
|
+
|
|
138
195
|
### deployments
|
|
139
196
|
|
|
140
197
|
```typescript
|
|
141
|
-
await dropthis.deployments.create("drop_abc123", { uploadId: "upl_xyz789" });
|
|
142
|
-
await dropthis.deployments.createRaw("drop_abc123", { upload_id: "upl_xyz789" });
|
|
143
198
|
await dropthis.deployments.list("drop_abc123");
|
|
144
199
|
await dropthis.deployments.get("drop_abc123", "dep_xyz789");
|
|
145
200
|
```
|
|
@@ -154,10 +209,6 @@ await dropthis.uploads.create({
|
|
|
154
209
|
files: [{ path: "index.html", contentType: "text/html", sizeBytes: 1024 }],
|
|
155
210
|
});
|
|
156
211
|
await dropthis.uploads.get("upl_abc123");
|
|
157
|
-
await dropthis.uploads.createPartTargets("upl_abc123", {
|
|
158
|
-
fileId: "file_xyz",
|
|
159
|
-
partNumbers: [1, 2, 3],
|
|
160
|
-
});
|
|
161
212
|
await dropthis.uploads.complete("upl_abc123", { files: {} });
|
|
162
213
|
await dropthis.uploads.cancel("upl_abc123");
|
|
163
214
|
```
|
|
@@ -186,6 +237,21 @@ await dropthis.account.update({ displayName: "Jane Doe" });
|
|
|
186
237
|
await dropthis.account.delete();
|
|
187
238
|
```
|
|
188
239
|
|
|
240
|
+
## Cloudflare Workers (edge)
|
|
241
|
+
|
|
242
|
+
Use the fs-free entry point for Cloudflare Workers and other edge runtimes. It does not import `node:fs`, `node:path`, or `node:crypto`.
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
import { DropthisEdge } from "@dropthis/node/edge";
|
|
246
|
+
|
|
247
|
+
const dropthis = new DropthisEdge({ apiKey: env.DROPTHIS_API_KEY });
|
|
248
|
+
const { data, error } = await dropthis.publish("<h1>Hello from the edge</h1>");
|
|
249
|
+
```
|
|
250
|
+
|
|
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
|
+
|
|
253
|
+
`DropthisEdge` exposes the same `publish(input, options?)` and `deploy(dropId, input, options?)` methods, plus the `drops`, `deployments`, `account`, and `apiKeys` resource accessors.
|
|
254
|
+
|
|
189
255
|
## Types
|
|
190
256
|
|
|
191
257
|
Key types exported from the package:
|
|
@@ -201,6 +267,8 @@ import type {
|
|
|
201
267
|
PrepareOptions,
|
|
202
268
|
RequestControls,
|
|
203
269
|
PublishOptions,
|
|
270
|
+
PublishInput,
|
|
271
|
+
PublishFileInput,
|
|
204
272
|
ListPage,
|
|
205
273
|
CreateUploadSessionRequest,
|
|
206
274
|
CreateUploadSessionResponse,
|
|
@@ -2,6 +2,7 @@ type DropthisClientOptions = {
|
|
|
2
2
|
apiKey?: string;
|
|
3
3
|
baseUrl?: string;
|
|
4
4
|
timeoutMs?: number;
|
|
5
|
+
uploadTimeoutMs?: number;
|
|
5
6
|
fetch?: typeof globalThis.fetch;
|
|
6
7
|
};
|
|
7
8
|
type RequestOptions = {
|
|
@@ -15,12 +16,15 @@ type DropthisErrorResponse = {
|
|
|
15
16
|
message: string;
|
|
16
17
|
statusCode: number | null;
|
|
17
18
|
type?: string;
|
|
18
|
-
|
|
19
|
+
title?: string;
|
|
20
|
+
detail?: string | null;
|
|
21
|
+
instance?: string | null;
|
|
19
22
|
param?: string | null;
|
|
20
23
|
currentRevision?: number;
|
|
21
24
|
requestId?: string | null;
|
|
22
25
|
suggestion?: string | null;
|
|
23
26
|
retryable?: boolean | null;
|
|
27
|
+
body?: unknown;
|
|
24
28
|
};
|
|
25
29
|
type DropthisResult<T> = {
|
|
26
30
|
data: T;
|
|
@@ -57,7 +61,6 @@ type DropResponse = {
|
|
|
57
61
|
id: string;
|
|
58
62
|
slug: string;
|
|
59
63
|
url: string;
|
|
60
|
-
canonicalHost: string;
|
|
61
64
|
deploymentId: string | null;
|
|
62
65
|
title: string;
|
|
63
66
|
contentType: string;
|
|
@@ -175,8 +178,6 @@ type UploadTarget = {
|
|
|
175
178
|
url: string;
|
|
176
179
|
headers: Record<string, string>;
|
|
177
180
|
expiresAt: string;
|
|
178
|
-
partSize?: number;
|
|
179
|
-
partCount?: number;
|
|
180
181
|
};
|
|
181
182
|
type CreateUploadSessionFileResponse = {
|
|
182
183
|
fileId: string;
|
|
@@ -206,21 +207,6 @@ type CreateUploadSessionResponse = {
|
|
|
206
207
|
files: CreateUploadSessionFileResponse[];
|
|
207
208
|
nextAction?: Action | null;
|
|
208
209
|
};
|
|
209
|
-
type CreateUploadPartTargetsRequest = {
|
|
210
|
-
fileId: string;
|
|
211
|
-
partNumbers: number[];
|
|
212
|
-
};
|
|
213
|
-
type UploadPartTarget = {
|
|
214
|
-
partNumber: number;
|
|
215
|
-
url: string;
|
|
216
|
-
headers: Record<string, string>;
|
|
217
|
-
expiresAt: string;
|
|
218
|
-
};
|
|
219
|
-
type CreateUploadPartTargetsResponse = {
|
|
220
|
-
fileId: string;
|
|
221
|
-
urlExpiresAt?: string | null;
|
|
222
|
-
parts: UploadPartTarget[];
|
|
223
|
-
};
|
|
224
210
|
type CompleteUploadSessionRequest = {
|
|
225
211
|
files?: Record<string, {
|
|
226
212
|
parts?: Array<{
|
|
@@ -264,41 +250,34 @@ type RequestControls = {
|
|
|
264
250
|
ifRevision?: number;
|
|
265
251
|
};
|
|
266
252
|
type PublishOptions = DropOptions & PrepareOptions & RequestControls;
|
|
267
|
-
type
|
|
253
|
+
type PublishFileInput = {
|
|
254
|
+
path: string;
|
|
255
|
+
contentType?: string;
|
|
256
|
+
content?: string;
|
|
257
|
+
contentBase64?: string;
|
|
258
|
+
bytes?: Uint8Array;
|
|
259
|
+
};
|
|
260
|
+
type PublishInput = string | string[] | URL | Uint8Array | {
|
|
261
|
+
kind: "content";
|
|
268
262
|
content: string;
|
|
269
263
|
contentType?: string;
|
|
270
|
-
|
|
271
|
-
visibility?: "public" | "unlisted";
|
|
272
|
-
metadata?: Record<string, unknown>;
|
|
273
|
-
entry?: string;
|
|
274
|
-
} | {
|
|
275
|
-
files: Array<{
|
|
276
|
-
path: string;
|
|
277
|
-
content?: string;
|
|
278
|
-
contentBase64?: string;
|
|
279
|
-
bytes?: Uint8Array;
|
|
280
|
-
contentType: string;
|
|
281
|
-
}>;
|
|
282
|
-
title?: string;
|
|
283
|
-
visibility?: "public" | "unlisted";
|
|
284
|
-
metadata?: Record<string, unknown>;
|
|
285
|
-
entry?: string;
|
|
264
|
+
path?: string;
|
|
286
265
|
} | {
|
|
266
|
+
kind: "source_url";
|
|
287
267
|
sourceUrl: string;
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
268
|
+
} | {
|
|
269
|
+
kind: "files";
|
|
270
|
+
files: PublishFileInput[];
|
|
291
271
|
entry?: string;
|
|
292
272
|
};
|
|
293
|
-
type PublishInput = string | URL | Uint8Array | ExplicitPublishInput;
|
|
294
273
|
|
|
295
274
|
declare class Transport {
|
|
296
275
|
readonly apiKey: string | undefined;
|
|
297
276
|
readonly baseUrl: string;
|
|
298
277
|
readonly timeoutMs: number;
|
|
278
|
+
readonly uploadTimeoutMs: number;
|
|
299
279
|
readonly fetchImpl: typeof globalThis.fetch;
|
|
300
280
|
constructor(options?: DropthisClientOptions | string);
|
|
301
|
-
multipart<T>(method: string, path: string, form: FormData, options?: RequestOptions): Promise<DropthisResult<T>>;
|
|
302
281
|
putSignedUrl(url: string, body: Uint8Array | Blob | ReadableStream, headers: Record<string, string>): Promise<DropthisResult<{
|
|
303
282
|
etag: string | null;
|
|
304
283
|
}>>;
|
|
@@ -309,6 +288,50 @@ declare class Transport {
|
|
|
309
288
|
}): Promise<DropthisResult<T>>;
|
|
310
289
|
}
|
|
311
290
|
|
|
291
|
+
/**
|
|
292
|
+
* A file ready to be staged for upload. The body is lazy: the orchestrator
|
|
293
|
+
* calls `getBody()` per file when it is ready to push bytes to the signed URL.
|
|
294
|
+
* This keeps the resolution layer pure and lets the filesystem layer (node.ts)
|
|
295
|
+
* defer reads/streams until upload time.
|
|
296
|
+
*/
|
|
297
|
+
type PreparedUploadFile = {
|
|
298
|
+
path: string;
|
|
299
|
+
contentType: string;
|
|
300
|
+
sizeBytes: number;
|
|
301
|
+
checksumSha256?: string;
|
|
302
|
+
getBody(): Promise<Uint8Array | Blob | ReadableStream>;
|
|
303
|
+
};
|
|
304
|
+
type PreparedPublishRequest = {
|
|
305
|
+
kind: "staged";
|
|
306
|
+
manifest: CreateUploadSessionRequest;
|
|
307
|
+
files: PreparedUploadFile[];
|
|
308
|
+
options: Record<string, unknown>;
|
|
309
|
+
metadata?: Record<string, unknown>;
|
|
310
|
+
} | {
|
|
311
|
+
kind: "source";
|
|
312
|
+
sourceUrl: string;
|
|
313
|
+
options: Record<string, unknown>;
|
|
314
|
+
metadata?: Record<string, unknown>;
|
|
315
|
+
};
|
|
316
|
+
/**
|
|
317
|
+
* The canonical publish inputs that can be resolved with no filesystem access:
|
|
318
|
+
* the {@link PublishInput} union minus `string[]` (which is inherently a list
|
|
319
|
+
* of filesystem paths handled by node.ts).
|
|
320
|
+
*/
|
|
321
|
+
type InMemoryPublishInput = string | URL | Uint8Array | {
|
|
322
|
+
kind: "content";
|
|
323
|
+
content: string;
|
|
324
|
+
contentType?: string;
|
|
325
|
+
path?: string;
|
|
326
|
+
} | {
|
|
327
|
+
kind: "source_url";
|
|
328
|
+
sourceUrl: string;
|
|
329
|
+
} | {
|
|
330
|
+
kind: "files";
|
|
331
|
+
files: PublishFileInput[];
|
|
332
|
+
entry?: string;
|
|
333
|
+
};
|
|
334
|
+
|
|
312
335
|
declare class AccountResource {
|
|
313
336
|
private readonly transport;
|
|
314
337
|
constructor(transport: Transport);
|
|
@@ -337,14 +360,6 @@ declare class ApiKeysResource {
|
|
|
337
360
|
declare class DeploymentsResource {
|
|
338
361
|
private readonly transport;
|
|
339
362
|
constructor(transport: Transport);
|
|
340
|
-
create(dropId: string, body: Record<string, unknown>, options?: {
|
|
341
|
-
idempotencyKey?: string;
|
|
342
|
-
ifRevision?: number;
|
|
343
|
-
}): Promise<DropthisResult<DropResponse>>;
|
|
344
|
-
createRaw(dropId: string, body: unknown, options?: {
|
|
345
|
-
idempotencyKey?: string;
|
|
346
|
-
ifRevision?: number;
|
|
347
|
-
}): Promise<DropthisResult<DropResponse>>;
|
|
348
363
|
list(dropId: string, params?: ListDeploymentsParams): Promise<DropthisResult<ListDeploymentsResponse>>;
|
|
349
364
|
get(dropId: string, deploymentId: string): Promise<DropthisResult<DropDeploymentResponse>>;
|
|
350
365
|
}
|
|
@@ -370,16 +385,10 @@ declare class CursorPage<T> implements ListPage<T> {
|
|
|
370
385
|
declare class DropsResource {
|
|
371
386
|
private readonly transport;
|
|
372
387
|
constructor(transport: Transport);
|
|
373
|
-
create(body: unknown, options?: {
|
|
374
|
-
idempotencyKey?: string;
|
|
375
|
-
}): Promise<DropthisResult<DropResponse>>;
|
|
376
|
-
createRaw(body: unknown, options?: {
|
|
377
|
-
idempotencyKey?: string;
|
|
378
|
-
}): Promise<DropthisResult<DropResponse>>;
|
|
379
388
|
list(params?: ListDropsParams): Promise<DropthisResult<CursorPage<DropResponse>>>;
|
|
380
389
|
get(dropId: string): Promise<DropthisResult<DropResponse>>;
|
|
381
390
|
update(dropId: string, options?: DropOptions & RequestControls): Promise<DropthisResult<DropResponse>>;
|
|
382
391
|
delete(dropId: string): Promise<DropthisResult<null>>;
|
|
383
392
|
}
|
|
384
393
|
|
|
385
|
-
export { AccountResource as A, type CompleteUploadSessionRequest as C, DeploymentsResource as D, type EmailOtpResponse as E, 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
|
|
394
|
+
export { AccountResource as A, 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 UploadManifestFile 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 UploadSessionFileResponse as x, type UploadSessionResponse as y, type UploadTarget as z };
|
|
@@ -2,6 +2,7 @@ type DropthisClientOptions = {
|
|
|
2
2
|
apiKey?: string;
|
|
3
3
|
baseUrl?: string;
|
|
4
4
|
timeoutMs?: number;
|
|
5
|
+
uploadTimeoutMs?: number;
|
|
5
6
|
fetch?: typeof globalThis.fetch;
|
|
6
7
|
};
|
|
7
8
|
type RequestOptions = {
|
|
@@ -15,12 +16,15 @@ type DropthisErrorResponse = {
|
|
|
15
16
|
message: string;
|
|
16
17
|
statusCode: number | null;
|
|
17
18
|
type?: string;
|
|
18
|
-
|
|
19
|
+
title?: string;
|
|
20
|
+
detail?: string | null;
|
|
21
|
+
instance?: string | null;
|
|
19
22
|
param?: string | null;
|
|
20
23
|
currentRevision?: number;
|
|
21
24
|
requestId?: string | null;
|
|
22
25
|
suggestion?: string | null;
|
|
23
26
|
retryable?: boolean | null;
|
|
27
|
+
body?: unknown;
|
|
24
28
|
};
|
|
25
29
|
type DropthisResult<T> = {
|
|
26
30
|
data: T;
|
|
@@ -57,7 +61,6 @@ type DropResponse = {
|
|
|
57
61
|
id: string;
|
|
58
62
|
slug: string;
|
|
59
63
|
url: string;
|
|
60
|
-
canonicalHost: string;
|
|
61
64
|
deploymentId: string | null;
|
|
62
65
|
title: string;
|
|
63
66
|
contentType: string;
|
|
@@ -175,8 +178,6 @@ type UploadTarget = {
|
|
|
175
178
|
url: string;
|
|
176
179
|
headers: Record<string, string>;
|
|
177
180
|
expiresAt: string;
|
|
178
|
-
partSize?: number;
|
|
179
|
-
partCount?: number;
|
|
180
181
|
};
|
|
181
182
|
type CreateUploadSessionFileResponse = {
|
|
182
183
|
fileId: string;
|
|
@@ -206,21 +207,6 @@ type CreateUploadSessionResponse = {
|
|
|
206
207
|
files: CreateUploadSessionFileResponse[];
|
|
207
208
|
nextAction?: Action | null;
|
|
208
209
|
};
|
|
209
|
-
type CreateUploadPartTargetsRequest = {
|
|
210
|
-
fileId: string;
|
|
211
|
-
partNumbers: number[];
|
|
212
|
-
};
|
|
213
|
-
type UploadPartTarget = {
|
|
214
|
-
partNumber: number;
|
|
215
|
-
url: string;
|
|
216
|
-
headers: Record<string, string>;
|
|
217
|
-
expiresAt: string;
|
|
218
|
-
};
|
|
219
|
-
type CreateUploadPartTargetsResponse = {
|
|
220
|
-
fileId: string;
|
|
221
|
-
urlExpiresAt?: string | null;
|
|
222
|
-
parts: UploadPartTarget[];
|
|
223
|
-
};
|
|
224
210
|
type CompleteUploadSessionRequest = {
|
|
225
211
|
files?: Record<string, {
|
|
226
212
|
parts?: Array<{
|
|
@@ -264,41 +250,34 @@ type RequestControls = {
|
|
|
264
250
|
ifRevision?: number;
|
|
265
251
|
};
|
|
266
252
|
type PublishOptions = DropOptions & PrepareOptions & RequestControls;
|
|
267
|
-
type
|
|
253
|
+
type PublishFileInput = {
|
|
254
|
+
path: string;
|
|
255
|
+
contentType?: string;
|
|
256
|
+
content?: string;
|
|
257
|
+
contentBase64?: string;
|
|
258
|
+
bytes?: Uint8Array;
|
|
259
|
+
};
|
|
260
|
+
type PublishInput = string | string[] | URL | Uint8Array | {
|
|
261
|
+
kind: "content";
|
|
268
262
|
content: string;
|
|
269
263
|
contentType?: string;
|
|
270
|
-
|
|
271
|
-
visibility?: "public" | "unlisted";
|
|
272
|
-
metadata?: Record<string, unknown>;
|
|
273
|
-
entry?: string;
|
|
274
|
-
} | {
|
|
275
|
-
files: Array<{
|
|
276
|
-
path: string;
|
|
277
|
-
content?: string;
|
|
278
|
-
contentBase64?: string;
|
|
279
|
-
bytes?: Uint8Array;
|
|
280
|
-
contentType: string;
|
|
281
|
-
}>;
|
|
282
|
-
title?: string;
|
|
283
|
-
visibility?: "public" | "unlisted";
|
|
284
|
-
metadata?: Record<string, unknown>;
|
|
285
|
-
entry?: string;
|
|
264
|
+
path?: string;
|
|
286
265
|
} | {
|
|
266
|
+
kind: "source_url";
|
|
287
267
|
sourceUrl: string;
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
268
|
+
} | {
|
|
269
|
+
kind: "files";
|
|
270
|
+
files: PublishFileInput[];
|
|
291
271
|
entry?: string;
|
|
292
272
|
};
|
|
293
|
-
type PublishInput = string | URL | Uint8Array | ExplicitPublishInput;
|
|
294
273
|
|
|
295
274
|
declare class Transport {
|
|
296
275
|
readonly apiKey: string | undefined;
|
|
297
276
|
readonly baseUrl: string;
|
|
298
277
|
readonly timeoutMs: number;
|
|
278
|
+
readonly uploadTimeoutMs: number;
|
|
299
279
|
readonly fetchImpl: typeof globalThis.fetch;
|
|
300
280
|
constructor(options?: DropthisClientOptions | string);
|
|
301
|
-
multipart<T>(method: string, path: string, form: FormData, options?: RequestOptions): Promise<DropthisResult<T>>;
|
|
302
281
|
putSignedUrl(url: string, body: Uint8Array | Blob | ReadableStream, headers: Record<string, string>): Promise<DropthisResult<{
|
|
303
282
|
etag: string | null;
|
|
304
283
|
}>>;
|
|
@@ -309,6 +288,50 @@ declare class Transport {
|
|
|
309
288
|
}): Promise<DropthisResult<T>>;
|
|
310
289
|
}
|
|
311
290
|
|
|
291
|
+
/**
|
|
292
|
+
* A file ready to be staged for upload. The body is lazy: the orchestrator
|
|
293
|
+
* calls `getBody()` per file when it is ready to push bytes to the signed URL.
|
|
294
|
+
* This keeps the resolution layer pure and lets the filesystem layer (node.ts)
|
|
295
|
+
* defer reads/streams until upload time.
|
|
296
|
+
*/
|
|
297
|
+
type PreparedUploadFile = {
|
|
298
|
+
path: string;
|
|
299
|
+
contentType: string;
|
|
300
|
+
sizeBytes: number;
|
|
301
|
+
checksumSha256?: string;
|
|
302
|
+
getBody(): Promise<Uint8Array | Blob | ReadableStream>;
|
|
303
|
+
};
|
|
304
|
+
type PreparedPublishRequest = {
|
|
305
|
+
kind: "staged";
|
|
306
|
+
manifest: CreateUploadSessionRequest;
|
|
307
|
+
files: PreparedUploadFile[];
|
|
308
|
+
options: Record<string, unknown>;
|
|
309
|
+
metadata?: Record<string, unknown>;
|
|
310
|
+
} | {
|
|
311
|
+
kind: "source";
|
|
312
|
+
sourceUrl: string;
|
|
313
|
+
options: Record<string, unknown>;
|
|
314
|
+
metadata?: Record<string, unknown>;
|
|
315
|
+
};
|
|
316
|
+
/**
|
|
317
|
+
* The canonical publish inputs that can be resolved with no filesystem access:
|
|
318
|
+
* the {@link PublishInput} union minus `string[]` (which is inherently a list
|
|
319
|
+
* of filesystem paths handled by node.ts).
|
|
320
|
+
*/
|
|
321
|
+
type InMemoryPublishInput = string | URL | Uint8Array | {
|
|
322
|
+
kind: "content";
|
|
323
|
+
content: string;
|
|
324
|
+
contentType?: string;
|
|
325
|
+
path?: string;
|
|
326
|
+
} | {
|
|
327
|
+
kind: "source_url";
|
|
328
|
+
sourceUrl: string;
|
|
329
|
+
} | {
|
|
330
|
+
kind: "files";
|
|
331
|
+
files: PublishFileInput[];
|
|
332
|
+
entry?: string;
|
|
333
|
+
};
|
|
334
|
+
|
|
312
335
|
declare class AccountResource {
|
|
313
336
|
private readonly transport;
|
|
314
337
|
constructor(transport: Transport);
|
|
@@ -337,14 +360,6 @@ declare class ApiKeysResource {
|
|
|
337
360
|
declare class DeploymentsResource {
|
|
338
361
|
private readonly transport;
|
|
339
362
|
constructor(transport: Transport);
|
|
340
|
-
create(dropId: string, body: Record<string, unknown>, options?: {
|
|
341
|
-
idempotencyKey?: string;
|
|
342
|
-
ifRevision?: number;
|
|
343
|
-
}): Promise<DropthisResult<DropResponse>>;
|
|
344
|
-
createRaw(dropId: string, body: unknown, options?: {
|
|
345
|
-
idempotencyKey?: string;
|
|
346
|
-
ifRevision?: number;
|
|
347
|
-
}): Promise<DropthisResult<DropResponse>>;
|
|
348
363
|
list(dropId: string, params?: ListDeploymentsParams): Promise<DropthisResult<ListDeploymentsResponse>>;
|
|
349
364
|
get(dropId: string, deploymentId: string): Promise<DropthisResult<DropDeploymentResponse>>;
|
|
350
365
|
}
|
|
@@ -370,16 +385,10 @@ declare class CursorPage<T> implements ListPage<T> {
|
|
|
370
385
|
declare class DropsResource {
|
|
371
386
|
private readonly transport;
|
|
372
387
|
constructor(transport: Transport);
|
|
373
|
-
create(body: unknown, options?: {
|
|
374
|
-
idempotencyKey?: string;
|
|
375
|
-
}): Promise<DropthisResult<DropResponse>>;
|
|
376
|
-
createRaw(body: unknown, options?: {
|
|
377
|
-
idempotencyKey?: string;
|
|
378
|
-
}): Promise<DropthisResult<DropResponse>>;
|
|
379
388
|
list(params?: ListDropsParams): Promise<DropthisResult<CursorPage<DropResponse>>>;
|
|
380
389
|
get(dropId: string): Promise<DropthisResult<DropResponse>>;
|
|
381
390
|
update(dropId: string, options?: DropOptions & RequestControls): Promise<DropthisResult<DropResponse>>;
|
|
382
391
|
delete(dropId: string): Promise<DropthisResult<null>>;
|
|
383
392
|
}
|
|
384
393
|
|
|
385
|
-
export { AccountResource as A, type CompleteUploadSessionRequest as C, DeploymentsResource as D, type EmailOtpResponse as E, 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
|
|
394
|
+
export { AccountResource as A, 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 UploadManifestFile 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 UploadSessionFileResponse as x, type UploadSessionResponse as y, type UploadTarget as z };
|