@dropthis/cli 0.6.1 → 0.8.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 +36 -4
- package/dist/cli.cjs.map +1 -1
- package/node_modules/@dropthis/node/dist/{drops-BPdmUPCT.d.cts → drops-CWGyF-x1.d.cts} +13 -1
- package/node_modules/@dropthis/node/dist/{drops-BPdmUPCT.d.ts → drops-CWGyF-x1.d.ts} +13 -1
- package/node_modules/@dropthis/node/dist/edge.cjs +34 -13
- package/node_modules/@dropthis/node/dist/edge.cjs.map +1 -1
- package/node_modules/@dropthis/node/dist/edge.d.cts +2 -2
- package/node_modules/@dropthis/node/dist/edge.d.ts +2 -2
- package/node_modules/@dropthis/node/dist/edge.mjs +34 -13
- package/node_modules/@dropthis/node/dist/edge.mjs.map +1 -1
- package/node_modules/@dropthis/node/dist/index.cjs +34 -13
- package/node_modules/@dropthis/node/dist/index.cjs.map +1 -1
- package/node_modules/@dropthis/node/dist/index.d.cts +4 -4
- package/node_modules/@dropthis/node/dist/index.d.ts +4 -4
- package/node_modules/@dropthis/node/dist/index.mjs +34 -13
- 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
|
@@ -74,6 +74,9 @@ type DropResponse = {
|
|
|
74
74
|
warnings: Array<Record<string, unknown>>;
|
|
75
75
|
createdAt: string;
|
|
76
76
|
expiresAt: string | null;
|
|
77
|
+
noindex: boolean;
|
|
78
|
+
passwordProtected: boolean;
|
|
79
|
+
metadata: Record<string, unknown>;
|
|
77
80
|
object: string;
|
|
78
81
|
accessible: boolean;
|
|
79
82
|
persistent: boolean;
|
|
@@ -250,6 +253,15 @@ type RequestControls = {
|
|
|
250
253
|
ifRevision?: number;
|
|
251
254
|
};
|
|
252
255
|
type PublishOptions = DropOptions & PrepareOptions & RequestControls;
|
|
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`.
|
|
260
|
+
*/
|
|
261
|
+
type DeployOptions = PrepareOptions & RequestControls & {
|
|
262
|
+
/** Entry file for multi-file bundles (default: index.html). */
|
|
263
|
+
entry?: string;
|
|
264
|
+
};
|
|
253
265
|
type PublishFileInput = {
|
|
254
266
|
path: string;
|
|
255
267
|
contentType?: string;
|
|
@@ -391,4 +403,4 @@ declare class DropsResource {
|
|
|
391
403
|
delete(dropId: string): Promise<DropthisResult<null>>;
|
|
392
404
|
}
|
|
393
405
|
|
|
394
|
-
export { AccountResource as A, type CompleteUploadSessionRequest as C,
|
|
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 };
|
|
@@ -74,6 +74,9 @@ type DropResponse = {
|
|
|
74
74
|
warnings: Array<Record<string, unknown>>;
|
|
75
75
|
createdAt: string;
|
|
76
76
|
expiresAt: string | null;
|
|
77
|
+
noindex: boolean;
|
|
78
|
+
passwordProtected: boolean;
|
|
79
|
+
metadata: Record<string, unknown>;
|
|
77
80
|
object: string;
|
|
78
81
|
accessible: boolean;
|
|
79
82
|
persistent: boolean;
|
|
@@ -250,6 +253,15 @@ type RequestControls = {
|
|
|
250
253
|
ifRevision?: number;
|
|
251
254
|
};
|
|
252
255
|
type PublishOptions = DropOptions & PrepareOptions & RequestControls;
|
|
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`.
|
|
260
|
+
*/
|
|
261
|
+
type DeployOptions = PrepareOptions & RequestControls & {
|
|
262
|
+
/** Entry file for multi-file bundles (default: index.html). */
|
|
263
|
+
entry?: string;
|
|
264
|
+
};
|
|
253
265
|
type PublishFileInput = {
|
|
254
266
|
path: string;
|
|
255
267
|
contentType?: string;
|
|
@@ -391,4 +403,4 @@ declare class DropsResource {
|
|
|
391
403
|
delete(dropId: string): Promise<DropthisResult<null>>;
|
|
392
404
|
}
|
|
393
405
|
|
|
394
|
-
export { AccountResource as A, type CompleteUploadSessionRequest as C,
|
|
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 };
|
|
@@ -197,13 +197,28 @@ function validatePublishOptions(options) {
|
|
|
197
197
|
}
|
|
198
198
|
function optionsBody(options) {
|
|
199
199
|
validatePublishOptions(options);
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
200
|
+
const body = {};
|
|
201
|
+
if (options.title !== void 0) body.title = options.title;
|
|
202
|
+
if (options.visibility !== void 0) body.visibility = options.visibility;
|
|
203
|
+
if (options.password !== void 0) body.password = options.password;
|
|
204
|
+
if (options.noindex !== void 0) body.noindex = options.noindex;
|
|
205
|
+
if (options.expiresAt !== void 0) {
|
|
206
|
+
body.expiresAt = options.expiresAt instanceof Date ? options.expiresAt.toISOString() : options.expiresAt;
|
|
207
|
+
}
|
|
208
|
+
return body;
|
|
209
|
+
}
|
|
210
|
+
function deployOptions(options) {
|
|
211
|
+
const out = {};
|
|
212
|
+
if (options.entry !== void 0) out.entry = options.entry;
|
|
213
|
+
if (options.contentType !== void 0) out.contentType = options.contentType;
|
|
214
|
+
if (options.path !== void 0) out.path = options.path;
|
|
215
|
+
if (options.ignore !== void 0) out.ignore = options.ignore;
|
|
216
|
+
if (options.ignoreDefaults !== void 0)
|
|
217
|
+
out.ignoreDefaults = options.ignoreDefaults;
|
|
218
|
+
if (options.idempotencyKey !== void 0)
|
|
219
|
+
out.idempotencyKey = options.idempotencyKey;
|
|
220
|
+
if (options.ifRevision !== void 0) out.ifRevision = options.ifRevision;
|
|
221
|
+
return out;
|
|
207
222
|
}
|
|
208
223
|
function buildStagedRequest(files, options, entry) {
|
|
209
224
|
assertNonEmptyBundle(files.map((f) => f.path));
|
|
@@ -368,7 +383,7 @@ async function publishStaged(transport, prepared, finalPath, options = {}) {
|
|
|
368
383
|
const finalOptions = {
|
|
369
384
|
body: {
|
|
370
385
|
uploadId: createResult.data.uploadId,
|
|
371
|
-
options: prepared.options,
|
|
386
|
+
...Object.keys(prepared.options).length > 0 ? { options: prepared.options } : {},
|
|
372
387
|
...prepared.metadata ? { metadata: prepared.metadata } : {}
|
|
373
388
|
},
|
|
374
389
|
idempotencyKey: `${baseKey}:publish`
|
|
@@ -382,7 +397,7 @@ async function publishSource(transport, prepared, finalPath, options = {}) {
|
|
|
382
397
|
return transport.request("POST", finalPath, {
|
|
383
398
|
body: {
|
|
384
399
|
sourceUrl: prepared.sourceUrl,
|
|
385
|
-
options: prepared.options,
|
|
400
|
+
...Object.keys(prepared.options).length > 0 ? { options: prepared.options } : {},
|
|
386
401
|
...prepared.metadata ? { metadata: prepared.metadata } : {}
|
|
387
402
|
},
|
|
388
403
|
idempotencyKey: `${baseKey}:publish`,
|
|
@@ -580,7 +595,7 @@ function toSnakeCase(value) {
|
|
|
580
595
|
|
|
581
596
|
// src/transport.ts
|
|
582
597
|
var DEFAULT_BASE_URL = "https://api.dropthis.app";
|
|
583
|
-
var SDK_VERSION = "0.
|
|
598
|
+
var SDK_VERSION = "0.8.0";
|
|
584
599
|
var Transport = class {
|
|
585
600
|
apiKey;
|
|
586
601
|
baseUrl;
|
|
@@ -590,7 +605,12 @@ var Transport = class {
|
|
|
590
605
|
constructor(options = {}) {
|
|
591
606
|
const resolved = typeof options === "string" ? { apiKey: options } : options;
|
|
592
607
|
this.apiKey = resolved.apiKey ?? (typeof process !== "undefined" ? process.env?.DROPTHIS_API_KEY : void 0);
|
|
593
|
-
|
|
608
|
+
const base = new URL(resolved.baseUrl ?? DEFAULT_BASE_URL);
|
|
609
|
+
const basePath = base.pathname.replace(/\/+$/, "");
|
|
610
|
+
base.pathname = basePath.endsWith("/v1") ? basePath : `${basePath}/v1`;
|
|
611
|
+
base.search = "";
|
|
612
|
+
base.hash = "";
|
|
613
|
+
this.baseUrl = base.toString().replace(/\/+$/, "");
|
|
594
614
|
this.timeoutMs = resolved.timeoutMs ?? 3e4;
|
|
595
615
|
this.uploadTimeoutMs = resolved.uploadTimeoutMs ?? 12e4;
|
|
596
616
|
this.fetchImpl = resolved.fetch ?? globalThis.fetch;
|
|
@@ -788,14 +808,15 @@ var DropthisEdge = class {
|
|
|
788
808
|
}
|
|
789
809
|
/** Publish a NEW content version to an existing drop, keeping its URL. */
|
|
790
810
|
async deploy(dropId, input, options = {}) {
|
|
811
|
+
const opts = deployOptions(options);
|
|
791
812
|
let prepared;
|
|
792
813
|
try {
|
|
793
|
-
prepared = await resolveInMemory(input,
|
|
814
|
+
prepared = await resolveInMemory(input, opts);
|
|
794
815
|
} catch (e) {
|
|
795
816
|
return toErrorResult(e);
|
|
796
817
|
}
|
|
797
818
|
const path = `/drops/${encodeURIComponent(dropId)}/deployments`;
|
|
798
|
-
return prepared.kind === "source" ? publishSource(this.transport, prepared, path,
|
|
819
|
+
return prepared.kind === "source" ? publishSource(this.transport, prepared, path, opts) : publishStaged(this.transport, prepared, path, opts);
|
|
799
820
|
}
|
|
800
821
|
};
|
|
801
822
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/edge.ts","../src/errors.ts","../src/publish/detect.ts","../src/publish/paths.ts","../src/publish/core.ts","../src/resources/account.ts","../src/resources/api-keys.ts","../src/resources/deployments.ts","../src/pagination.ts","../src/resources/drops.ts","../src/case.ts","../src/transport.ts"],"sourcesContent":["// Workers-safe entry for @dropthis/node. Reuses the fetch-based Transport and the\n// resource classes, and exposes canonical `publish`/`deploy` powered by the\n// fs-free core pipeline.\n//\n// IMPORTANT: this module must NOT import `./dropthis.js` or `./publish/node.js`,\n// which pull in `node:fs`, `node:path`, `node:crypto`, `fast-glob`, `ignore`,\n// and `Buffer` and cannot be bundled for Cloudflare Workers. The only publish\n// import allowed is `./publish/core.js` (verified fs-free). Keep the import\n// graph to: publish/core + transport + resources + errors + types only.\n//\n// Edge semantics:\n// bare string → inline content (no filesystem lookup; HTML/text auto-detected)\n// http(s) URL → {kind:\"source_url\"} via URL object or http(s) string → source flow\n// Uint8Array → staged single-file upload\n// {kind:\"files\"} → staged multi-file bundle (agent-native; full multi-file supported on edge)\n// string[] → NOT part of InMemoryPublishInput (no fs on edge)\n\nimport { toErrorResult } from \"./errors.js\";\nimport {\n\ttype InMemoryPublishInput,\n\tpublishSource,\n\tpublishStaged,\n\tresolveInMemory,\n} from \"./publish/core.js\";\nimport { AccountResource } from \"./resources/account.js\";\nimport { ApiKeysResource } from \"./resources/api-keys.js\";\nimport { DeploymentsResource } from \"./resources/deployments.js\";\nimport { DropsResource } from \"./resources/drops.js\";\nimport { Transport } from \"./transport.js\";\nimport type {\n\tDropResponse,\n\tDropthisClientOptions,\n\tDropthisResult,\n\tPublishOptions,\n} from \"./types.js\";\n\nexport type { InMemoryPublishInput } from \"./publish/core.js\";\n\n/** Workers-safe dropthis client. Pass an apiKey explicitly (no process.env on the edge). */\nexport class DropthisEdge {\n\tprivate readonly transport: Transport;\n\tprivate dropsResource?: DropsResource;\n\tprivate accountResource?: AccountResource;\n\tprivate apiKeysResource?: ApiKeysResource;\n\tprivate deploymentsResource?: DeploymentsResource;\n\n\tconstructor(options: DropthisClientOptions | string = {}) {\n\t\tthis.transport = new Transport(options);\n\t}\n\n\tget drops(): DropsResource {\n\t\tif (!this.dropsResource)\n\t\t\tthis.dropsResource = new DropsResource(this.transport);\n\t\treturn this.dropsResource;\n\t}\n\n\tget account(): AccountResource {\n\t\tif (!this.accountResource)\n\t\t\tthis.accountResource = new AccountResource(this.transport);\n\t\treturn this.accountResource;\n\t}\n\n\tget apiKeys(): ApiKeysResource {\n\t\tif (!this.apiKeysResource)\n\t\t\tthis.apiKeysResource = new ApiKeysResource(this.transport);\n\t\treturn this.apiKeysResource;\n\t}\n\n\tget deployments(): DeploymentsResource {\n\t\tif (!this.deploymentsResource)\n\t\t\tthis.deploymentsResource = new DeploymentsResource(this.transport);\n\t\treturn this.deploymentsResource;\n\t}\n\n\t/** Publish a NEW drop from in-memory content. */\n\tasync publish(\n\t\tinput: InMemoryPublishInput,\n\t\toptions: PublishOptions = {},\n\t): Promise<DropthisResult<DropResponse>> {\n\t\tlet prepared: Awaited<ReturnType<typeof resolveInMemory>>;\n\t\ttry {\n\t\t\tprepared = await resolveInMemory(input, options);\n\t\t} catch (e) {\n\t\t\treturn toErrorResult<DropResponse>(e);\n\t\t}\n\t\treturn prepared.kind === \"source\"\n\t\t\t? publishSource(this.transport, prepared, \"/drops\", options)\n\t\t\t: publishStaged(this.transport, prepared, \"/drops\", options);\n\t}\n\n\t/** Publish a NEW content version to an existing drop, keeping its URL. */\n\tasync deploy(\n\t\tdropId: string,\n\t\tinput: InMemoryPublishInput,\n\t\toptions: PublishOptions = {},\n\t): Promise<DropthisResult<DropResponse>> {\n\t\tlet prepared: Awaited<ReturnType<typeof resolveInMemory>>;\n\t\ttry {\n\t\t\tprepared = await resolveInMemory(input, options);\n\t\t} catch (e) {\n\t\t\treturn toErrorResult<DropResponse>(e);\n\t\t}\n\t\tconst path = `/drops/${encodeURIComponent(dropId)}/deployments`;\n\t\treturn prepared.kind === \"source\"\n\t\t\t? publishSource(this.transport, prepared, path, options)\n\t\t\t: publishStaged(this.transport, prepared, path, options);\n\t}\n}\n","import type { DropthisResult } from \"./types.js\";\n\nconst API_KEY_RE = /sk_[A-Za-z0-9_-]+/g;\n\nexport function redactSecrets(message: string): string {\n\treturn message.replace(API_KEY_RE, \"sk_[redacted]\");\n}\n\nexport function createErrorResult<T>(\n\tcode: string,\n\tmessage: string,\n\tstatusCode: number | null,\n\textra: {\n\t\ttype?: string;\n\t\ttitle?: string;\n\t\tdetail?: string | null;\n\t\tinstance?: string | null;\n\t\tparam?: string | null;\n\t\tcurrentRevision?: number;\n\t\trequestId?: string | null;\n\t\theaders?: Record<string, string>;\n\t\tsuggestion?: string | null;\n\t\tretryable?: boolean | null;\n\t\tbody?: unknown;\n\t} = {},\n): DropthisResult<T> {\n\treturn {\n\t\tdata: null,\n\t\terror: {\n\t\t\tcode,\n\t\t\tmessage: redactSecrets(message),\n\t\t\tstatusCode,\n\t\t\t...(extra.type ? { type: extra.type } : {}),\n\t\t\t...(extra.title !== undefined ? { title: extra.title } : {}),\n\t\t\t...(extra.detail !== undefined ? { detail: extra.detail } : {}),\n\t\t\t...(extra.instance !== undefined ? { instance: extra.instance } : {}),\n\t\t\t...(extra.param !== undefined ? { param: extra.param } : {}),\n\t\t\t...(extra.currentRevision !== undefined\n\t\t\t\t? { currentRevision: extra.currentRevision }\n\t\t\t\t: {}),\n\t\t\t...(extra.requestId !== undefined ? { requestId: extra.requestId } : {}),\n\t\t\t...(extra.suggestion !== undefined\n\t\t\t\t? { suggestion: extra.suggestion }\n\t\t\t\t: {}),\n\t\t\t...(extra.retryable !== undefined ? { retryable: extra.retryable } : {}),\n\t\t\t...(extra.body !== undefined ? { body: extra.body } : {}),\n\t\t},\n\t\theaders: extra.headers ?? {},\n\t};\n}\n\nexport class PublishInputError extends Error {\n\tconstructor(\n\t\treadonly code: string,\n\t\tmessage: string,\n\t\treadonly param?: string,\n\t\treadonly suggestion?: string,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"PublishInputError\";\n\t}\n}\n\nexport function toErrorResult<T>(err: unknown): DropthisResult<T> {\n\tif (err instanceof PublishInputError)\n\t\treturn createErrorResult<T>(err.code, err.message, null, {\n\t\t\tparam: err.param ?? null,\n\t\t\tsuggestion: err.suggestion ?? null,\n\t\t});\n\treturn createErrorResult<T>(\n\t\t\"sdk_error\",\n\t\terr instanceof Error ? err.message : \"Unknown SDK error\",\n\t\tnull,\n\t);\n}\n","export function isHttpUrl(value: string): boolean {\n\ttry {\n\t\tconst url = new URL(value);\n\t\treturn url.protocol === \"http:\" || url.protocol === \"https:\";\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport function containsHtmlTag(value: string): boolean {\n\treturn /<[a-z!/][^>]*>/i.test(value);\n}\n\nconst FILE_EXT = /\\.[A-Za-z0-9]{1,8}([?#].*)?$/;\nexport function isPathShaped(value: string): boolean {\n\tif (value.length === 0 || value.length > 4096 || value.includes(\"\\n\"))\n\t\treturn false;\n\t// Reject strings that look like HTML (tags disqualify path interpretation)\n\tif (containsHtmlTag(value)) return false;\n\tif (value.includes(\"/\") || value.includes(\"\\\\\")) return true;\n\tif (/^[A-Za-z]:[\\\\/]/.test(value)) return true;\n\treturn FILE_EXT.test(value);\n}\n\nexport function contentTypeForString(value: string, override?: string): string {\n\tif (override) return override;\n\treturn containsHtmlTag(value) ? \"text/html\" : \"text/plain; charset=utf-8\";\n}\n\nexport function detectBytesContentType(bytes: Uint8Array): string {\n\tconst text = new TextDecoder(\"utf-8\", { fatal: false }).decode(bytes);\n\tif (text.includes(\"�\")) return \"application/octet-stream\";\n\treturn containsHtmlTag(text) ? \"text/html\" : \"text/plain; charset=utf-8\";\n}\n\nexport function entryForContentType(contentType: string): string {\n\tconst m = contentType.toLowerCase().split(\";\", 1)[0]?.trim() ?? \"\";\n\tif (m === \"text/html\" || m === \"application/xhtml+xml\") return \"index.html\";\n\tif (m === \"application/json\") return \"index.json\";\n\tif (m === \"text/css\") return \"index.css\";\n\tif (m === \"text/javascript\" || m === \"application/javascript\")\n\t\treturn \"index.js\";\n\tif (m.startsWith(\"text/\")) return \"index.txt\";\n\treturn \"index\";\n}\n","import { PublishInputError } from \"../errors.js\";\n\nexport function normalizeManifestPath(path: string): string {\n\treturn path.replace(/\\\\/g, \"/\").replace(/^\\.\\//, \"\");\n}\n\nexport function assertValidManifestPath(path: string): void {\n\t// User-supplied manifest paths ({kind:\"files\"}.path, options.path, options.entry) must be POSIX.\n\t// Local filesystem paths are normalized via normalizeManifestPath, NOT passed here.\n\tif (path.includes(\"\\\\\"))\n\t\tthrow new PublishInputError(\n\t\t\t\"invalid_path\",\n\t\t\t`Manifest path must use \"/\": \"${path}\".`,\n\t\t\tpath,\n\t\t);\n\tconst p = normalizeManifestPath(path);\n\tif (p === \"\")\n\t\tthrow new PublishInputError(\n\t\t\t\"invalid_path\",\n\t\t\t\"Manifest path must not be empty.\",\n\t\t\tpath,\n\t\t);\n\tif (p.startsWith(\"/\"))\n\t\tthrow new PublishInputError(\n\t\t\t\"invalid_path\",\n\t\t\t`Manifest path must be relative: \"${path}\".`,\n\t\t\tpath,\n\t\t);\n\tif (p.startsWith(\"~\"))\n\t\tthrow new PublishInputError(\n\t\t\t\"invalid_path\",\n\t\t\t`Manifest path must not start with \"~\": \"${path}\".`,\n\t\t\tpath,\n\t\t);\n\tif (p.split(\"/\").includes(\"..\"))\n\t\tthrow new PublishInputError(\n\t\t\t\"invalid_path\",\n\t\t\t`Manifest path must not contain \"..\": \"${path}\".`,\n\t\t\tpath,\n\t\t);\n}\n\nexport function assertNoDuplicatePaths(paths: string[]): void {\n\tconst seen = new Set<string>();\n\tfor (const raw of paths) {\n\t\tconst p = normalizeManifestPath(raw);\n\t\tif (seen.has(p))\n\t\t\tthrow new PublishInputError(\n\t\t\t\t\"duplicate_path\",\n\t\t\t\t`Duplicate file path after normalization: \"${p}\".`,\n\t\t\t\tp,\n\t\t\t\t\"Give each file a unique path; basename mapping for string[] can collide.\",\n\t\t\t);\n\t\tseen.add(p);\n\t}\n}\n\nexport function assertNonEmptyBundle(paths: string[]): void {\n\tif (paths.length === 0)\n\t\tthrow new PublishInputError(\n\t\t\t\"empty_bundle\",\n\t\t\t\"Nothing to publish: the bundle has no files.\",\n\t\t\tundefined,\n\t\t\t\"Pass at least one file, or a directory that contains files.\",\n\t\t);\n}\n","import { createErrorResult, PublishInputError } from \"../errors.js\";\nimport type { Transport } from \"../transport.js\";\nimport type {\n\tCreateUploadSessionRequest,\n\tCreateUploadSessionResponse,\n\tDropResponse,\n\tDropthisResult,\n\tPublishFileInput,\n\tPublishOptions,\n\tUploadManifestFile,\n\tUploadSessionResponse,\n} from \"../types.js\";\nimport {\n\tcontentTypeForString,\n\tdetectBytesContentType,\n\tentryForContentType,\n\tisHttpUrl,\n} from \"./detect.js\";\nimport {\n\tassertNoDuplicatePaths,\n\tassertNonEmptyBundle,\n\tassertValidManifestPath,\n\tnormalizeManifestPath,\n} from \"./paths.js\";\n\n/**\n * A file ready to be staged for upload. The body is lazy: the orchestrator\n * calls `getBody()` per file when it is ready to push bytes to the signed URL.\n * This keeps the resolution layer pure and lets the filesystem layer (node.ts)\n * defer reads/streams until upload time.\n */\nexport type PreparedUploadFile = {\n\tpath: string;\n\tcontentType: string;\n\tsizeBytes: number;\n\tchecksumSha256?: string;\n\tgetBody(): Promise<Uint8Array | Blob | ReadableStream>;\n};\n\nexport type PreparedPublishRequest =\n\t| {\n\t\t\tkind: \"staged\";\n\t\t\tmanifest: CreateUploadSessionRequest;\n\t\t\tfiles: PreparedUploadFile[];\n\t\t\toptions: Record<string, unknown>;\n\t\t\tmetadata?: Record<string, unknown>;\n\t }\n\t| {\n\t\t\tkind: \"source\";\n\t\t\tsourceUrl: string;\n\t\t\toptions: Record<string, unknown>;\n\t\t\tmetadata?: Record<string, unknown>;\n\t };\n\n/**\n * The canonical publish inputs that can be resolved with no filesystem access:\n * the {@link PublishInput} union minus `string[]` (which is inherently a list\n * of filesystem paths handled by node.ts).\n */\nexport type InMemoryPublishInput =\n\t| string\n\t| URL\n\t| Uint8Array\n\t| { kind: \"content\"; content: string; contentType?: string; path?: string }\n\t| { kind: \"source_url\"; sourceUrl: string }\n\t| { kind: \"files\"; files: PublishFileInput[]; entry?: string };\n\nconst VALID_VISIBILITIES = [\"public\", \"unlisted\"] as const;\nconst MAX_TITLE_LENGTH = 500;\n\nexport function validatePublishOptions(options: PublishOptions): void {\n\tif (\n\t\toptions.title !== undefined &&\n\t\toptions.title !== null &&\n\t\toptions.title.length > MAX_TITLE_LENGTH\n\t) {\n\t\tthrow new Error(`Title must be ${MAX_TITLE_LENGTH} characters or less.`);\n\t}\n\n\tif (options.visibility !== undefined && options.visibility !== null) {\n\t\tif (\n\t\t\t!(VALID_VISIBILITIES as readonly string[]).includes(options.visibility)\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid visibility \"${options.visibility}\". Use \"public\" or \"unlisted\".`,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (options.expiresAt !== undefined && options.expiresAt !== null) {\n\t\tif (options.expiresAt instanceof Date) {\n\t\t\tif (Number.isNaN(options.expiresAt.getTime())) {\n\t\t\t\tthrow new Error(\"Invalid expiresAt date.\");\n\t\t\t}\n\t\t} else if (typeof options.expiresAt === \"string\") {\n\t\t\tconst parsed = new Date(options.expiresAt);\n\t\t\tif (Number.isNaN(parsed.getTime())) {\n\t\t\t\tthrow new Error(\"Invalid expiresAt date.\");\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function optionsBody(options: PublishOptions): Record<string, unknown> {\n\tvalidatePublishOptions(options);\n\treturn {\n\t\ttitle: options.title,\n\t\tvisibility: options.visibility,\n\t\tpassword: options.password,\n\t\tnoindex: options.noindex,\n\t\texpiresAt:\n\t\t\toptions.expiresAt instanceof Date\n\t\t\t\t? options.expiresAt.toISOString()\n\t\t\t\t: options.expiresAt,\n\t};\n}\n\n/**\n * Builds a staged upload request from already-prepared files. Validates the\n * bundle is non-empty, normalizes manifest paths, and rejects duplicates.\n * Reused by core's in-memory paths AND by node.ts for file/dir/string[] inputs.\n *\n * `entry` argument wins over `options.entry`.\n */\nexport function buildStagedRequest(\n\tfiles: PreparedUploadFile[],\n\toptions: PublishOptions,\n\tentry?: string,\n): PreparedPublishRequest {\n\tassertNonEmptyBundle(files.map((f) => f.path));\n\tconst normalizedPaths = files.map((f) => normalizeManifestPath(f.path));\n\tassertNoDuplicatePaths(normalizedPaths);\n\n\tconst manifestFiles: UploadManifestFile[] = files.map((file) => ({\n\t\tpath: normalizeManifestPath(file.path),\n\t\tcontentType: file.contentType,\n\t\tsizeBytes: file.sizeBytes,\n\t\t...(file.checksumSha256 ? { checksumSha256: file.checksumSha256 } : {}),\n\t}));\n\n\tconst resolvedEntry = entry ?? options.entry;\n\tif (resolvedEntry !== undefined) assertValidManifestPath(resolvedEntry);\n\tconst manifest: CreateUploadSessionRequest = {\n\t\tschemaVersion: 1,\n\t\tfiles: manifestFiles,\n\t\t...(resolvedEntry ? { entry: resolvedEntry } : {}),\n\t};\n\n\tconst prepared: Extract<PreparedPublishRequest, { kind: \"staged\" }> = {\n\t\tkind: \"staged\",\n\t\tmanifest,\n\t\tfiles,\n\t\toptions: optionsBody(options),\n\t};\n\tif (options.metadata) prepared.metadata = options.metadata;\n\treturn prepared;\n}\n\n/** Builds a `source_url` request (validates http(s)). */\nexport function buildSourceRequest(\n\tsourceUrl: string,\n\toptions: PublishOptions,\n): PreparedPublishRequest {\n\tif (!isHttpUrl(sourceUrl)) {\n\t\tthrow new PublishInputError(\n\t\t\t\"invalid_source_url\",\n\t\t\t\"source_url must be an http(s) URL.\",\n\t\t\tsourceUrl,\n\t\t\t\"Fetch the content first, then pass it as content/files.\",\n\t\t);\n\t}\n\tconst prepared: Extract<PreparedPublishRequest, { kind: \"source\" }> = {\n\t\tkind: \"source\",\n\t\tsourceUrl,\n\t\toptions: optionsBody(options),\n\t};\n\tif (options.metadata) prepared.metadata = options.metadata;\n\treturn prepared;\n}\n\nfunction decodeBase64(value: string): Uint8Array {\n\tconst binary = atob(value);\n\treturn Uint8Array.from(binary, (c) => c.charCodeAt(0));\n}\n\nfunction fileBytes(file: PublishFileInput): Uint8Array {\n\tif (file.content !== undefined) return new TextEncoder().encode(file.content);\n\tif (file.contentBase64 !== undefined) return decodeBase64(file.contentBase64);\n\tif (file.bytes !== undefined) return file.bytes;\n\tthrow new PublishInputError(\n\t\t\"missing_file_bytes\",\n\t\t`File \"${file.path}\" is missing content bytes.`,\n\t\tfile.path,\n\t\t\"Provide one of content, contentBase64, or bytes.\",\n\t);\n}\n\nfunction singleStagedFile(\n\tpath: string,\n\tcontentType: string,\n\tbytes: Uint8Array,\n\toptions: PublishOptions,\n): PreparedPublishRequest {\n\treturn buildStagedRequest(\n\t\t[\n\t\t\t{\n\t\t\t\tpath,\n\t\t\t\tcontentType,\n\t\t\t\tsizeBytes: bytes.byteLength,\n\t\t\t\tgetBody: async () => bytes,\n\t\t\t},\n\t\t],\n\t\toptions,\n\t);\n}\n\n/**\n * Resolves the in-memory canonical inputs (the edge subset of {@link PublishInput})\n * into a {@link PreparedPublishRequest}. Performs NO filesystem access.\n */\nexport async function resolveInMemory(\n\tinput: InMemoryPublishInput,\n\toptions: PublishOptions = {},\n): Promise<PreparedPublishRequest> {\n\tif (input instanceof URL) {\n\t\treturn buildSourceRequest(input.toString(), options);\n\t}\n\n\tif (typeof input === \"string\") {\n\t\tif (isHttpUrl(input)) return buildSourceRequest(input, options);\n\t\tconst contentType = contentTypeForString(input, options.contentType);\n\t\tif (options.path !== undefined) assertValidManifestPath(options.path);\n\t\tconst path = options.path ?? entryForContentType(contentType);\n\t\tconst bytes = new TextEncoder().encode(input);\n\t\treturn singleStagedFile(path, contentType, bytes, options);\n\t}\n\n\t// A Node binary buffer is a Uint8Array subclass, so this branch also covers\n\t// it without referencing the Node-only global.\n\tif (input instanceof Uint8Array) {\n\t\tconst contentType = options.contentType ?? detectBytesContentType(input);\n\t\tif (options.path !== undefined) assertValidManifestPath(options.path);\n\t\tconst path = options.path ?? entryForContentType(contentType);\n\t\treturn singleStagedFile(path, contentType, input, options);\n\t}\n\n\tif (input.kind === \"content\") {\n\t\tconst contentType = input.contentType ?? options.contentType ?? \"text/html\";\n\t\tif (input.path !== undefined) assertValidManifestPath(input.path);\n\t\tif (options.path !== undefined) assertValidManifestPath(options.path);\n\t\tconst path = input.path ?? options.path ?? entryForContentType(contentType);\n\t\tconst bytes = new TextEncoder().encode(input.content);\n\t\treturn singleStagedFile(path, contentType, bytes, options);\n\t}\n\n\tif (input.kind === \"source_url\") {\n\t\treturn buildSourceRequest(input.sourceUrl, options);\n\t}\n\n\t// input.kind === \"files\"\n\tconst files: PreparedUploadFile[] = input.files.map((file) => {\n\t\tassertValidManifestPath(file.path);\n\t\tconst bytes = fileBytes(file);\n\t\tconst contentType = file.contentType ?? detectBytesContentType(bytes);\n\t\treturn {\n\t\t\tpath: file.path,\n\t\t\tcontentType,\n\t\t\tsizeBytes: bytes.byteLength,\n\t\t\tgetBody: async () => bytes,\n\t\t};\n\t});\n\treturn buildStagedRequest(files, options, input.entry);\n}\n\n// ---------------------------------------------------------------------------\n// Orchestration helpers\n// ---------------------------------------------------------------------------\n\ntype StagedPublishOptions = { idempotencyKey?: string; ifRevision?: number };\n\nfunction errorResult<T>(result: DropthisResult<unknown>): DropthisResult<T> {\n\tif (!result.error) throw new Error(\"Expected an error result\");\n\treturn { data: null, error: result.error, headers: result.headers };\n}\n\n/**\n * Executes the staged-upload publish flow (single-PUT only).\n * Calls POST /uploads → PUT signed URL per file → POST /uploads/{id}/complete\n * → POST finalPath.\n */\nexport async function publishStaged(\n\ttransport: Transport,\n\tprepared: Extract<PreparedPublishRequest, { kind: \"staged\" }>,\n\tfinalPath: string,\n\toptions: StagedPublishOptions = {},\n): Promise<DropthisResult<DropResponse>> {\n\tconst baseKey = options.idempotencyKey ?? `sdk-${crypto.randomUUID()}`;\n\n\t// Step 1: create upload session\n\tconst createResult = await transport.request<CreateUploadSessionResponse>(\n\t\t\"POST\",\n\t\t\"/uploads\",\n\t\t{\n\t\t\tbody: prepared.manifest,\n\t\t\tidempotencyKey: `${baseKey}:create-upload`,\n\t\t},\n\t);\n\tif (createResult.error) return errorResult(createResult);\n\n\t// Step 2: upload each file via single PUT\n\tfor (const file of prepared.files) {\n\t\tconst target = createResult.data.files.find((f) => f.path === file.path);\n\t\tif (!target) {\n\t\t\treturn createErrorResult(\n\t\t\t\t\"upload_target_missing\",\n\t\t\t\t`Upload target missing for ${file.path}`,\n\t\t\t\tnull,\n\t\t\t);\n\t\t}\n\t\tif (target.upload.strategy !== \"single_put\") {\n\t\t\treturn createErrorResult(\n\t\t\t\t\"unsupported_upload_strategy\",\n\t\t\t\t`Unsupported upload strategy \"${target.upload.strategy}\" for ${file.path}. This SDK uploads via single PUT only.`,\n\t\t\t\tnull,\n\t\t\t);\n\t\t}\n\t\tconst put = await transport.putSignedUrl(\n\t\t\ttarget.upload.url,\n\t\t\tawait file.getBody(),\n\t\t\ttarget.upload.headers,\n\t\t);\n\t\tif (put.error) return errorResult(put);\n\t}\n\n\t// Step 3: complete upload session\n\tconst completeResult = await transport.request<UploadSessionResponse>(\n\t\t\"POST\",\n\t\t`/uploads/${encodeURIComponent(createResult.data.uploadId)}/complete`,\n\t\t{\n\t\t\tbody: { files: {} },\n\t\t\tidempotencyKey: `${baseKey}:complete-upload`,\n\t\t},\n\t);\n\tif (completeResult.error) return errorResult(completeResult);\n\n\t// Step 4: final publish\n\tconst finalOptions: Parameters<Transport[\"request\"]>[2] = {\n\t\tbody: {\n\t\t\tuploadId: createResult.data.uploadId,\n\t\t\toptions: prepared.options,\n\t\t\t...(prepared.metadata ? { metadata: prepared.metadata } : {}),\n\t\t},\n\t\tidempotencyKey: `${baseKey}:publish`,\n\t};\n\tif (options.ifRevision !== undefined)\n\t\tfinalOptions.ifRevision = options.ifRevision;\n\treturn transport.request<DropResponse>(\"POST\", finalPath, finalOptions);\n}\n\n/**\n * Executes the source-URL publish flow.\n * Sends a single POST to finalPath with { sourceUrl, options } and optional metadata.\n */\nexport async function publishSource(\n\ttransport: Transport,\n\tprepared: Extract<PreparedPublishRequest, { kind: \"source\" }>,\n\tfinalPath: string,\n\toptions: StagedPublishOptions = {},\n): Promise<DropthisResult<DropResponse>> {\n\tconst baseKey = options.idempotencyKey ?? `sdk-${crypto.randomUUID()}`;\n\treturn transport.request<DropResponse>(\"POST\", finalPath, {\n\t\tbody: {\n\t\t\tsourceUrl: prepared.sourceUrl,\n\t\t\toptions: prepared.options,\n\t\t\t...(prepared.metadata ? { metadata: prepared.metadata } : {}),\n\t\t},\n\t\tidempotencyKey: `${baseKey}:publish`,\n\t\t...(options.ifRevision !== undefined\n\t\t\t? { ifRevision: options.ifRevision }\n\t\t\t: {}),\n\t});\n}\n","import type { Transport } from \"../transport.js\";\nimport type { AccountResponse, DropthisResult } from \"../types.js\";\n\nexport class AccountResource {\n\tconstructor(private readonly transport: Transport) {}\n\n\tget(): Promise<DropthisResult<AccountResponse>> {\n\t\treturn this.transport.request(\"GET\", \"/account\");\n\t}\n\n\tupdate(input: {\n\t\tdisplayName: string | null;\n\t}): Promise<DropthisResult<AccountResponse>> {\n\t\treturn this.transport.request(\"PATCH\", \"/account\", { body: input });\n\t}\n\n\tdelete(): Promise<DropthisResult<null>> {\n\t\treturn this.transport.request(\"DELETE\", \"/account\");\n\t}\n}\n","import type { Transport } from \"../transport.js\";\nimport type {\n\tApiKeyCreatedResponse,\n\tApiKeyResponse,\n\tDropthisResult,\n} from \"../types.js\";\n\nexport class ApiKeysResource {\n\tconstructor(private readonly transport: Transport) {}\n\n\tlist(): Promise<DropthisResult<{ object: \"list\"; data: ApiKeyResponse[] }>> {\n\t\treturn this.transport.request(\"GET\", \"/api-keys\");\n\t}\n\n\tcreate(input: {\n\t\tlabel: string;\n\t}): Promise<DropthisResult<ApiKeyCreatedResponse>> {\n\t\treturn this.transport.request(\"POST\", \"/api-keys\", { body: input });\n\t}\n\n\tdelete(keyId: string): Promise<DropthisResult<{ ok: true }>> {\n\t\treturn this.transport.request(\n\t\t\t\"DELETE\",\n\t\t\t`/api-keys/${encodeURIComponent(keyId)}`,\n\t\t);\n\t}\n}\n","import type { Transport } from \"../transport.js\";\nimport type {\n\tDropDeploymentResponse,\n\tDropthisResult,\n\tListDeploymentsParams,\n\tListDeploymentsResponse,\n} from \"../types.js\";\n\nexport class DeploymentsResource {\n\tconstructor(private readonly transport: Transport) {}\n\n\tlist(\n\t\tdropId: string,\n\t\tparams: ListDeploymentsParams = {},\n\t): Promise<DropthisResult<ListDeploymentsResponse>> {\n\t\treturn this.transport.request(\n\t\t\t\"GET\",\n\t\t\t`/drops/${encodeURIComponent(dropId)}/deployments`,\n\t\t\t{ params },\n\t\t);\n\t}\n\n\tget(\n\t\tdropId: string,\n\t\tdeploymentId: string,\n\t): Promise<DropthisResult<DropDeploymentResponse>> {\n\t\treturn this.transport.request(\n\t\t\t\"GET\",\n\t\t\t`/drops/${encodeURIComponent(dropId)}/deployments/${encodeURIComponent(deploymentId)}`,\n\t\t);\n\t}\n}\n","import type { DropthisResult, ListPage } from \"./types.js\";\n\nexport class CursorPage<T> implements ListPage<T> {\n\treadonly object = \"list\" as const;\n\treadonly data: T[];\n\treadonly hasMore: boolean;\n\treadonly nextCursor: string | null;\n\tprivate readonly fetchNextPage:\n\t\t| (() => Promise<DropthisResult<CursorPage<T>>>)\n\t\t| undefined;\n\n\tconstructor(input: {\n\t\tdata: T[];\n\t\thasMore: boolean;\n\t\tnextCursor: string | null;\n\t\tfetchNextPage?: (() => Promise<DropthisResult<CursorPage<T>>>) | undefined;\n\t}) {\n\t\tthis.data = input.data;\n\t\tthis.hasMore = input.hasMore;\n\t\tthis.nextCursor = input.nextCursor;\n\t\tthis.fetchNextPage = input.fetchNextPage;\n\t}\n\n\tasync autoPagingToArray(options: { limit?: number } = {}): Promise<T[]> {\n\t\tconst items: T[] = [];\n\t\tfor await (const item of this) {\n\t\t\titems.push(item);\n\t\t\tif (options.limit !== undefined && items.length >= options.limit) break;\n\t\t}\n\t\treturn items;\n\t}\n\n\tasync *[Symbol.asyncIterator](): AsyncIterableIterator<T> {\n\t\tfor (const item of this.data) yield item;\n\t\tlet current: CursorPage<T> = this;\n\t\twhile (current.hasMore && current.fetchNextPage) {\n\t\t\tconst next = await current.fetchNextPage();\n\t\t\tif (next.error) break;\n\t\t\tcurrent = next.data;\n\t\t\tfor (const item of current.data) yield item;\n\t\t}\n\t}\n}\n","import { CursorPage } from \"../pagination.js\";\nimport type { Transport } from \"../transport.js\";\nimport type {\n\tDropOptions,\n\tDropResponse,\n\tDropthisResult,\n\tListDropsParams,\n\tRequestControls,\n} from \"../types.js\";\n\nexport class DropsResource {\n\tconstructor(private readonly transport: Transport) {}\n\n\tasync list(\n\t\tparams: ListDropsParams = {},\n\t): Promise<DropthisResult<CursorPage<DropResponse>>> {\n\t\tconst result = await this.transport.request<{\n\t\t\tdrops: DropResponse[];\n\t\t\tnextCursor: string | null;\n\t\t}>(\"GET\", \"/drops\", {\n\t\t\tparams: params as Record<string, string | number | boolean>,\n\t\t});\n\t\tif (result.error) return result;\n\t\tconst page = new CursorPage<DropResponse>({\n\t\t\tdata: result.data.drops,\n\t\t\tnextCursor: result.data.nextCursor,\n\t\t\thasMore: result.data.nextCursor !== null,\n\t\t\tfetchNextPage: result.data.nextCursor\n\t\t\t\t? () => this.list({ ...params, cursor: result.data.nextCursor })\n\t\t\t\t: undefined,\n\t\t});\n\t\treturn { data: page, error: null, headers: result.headers };\n\t}\n\n\tget(dropId: string): Promise<DropthisResult<DropResponse>> {\n\t\treturn this.transport.request(\n\t\t\t\"GET\",\n\t\t\t`/drops/${encodeURIComponent(dropId)}`,\n\t\t);\n\t}\n\n\tupdate(\n\t\tdropId: string,\n\t\toptions: DropOptions & RequestControls = {},\n\t): Promise<DropthisResult<DropResponse>> {\n\t\tconst requestOptions: Parameters<Transport[\"request\"]>[2] = {\n\t\t\tbody: updateBody(options),\n\t\t};\n\t\tif (options.idempotencyKey)\n\t\t\trequestOptions.idempotencyKey = options.idempotencyKey;\n\t\tif (options.ifRevision !== undefined)\n\t\t\trequestOptions.ifRevision = options.ifRevision;\n\t\treturn this.transport.request(\n\t\t\t\"PATCH\",\n\t\t\t`/drops/${encodeURIComponent(dropId)}`,\n\t\t\trequestOptions,\n\t\t);\n\t}\n\n\tdelete(dropId: string): Promise<DropthisResult<null>> {\n\t\treturn this.transport.request(\n\t\t\t\"DELETE\",\n\t\t\t`/drops/${encodeURIComponent(dropId)}`,\n\t\t);\n\t}\n}\n\nconst SETTINGS = [\n\t\"title\",\n\t\"visibility\",\n\t\"password\",\n\t\"noindex\",\n\t\"expiresAt\",\n\t\"slug\",\n] as const;\n\nfunction updateBody(options: DropOptions & RequestControls): unknown {\n\tconst out: Record<string, unknown> = {};\n\tfor (const key of SETTINGS)\n\t\tif (options[key] !== undefined) out[key] = options[key];\n\treturn {\n\t\toptions: out,\n\t\t...(options.metadata !== undefined ? { metadata: options.metadata } : {}),\n\t};\n}\n","export function toCamelKey(key: string): string {\n\treturn key.replace(/_([a-z])/g, (_, char: string) => char.toUpperCase());\n}\n\nexport function toSnakeKey(key: string): string {\n\treturn key.replace(/[A-Z]/g, (char) => `_${char.toLowerCase()}`);\n}\n\nconst PASSTHROUGH_KEYS = new Set([\"metadata\"]);\n\nexport function toCamelCase(value: unknown): unknown {\n\tif (Array.isArray(value)) return value.map(toCamelCase);\n\tif (value && typeof value === \"object\") {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries(value).map(([key, item]) => [\n\t\t\t\ttoCamelKey(key),\n\t\t\t\tPASSTHROUGH_KEYS.has(key) ? item : toCamelCase(item),\n\t\t\t]),\n\t\t);\n\t}\n\treturn value;\n}\n\nexport function toSnakeCase(value: unknown): unknown {\n\tif (Array.isArray(value)) return value.map(toSnakeCase);\n\tif (value && typeof value === \"object\") {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries(value)\n\t\t\t\t.filter(([, item]) => item !== undefined)\n\t\t\t\t.map(([key, item]) => [\n\t\t\t\t\ttoSnakeKey(key),\n\t\t\t\t\tPASSTHROUGH_KEYS.has(key) ? item : toSnakeCase(item),\n\t\t\t\t]),\n\t\t);\n\t}\n\treturn value;\n}\n","import { toCamelCase, toSnakeCase } from \"./case.js\";\nimport { createErrorResult } from \"./errors.js\";\nimport type {\n\tDropthisClientOptions,\n\tDropthisResult,\n\tRequestOptions,\n} from \"./types.js\";\n\nconst DEFAULT_BASE_URL = \"https://api.dropthis.app\";\nconst SDK_VERSION = \"0.6.0\";\n\nexport class Transport {\n\treadonly apiKey: string | undefined;\n\treadonly baseUrl: string;\n\treadonly timeoutMs: number;\n\treadonly uploadTimeoutMs: number;\n\treadonly fetchImpl: typeof globalThis.fetch;\n\n\tconstructor(options: DropthisClientOptions | string = {}) {\n\t\tconst resolved =\n\t\t\ttypeof options === \"string\" ? { apiKey: options } : options;\n\t\tthis.apiKey =\n\t\t\tresolved.apiKey ??\n\t\t\t(typeof process !== \"undefined\"\n\t\t\t\t? process.env?.DROPTHIS_API_KEY\n\t\t\t\t: undefined);\n\t\tthis.baseUrl = (resolved.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n\t\tthis.timeoutMs = resolved.timeoutMs ?? 30_000;\n\t\tthis.uploadTimeoutMs = resolved.uploadTimeoutMs ?? 120_000;\n\t\tthis.fetchImpl = resolved.fetch ?? globalThis.fetch;\n\t}\n\n\tasync putSignedUrl(\n\t\turl: string,\n\t\tbody: Uint8Array | Blob | ReadableStream,\n\t\theaders: Record<string, string>,\n\t): Promise<DropthisResult<{ etag: string | null }>> {\n\t\tconst controller = new AbortController();\n\t\tconst timeout = setTimeout(() => controller.abort(), this.uploadTimeoutMs);\n\t\ttry {\n\t\t\tconst request: RequestInit & { duplex?: \"half\" } = {\n\t\t\t\tmethod: \"PUT\",\n\t\t\t\theaders,\n\t\t\t\tbody: body as BodyInit,\n\t\t\t\tsignal: controller.signal,\n\t\t\t};\n\t\t\tif (body instanceof ReadableStream) request.duplex = \"half\";\n\t\t\tconst response = await this.fetchImpl(url, request);\n\t\t\tconst responseHeaders = headersToObject(response.headers);\n\t\t\tif (!response.ok) {\n\t\t\t\tconst text = await response.text();\n\t\t\t\treturn createErrorResult(\n\t\t\t\t\t`signed_upload_${response.status}`,\n\t\t\t\t\ttext || response.statusText,\n\t\t\t\t\tresponse.status,\n\t\t\t\t\t{ headers: responseHeaders },\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tdata: {\n\t\t\t\t\tetag: response.headers.get(\"ETag\") ?? responseHeaders.etag ?? null,\n\t\t\t\t},\n\t\t\t\terror: null,\n\t\t\t\theaders: responseHeaders,\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tconst message =\n\t\t\t\terror instanceof Error && error.name === \"AbortError\"\n\t\t\t\t\t? \"Request timed out\"\n\t\t\t\t\t: error instanceof Error\n\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t: \"Network error\";\n\t\t\treturn createErrorResult(\n\t\t\t\terror instanceof Error && error.name === \"AbortError\"\n\t\t\t\t\t? \"timeout\"\n\t\t\t\t\t: \"network_error\",\n\t\t\t\tmessage,\n\t\t\t\tnull,\n\t\t\t);\n\t\t} finally {\n\t\t\tclearTimeout(timeout);\n\t\t}\n\t}\n\n\tasync request<T>(\n\t\tmethod: string,\n\t\tpath: string,\n\t\toptions: RequestOptions & {\n\t\t\tbody?: unknown;\n\t\t\tbodyCase?: \"snake\" | \"raw\";\n\t\t\tparams?: Record<string, string | number | boolean | null | undefined>;\n\t\t} = {},\n\t): Promise<DropthisResult<T>> {\n\t\tconst authenticated = options.authenticated ?? true;\n\t\tif (authenticated && !this.apiKey) {\n\t\t\treturn createErrorResult<T>(\n\t\t\t\t\"missing_api_key\",\n\t\t\t\t\"No API key provided. Pass apiKey or set DROPTHIS_API_KEY.\",\n\t\t\t\tnull,\n\t\t\t);\n\t\t}\n\n\t\tconst headers: Record<string, string> = {\n\t\t\t\"user-agent\": `dropthis-node/${SDK_VERSION}`,\n\t\t};\n\t\tif (authenticated && this.apiKey)\n\t\t\theaders.authorization = `Bearer ${this.apiKey}`;\n\t\tif (options.idempotencyKey)\n\t\t\theaders[\"idempotency-key\"] = options.idempotencyKey;\n\t\tif (options.ifRevision !== undefined)\n\t\t\theaders[\"if-revision\"] = String(options.ifRevision);\n\t\tif (options.body !== undefined && !(options.body instanceof FormData))\n\t\t\theaders[\"content-type\"] = \"application/json\";\n\n\t\tconst url = new URL(`${this.baseUrl}${path}`);\n\t\tconst wireParams =\n\t\t\toptions.bodyCase === \"raw\"\n\t\t\t\t? options.params\n\t\t\t\t: (toSnakeCase(options.params ?? {}) as Record<string, unknown>);\n\t\tfor (const [key, value] of Object.entries(wireParams ?? {})) {\n\t\t\tif (value !== undefined && value !== null)\n\t\t\t\turl.searchParams.set(key, String(value));\n\t\t}\n\n\t\tconst controller = new AbortController();\n\t\tconst timeout = setTimeout(\n\t\t\t() => controller.abort(),\n\t\t\toptions.timeoutMs ?? this.timeoutMs,\n\t\t);\n\t\ttry {\n\t\t\tconst request: RequestInit = {\n\t\t\t\tmethod,\n\t\t\t\theaders,\n\t\t\t\tsignal: controller.signal,\n\t\t\t};\n\t\t\tif (options.body instanceof FormData) {\n\t\t\t\trequest.body = options.body;\n\t\t\t} else if (options.body !== undefined) {\n\t\t\t\tconst wireBody =\n\t\t\t\t\toptions.bodyCase === \"raw\" ? options.body : toSnakeCase(options.body);\n\t\t\t\trequest.body = JSON.stringify(wireBody);\n\t\t\t}\n\n\t\t\tconst response = await this.fetchImpl(url.toString(), request);\n\t\t\tconst responseHeaders = headersToObject(response.headers);\n\t\t\tconst text = await response.text();\n\t\t\tconst parsed = parseJson(text);\n\t\t\tif (!response.ok) {\n\t\t\t\tconst body =\n\t\t\t\t\tparsed && typeof parsed === \"object\"\n\t\t\t\t\t\t? (parsed as Record<string, unknown>)\n\t\t\t\t\t\t: {};\n\t\t\t\tconst message =\n\t\t\t\t\tstringValue(body.detail) ??\n\t\t\t\t\tstringValue(body.title) ??\n\t\t\t\t\tresponse.statusText;\n\t\t\t\tconst code =\n\t\t\t\t\tstringValue(body.code) ??\n\t\t\t\t\tstringValue(body.error_code) ??\n\t\t\t\t\t`http_${response.status}`;\n\t\t\t\tconst currentRevision = numberValue(body.current_revision);\n\t\t\t\tconst type = stringValue(body.type);\n\t\t\t\tconst title = stringValue(body.title);\n\t\t\t\tconst instance = stringValue(body.instance);\n\t\t\t\treturn createErrorResult<T>(code, message, response.status, {\n\t\t\t\t\tbody,\n\t\t\t\t\t...(type !== null ? { type } : {}),\n\t\t\t\t\t...(title !== null ? { title } : {}),\n\t\t\t\t\t...(instance !== null ? { instance } : {}),\n\t\t\t\t\tdetail: stringValue(body.detail),\n\t\t\t\t\tparam: stringValue(body.param),\n\t\t\t\t\t...(currentRevision !== undefined ? { currentRevision } : {}),\n\t\t\t\t\trequestId:\n\t\t\t\t\t\tstringValue(body.request_id) ??\n\t\t\t\t\t\tresponseHeaders[\"x-request-id\"] ??\n\t\t\t\t\t\tnull,\n\t\t\t\t\tsuggestion: stringValue(body.suggestion),\n\t\t\t\t\tretryable: booleanValue(body.retryable),\n\t\t\t\t\theaders: responseHeaders,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tdata: toCamelCase(parsed) as T,\n\t\t\t\terror: null,\n\t\t\t\theaders: responseHeaders,\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tconst message =\n\t\t\t\terror instanceof Error && error.name === \"AbortError\"\n\t\t\t\t\t? \"Request timed out\"\n\t\t\t\t\t: error instanceof Error\n\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t: \"Network error\";\n\t\t\treturn createErrorResult<T>(\n\t\t\t\terror instanceof Error && error.name === \"AbortError\"\n\t\t\t\t\t? \"timeout\"\n\t\t\t\t\t: \"network_error\",\n\t\t\t\tmessage,\n\t\t\t\tnull,\n\t\t\t);\n\t\t} finally {\n\t\t\tclearTimeout(timeout);\n\t\t}\n\t}\n}\n\nfunction headersToObject(headers: Headers): Record<string, string> {\n\tconst result: Record<string, string> = {};\n\theaders.forEach((value, key) => {\n\t\tresult[key.toLowerCase()] = value;\n\t});\n\treturn result;\n}\n\nfunction parseJson(text: string): unknown {\n\tif (!text) return null;\n\ttry {\n\t\treturn JSON.parse(text);\n\t} catch {\n\t\treturn text;\n\t}\n}\n\nfunction stringValue(value: unknown): string | null {\n\treturn typeof value === \"string\" ? value : null;\n}\n\nfunction numberValue(value: unknown): number | undefined {\n\treturn typeof value === \"number\" ? value : undefined;\n}\n\nfunction booleanValue(value: unknown): boolean | null {\n\treturn typeof value === \"boolean\" ? value : null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,IAAM,aAAa;AAEZ,SAAS,cAAc,SAAyB;AACtD,SAAO,QAAQ,QAAQ,YAAY,eAAe;AACnD;AAEO,SAAS,kBACf,MACA,SACA,YACA,QAYI,CAAC,GACe;AACpB,SAAO;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,MACN;AAAA,MACA,SAAS,cAAc,OAAO;AAAA,MAC9B;AAAA,MACA,GAA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"sources":["../src/edge.ts","../src/errors.ts","../src/publish/detect.ts","../src/publish/paths.ts","../src/publish/core.ts","../src/resources/account.ts","../src/resources/api-keys.ts","../src/resources/deployments.ts","../src/pagination.ts","../src/resources/drops.ts","../src/case.ts","../src/transport.ts"],"sourcesContent":["// Workers-safe entry for @dropthis/node. Reuses the fetch-based Transport and the\n// resource classes, and exposes canonical `publish`/`deploy` powered by the\n// fs-free core pipeline.\n//\n// IMPORTANT: this module must NOT import `./dropthis.js` or `./publish/node.js`,\n// which pull in `node:fs`, `node:path`, `node:crypto`, `fast-glob`, `ignore`,\n// and `Buffer` and cannot be bundled for Cloudflare Workers. The only publish\n// import allowed is `./publish/core.js` (verified fs-free). Keep the import\n// graph to: publish/core + transport + resources + errors + types only.\n//\n// Edge semantics:\n// bare string → inline content (no filesystem lookup; HTML/text auto-detected)\n// http(s) URL → {kind:\"source_url\"} via URL object or http(s) string → source flow\n// Uint8Array → staged single-file upload\n// {kind:\"files\"} → staged multi-file bundle (agent-native; full multi-file supported on edge)\n// string[] → NOT part of InMemoryPublishInput (no fs on edge)\n\nimport { toErrorResult } from \"./errors.js\";\nimport {\n\tdeployOptions,\n\ttype InMemoryPublishInput,\n\tpublishSource,\n\tpublishStaged,\n\tresolveInMemory,\n} from \"./publish/core.js\";\nimport { AccountResource } from \"./resources/account.js\";\nimport { ApiKeysResource } from \"./resources/api-keys.js\";\nimport { DeploymentsResource } from \"./resources/deployments.js\";\nimport { DropsResource } from \"./resources/drops.js\";\nimport { Transport } from \"./transport.js\";\nimport type {\n\tDeployOptions,\n\tDropResponse,\n\tDropthisClientOptions,\n\tDropthisResult,\n\tPublishOptions,\n} from \"./types.js\";\n\nexport type { InMemoryPublishInput } from \"./publish/core.js\";\n\n/** Workers-safe dropthis client. Pass an apiKey explicitly (no process.env on the edge). */\nexport class DropthisEdge {\n\tprivate readonly transport: Transport;\n\tprivate dropsResource?: DropsResource;\n\tprivate accountResource?: AccountResource;\n\tprivate apiKeysResource?: ApiKeysResource;\n\tprivate deploymentsResource?: DeploymentsResource;\n\n\tconstructor(options: DropthisClientOptions | string = {}) {\n\t\tthis.transport = new Transport(options);\n\t}\n\n\tget drops(): DropsResource {\n\t\tif (!this.dropsResource)\n\t\t\tthis.dropsResource = new DropsResource(this.transport);\n\t\treturn this.dropsResource;\n\t}\n\n\tget account(): AccountResource {\n\t\tif (!this.accountResource)\n\t\t\tthis.accountResource = new AccountResource(this.transport);\n\t\treturn this.accountResource;\n\t}\n\n\tget apiKeys(): ApiKeysResource {\n\t\tif (!this.apiKeysResource)\n\t\t\tthis.apiKeysResource = new ApiKeysResource(this.transport);\n\t\treturn this.apiKeysResource;\n\t}\n\n\tget deployments(): DeploymentsResource {\n\t\tif (!this.deploymentsResource)\n\t\t\tthis.deploymentsResource = new DeploymentsResource(this.transport);\n\t\treturn this.deploymentsResource;\n\t}\n\n\t/** Publish a NEW drop from in-memory content. */\n\tasync publish(\n\t\tinput: InMemoryPublishInput,\n\t\toptions: PublishOptions = {},\n\t): Promise<DropthisResult<DropResponse>> {\n\t\tlet prepared: Awaited<ReturnType<typeof resolveInMemory>>;\n\t\ttry {\n\t\t\tprepared = await resolveInMemory(input, options);\n\t\t} catch (e) {\n\t\t\treturn toErrorResult<DropResponse>(e);\n\t\t}\n\t\treturn prepared.kind === \"source\"\n\t\t\t? publishSource(this.transport, prepared, \"/drops\", options)\n\t\t\t: publishStaged(this.transport, prepared, \"/drops\", options);\n\t}\n\n\t/** Publish a NEW content version to an existing drop, keeping its URL. */\n\tasync deploy(\n\t\tdropId: string,\n\t\tinput: InMemoryPublishInput,\n\t\toptions: DeployOptions = {},\n\t): Promise<DropthisResult<DropResponse>> {\n\t\t// A deployment is content-only: strip drop settings/metadata BEFORE prepare. Use update()\n\t\t// to change settings.\n\t\tconst opts = deployOptions(options);\n\t\tlet prepared: Awaited<ReturnType<typeof resolveInMemory>>;\n\t\ttry {\n\t\t\tprepared = await resolveInMemory(input, opts);\n\t\t} catch (e) {\n\t\t\treturn toErrorResult<DropResponse>(e);\n\t\t}\n\t\tconst path = `/drops/${encodeURIComponent(dropId)}/deployments`;\n\t\treturn prepared.kind === \"source\"\n\t\t\t? publishSource(this.transport, prepared, path, opts)\n\t\t\t: publishStaged(this.transport, prepared, path, opts);\n\t}\n}\n","import type { DropthisResult } from \"./types.js\";\n\nconst API_KEY_RE = /sk_[A-Za-z0-9_-]+/g;\n\nexport function redactSecrets(message: string): string {\n\treturn message.replace(API_KEY_RE, \"sk_[redacted]\");\n}\n\nexport function createErrorResult<T>(\n\tcode: string,\n\tmessage: string,\n\tstatusCode: number | null,\n\textra: {\n\t\ttype?: string;\n\t\ttitle?: string;\n\t\tdetail?: string | null;\n\t\tinstance?: string | null;\n\t\tparam?: string | null;\n\t\tcurrentRevision?: number;\n\t\trequestId?: string | null;\n\t\theaders?: Record<string, string>;\n\t\tsuggestion?: string | null;\n\t\tretryable?: boolean | null;\n\t\tbody?: unknown;\n\t} = {},\n): DropthisResult<T> {\n\treturn {\n\t\tdata: null,\n\t\terror: {\n\t\t\tcode,\n\t\t\tmessage: redactSecrets(message),\n\t\t\tstatusCode,\n\t\t\t...(extra.type ? { type: extra.type } : {}),\n\t\t\t...(extra.title !== undefined ? { title: extra.title } : {}),\n\t\t\t...(extra.detail !== undefined ? { detail: extra.detail } : {}),\n\t\t\t...(extra.instance !== undefined ? { instance: extra.instance } : {}),\n\t\t\t...(extra.param !== undefined ? { param: extra.param } : {}),\n\t\t\t...(extra.currentRevision !== undefined\n\t\t\t\t? { currentRevision: extra.currentRevision }\n\t\t\t\t: {}),\n\t\t\t...(extra.requestId !== undefined ? { requestId: extra.requestId } : {}),\n\t\t\t...(extra.suggestion !== undefined\n\t\t\t\t? { suggestion: extra.suggestion }\n\t\t\t\t: {}),\n\t\t\t...(extra.retryable !== undefined ? { retryable: extra.retryable } : {}),\n\t\t\t...(extra.body !== undefined ? { body: extra.body } : {}),\n\t\t},\n\t\theaders: extra.headers ?? {},\n\t};\n}\n\nexport class PublishInputError extends Error {\n\tconstructor(\n\t\treadonly code: string,\n\t\tmessage: string,\n\t\treadonly param?: string,\n\t\treadonly suggestion?: string,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"PublishInputError\";\n\t}\n}\n\nexport function toErrorResult<T>(err: unknown): DropthisResult<T> {\n\tif (err instanceof PublishInputError)\n\t\treturn createErrorResult<T>(err.code, err.message, null, {\n\t\t\tparam: err.param ?? null,\n\t\t\tsuggestion: err.suggestion ?? null,\n\t\t});\n\treturn createErrorResult<T>(\n\t\t\"sdk_error\",\n\t\terr instanceof Error ? err.message : \"Unknown SDK error\",\n\t\tnull,\n\t);\n}\n","export function isHttpUrl(value: string): boolean {\n\ttry {\n\t\tconst url = new URL(value);\n\t\treturn url.protocol === \"http:\" || url.protocol === \"https:\";\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport function containsHtmlTag(value: string): boolean {\n\treturn /<[a-z!/][^>]*>/i.test(value);\n}\n\nconst FILE_EXT = /\\.[A-Za-z0-9]{1,8}([?#].*)?$/;\nexport function isPathShaped(value: string): boolean {\n\tif (value.length === 0 || value.length > 4096 || value.includes(\"\\n\"))\n\t\treturn false;\n\t// Reject strings that look like HTML (tags disqualify path interpretation)\n\tif (containsHtmlTag(value)) return false;\n\tif (value.includes(\"/\") || value.includes(\"\\\\\")) return true;\n\tif (/^[A-Za-z]:[\\\\/]/.test(value)) return true;\n\treturn FILE_EXT.test(value);\n}\n\nexport function contentTypeForString(value: string, override?: string): string {\n\tif (override) return override;\n\treturn containsHtmlTag(value) ? \"text/html\" : \"text/plain; charset=utf-8\";\n}\n\nexport function detectBytesContentType(bytes: Uint8Array): string {\n\tconst text = new TextDecoder(\"utf-8\", { fatal: false }).decode(bytes);\n\tif (text.includes(\"�\")) return \"application/octet-stream\";\n\treturn containsHtmlTag(text) ? \"text/html\" : \"text/plain; charset=utf-8\";\n}\n\nexport function entryForContentType(contentType: string): string {\n\tconst m = contentType.toLowerCase().split(\";\", 1)[0]?.trim() ?? \"\";\n\tif (m === \"text/html\" || m === \"application/xhtml+xml\") return \"index.html\";\n\tif (m === \"application/json\") return \"index.json\";\n\tif (m === \"text/css\") return \"index.css\";\n\tif (m === \"text/javascript\" || m === \"application/javascript\")\n\t\treturn \"index.js\";\n\tif (m.startsWith(\"text/\")) return \"index.txt\";\n\treturn \"index\";\n}\n","import { PublishInputError } from \"../errors.js\";\n\nexport function normalizeManifestPath(path: string): string {\n\treturn path.replace(/\\\\/g, \"/\").replace(/^\\.\\//, \"\");\n}\n\nexport function assertValidManifestPath(path: string): void {\n\t// User-supplied manifest paths ({kind:\"files\"}.path, options.path, options.entry) must be POSIX.\n\t// Local filesystem paths are normalized via normalizeManifestPath, NOT passed here.\n\tif (path.includes(\"\\\\\"))\n\t\tthrow new PublishInputError(\n\t\t\t\"invalid_path\",\n\t\t\t`Manifest path must use \"/\": \"${path}\".`,\n\t\t\tpath,\n\t\t);\n\tconst p = normalizeManifestPath(path);\n\tif (p === \"\")\n\t\tthrow new PublishInputError(\n\t\t\t\"invalid_path\",\n\t\t\t\"Manifest path must not be empty.\",\n\t\t\tpath,\n\t\t);\n\tif (p.startsWith(\"/\"))\n\t\tthrow new PublishInputError(\n\t\t\t\"invalid_path\",\n\t\t\t`Manifest path must be relative: \"${path}\".`,\n\t\t\tpath,\n\t\t);\n\tif (p.startsWith(\"~\"))\n\t\tthrow new PublishInputError(\n\t\t\t\"invalid_path\",\n\t\t\t`Manifest path must not start with \"~\": \"${path}\".`,\n\t\t\tpath,\n\t\t);\n\tif (p.split(\"/\").includes(\"..\"))\n\t\tthrow new PublishInputError(\n\t\t\t\"invalid_path\",\n\t\t\t`Manifest path must not contain \"..\": \"${path}\".`,\n\t\t\tpath,\n\t\t);\n}\n\nexport function assertNoDuplicatePaths(paths: string[]): void {\n\tconst seen = new Set<string>();\n\tfor (const raw of paths) {\n\t\tconst p = normalizeManifestPath(raw);\n\t\tif (seen.has(p))\n\t\t\tthrow new PublishInputError(\n\t\t\t\t\"duplicate_path\",\n\t\t\t\t`Duplicate file path after normalization: \"${p}\".`,\n\t\t\t\tp,\n\t\t\t\t\"Give each file a unique path; basename mapping for string[] can collide.\",\n\t\t\t);\n\t\tseen.add(p);\n\t}\n}\n\nexport function assertNonEmptyBundle(paths: string[]): void {\n\tif (paths.length === 0)\n\t\tthrow new PublishInputError(\n\t\t\t\"empty_bundle\",\n\t\t\t\"Nothing to publish: the bundle has no files.\",\n\t\t\tundefined,\n\t\t\t\"Pass at least one file, or a directory that contains files.\",\n\t\t);\n}\n","import { createErrorResult, PublishInputError } from \"../errors.js\";\nimport type { Transport } from \"../transport.js\";\nimport type {\n\tCreateUploadSessionRequest,\n\tCreateUploadSessionResponse,\n\tDeployOptions,\n\tDropResponse,\n\tDropthisResult,\n\tPublishFileInput,\n\tPublishOptions,\n\tUploadManifestFile,\n\tUploadSessionResponse,\n} from \"../types.js\";\nimport {\n\tcontentTypeForString,\n\tdetectBytesContentType,\n\tentryForContentType,\n\tisHttpUrl,\n} from \"./detect.js\";\nimport {\n\tassertNoDuplicatePaths,\n\tassertNonEmptyBundle,\n\tassertValidManifestPath,\n\tnormalizeManifestPath,\n} from \"./paths.js\";\n\n/**\n * A file ready to be staged for upload. The body is lazy: the orchestrator\n * calls `getBody()` per file when it is ready to push bytes to the signed URL.\n * This keeps the resolution layer pure and lets the filesystem layer (node.ts)\n * defer reads/streams until upload time.\n */\nexport type PreparedUploadFile = {\n\tpath: string;\n\tcontentType: string;\n\tsizeBytes: number;\n\tchecksumSha256?: string;\n\tgetBody(): Promise<Uint8Array | Blob | ReadableStream>;\n};\n\nexport type PreparedPublishRequest =\n\t| {\n\t\t\tkind: \"staged\";\n\t\t\tmanifest: CreateUploadSessionRequest;\n\t\t\tfiles: PreparedUploadFile[];\n\t\t\toptions: Record<string, unknown>;\n\t\t\tmetadata?: Record<string, unknown>;\n\t }\n\t| {\n\t\t\tkind: \"source\";\n\t\t\tsourceUrl: string;\n\t\t\toptions: Record<string, unknown>;\n\t\t\tmetadata?: Record<string, unknown>;\n\t };\n\n/**\n * The canonical publish inputs that can be resolved with no filesystem access:\n * the {@link PublishInput} union minus `string[]` (which is inherently a list\n * of filesystem paths handled by node.ts).\n */\nexport type InMemoryPublishInput =\n\t| string\n\t| URL\n\t| Uint8Array\n\t| { kind: \"content\"; content: string; contentType?: string; path?: string }\n\t| { kind: \"source_url\"; sourceUrl: string }\n\t| { kind: \"files\"; files: PublishFileInput[]; entry?: string };\n\nconst VALID_VISIBILITIES = [\"public\", \"unlisted\"] as const;\nconst MAX_TITLE_LENGTH = 500;\n\nexport function validatePublishOptions(options: PublishOptions): void {\n\tif (\n\t\toptions.title !== undefined &&\n\t\toptions.title !== null &&\n\t\toptions.title.length > MAX_TITLE_LENGTH\n\t) {\n\t\tthrow new Error(`Title must be ${MAX_TITLE_LENGTH} characters or less.`);\n\t}\n\n\tif (options.visibility !== undefined && options.visibility !== null) {\n\t\tif (\n\t\t\t!(VALID_VISIBILITIES as readonly string[]).includes(options.visibility)\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid visibility \"${options.visibility}\". Use \"public\" or \"unlisted\".`,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (options.expiresAt !== undefined && options.expiresAt !== null) {\n\t\tif (options.expiresAt instanceof Date) {\n\t\t\tif (Number.isNaN(options.expiresAt.getTime())) {\n\t\t\t\tthrow new Error(\"Invalid expiresAt date.\");\n\t\t\t}\n\t\t} else if (typeof options.expiresAt === \"string\") {\n\t\t\tconst parsed = new Date(options.expiresAt);\n\t\t\tif (Number.isNaN(parsed.getTime())) {\n\t\t\t\tthrow new Error(\"Invalid expiresAt date.\");\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function optionsBody(options: PublishOptions): Record<string, unknown> {\n\tvalidatePublishOptions(options);\n\tconst body: Record<string, unknown> = {};\n\tif (options.title !== undefined) body.title = options.title;\n\tif (options.visibility !== undefined) body.visibility = options.visibility;\n\tif (options.password !== undefined) body.password = options.password;\n\tif (options.noindex !== undefined) body.noindex = options.noindex;\n\tif (options.expiresAt !== undefined) {\n\t\tbody.expiresAt =\n\t\t\toptions.expiresAt instanceof Date\n\t\t\t\t? options.expiresAt.toISOString()\n\t\t\t\t: options.expiresAt;\n\t}\n\treturn body;\n}\n\n/**\n * Narrow options to the content-only subset for `deploy()`: a deployment ships a new content\n * version and never changes drop settings (title, visibility, password, noindex, expiry,\n * metadata). Picking only content-prep + request controls drops any settings BEFORE prepare,\n * so they are never validated, sent, or applied.\n */\nexport function deployOptions(options: DeployOptions): DeployOptions {\n\tconst out: DeployOptions = {};\n\tif (options.entry !== undefined) out.entry = options.entry;\n\tif (options.contentType !== undefined) out.contentType = options.contentType;\n\tif (options.path !== undefined) out.path = options.path;\n\tif (options.ignore !== undefined) out.ignore = options.ignore;\n\tif (options.ignoreDefaults !== undefined)\n\t\tout.ignoreDefaults = options.ignoreDefaults;\n\tif (options.idempotencyKey !== undefined)\n\t\tout.idempotencyKey = options.idempotencyKey;\n\tif (options.ifRevision !== undefined) out.ifRevision = options.ifRevision;\n\treturn out;\n}\n\n/**\n * Builds a staged upload request from already-prepared files. Validates the\n * bundle is non-empty, normalizes manifest paths, and rejects duplicates.\n * Reused by core's in-memory paths AND by node.ts for file/dir/string[] inputs.\n *\n * `entry` argument wins over `options.entry`.\n */\nexport function buildStagedRequest(\n\tfiles: PreparedUploadFile[],\n\toptions: PublishOptions,\n\tentry?: string,\n): PreparedPublishRequest {\n\tassertNonEmptyBundle(files.map((f) => f.path));\n\tconst normalizedPaths = files.map((f) => normalizeManifestPath(f.path));\n\tassertNoDuplicatePaths(normalizedPaths);\n\n\tconst manifestFiles: UploadManifestFile[] = files.map((file) => ({\n\t\tpath: normalizeManifestPath(file.path),\n\t\tcontentType: file.contentType,\n\t\tsizeBytes: file.sizeBytes,\n\t\t...(file.checksumSha256 ? { checksumSha256: file.checksumSha256 } : {}),\n\t}));\n\n\tconst resolvedEntry = entry ?? options.entry;\n\tif (resolvedEntry !== undefined) assertValidManifestPath(resolvedEntry);\n\tconst manifest: CreateUploadSessionRequest = {\n\t\tschemaVersion: 1,\n\t\tfiles: manifestFiles,\n\t\t...(resolvedEntry ? { entry: resolvedEntry } : {}),\n\t};\n\n\tconst prepared: Extract<PreparedPublishRequest, { kind: \"staged\" }> = {\n\t\tkind: \"staged\",\n\t\tmanifest,\n\t\tfiles,\n\t\toptions: optionsBody(options),\n\t};\n\tif (options.metadata) prepared.metadata = options.metadata;\n\treturn prepared;\n}\n\n/** Builds a `source_url` request (validates http(s)). */\nexport function buildSourceRequest(\n\tsourceUrl: string,\n\toptions: PublishOptions,\n): PreparedPublishRequest {\n\tif (!isHttpUrl(sourceUrl)) {\n\t\tthrow new PublishInputError(\n\t\t\t\"invalid_source_url\",\n\t\t\t\"source_url must be an http(s) URL.\",\n\t\t\tsourceUrl,\n\t\t\t\"Fetch the content first, then pass it as content/files.\",\n\t\t);\n\t}\n\tconst prepared: Extract<PreparedPublishRequest, { kind: \"source\" }> = {\n\t\tkind: \"source\",\n\t\tsourceUrl,\n\t\toptions: optionsBody(options),\n\t};\n\tif (options.metadata) prepared.metadata = options.metadata;\n\treturn prepared;\n}\n\nfunction decodeBase64(value: string): Uint8Array {\n\tconst binary = atob(value);\n\treturn Uint8Array.from(binary, (c) => c.charCodeAt(0));\n}\n\nfunction fileBytes(file: PublishFileInput): Uint8Array {\n\tif (file.content !== undefined) return new TextEncoder().encode(file.content);\n\tif (file.contentBase64 !== undefined) return decodeBase64(file.contentBase64);\n\tif (file.bytes !== undefined) return file.bytes;\n\tthrow new PublishInputError(\n\t\t\"missing_file_bytes\",\n\t\t`File \"${file.path}\" is missing content bytes.`,\n\t\tfile.path,\n\t\t\"Provide one of content, contentBase64, or bytes.\",\n\t);\n}\n\nfunction singleStagedFile(\n\tpath: string,\n\tcontentType: string,\n\tbytes: Uint8Array,\n\toptions: PublishOptions,\n): PreparedPublishRequest {\n\treturn buildStagedRequest(\n\t\t[\n\t\t\t{\n\t\t\t\tpath,\n\t\t\t\tcontentType,\n\t\t\t\tsizeBytes: bytes.byteLength,\n\t\t\t\tgetBody: async () => bytes,\n\t\t\t},\n\t\t],\n\t\toptions,\n\t);\n}\n\n/**\n * Resolves the in-memory canonical inputs (the edge subset of {@link PublishInput})\n * into a {@link PreparedPublishRequest}. Performs NO filesystem access.\n */\nexport async function resolveInMemory(\n\tinput: InMemoryPublishInput,\n\toptions: PublishOptions = {},\n): Promise<PreparedPublishRequest> {\n\tif (input instanceof URL) {\n\t\treturn buildSourceRequest(input.toString(), options);\n\t}\n\n\tif (typeof input === \"string\") {\n\t\tif (isHttpUrl(input)) return buildSourceRequest(input, options);\n\t\tconst contentType = contentTypeForString(input, options.contentType);\n\t\tif (options.path !== undefined) assertValidManifestPath(options.path);\n\t\tconst path = options.path ?? entryForContentType(contentType);\n\t\tconst bytes = new TextEncoder().encode(input);\n\t\treturn singleStagedFile(path, contentType, bytes, options);\n\t}\n\n\t// A Node binary buffer is a Uint8Array subclass, so this branch also covers\n\t// it without referencing the Node-only global.\n\tif (input instanceof Uint8Array) {\n\t\tconst contentType = options.contentType ?? detectBytesContentType(input);\n\t\tif (options.path !== undefined) assertValidManifestPath(options.path);\n\t\tconst path = options.path ?? entryForContentType(contentType);\n\t\treturn singleStagedFile(path, contentType, input, options);\n\t}\n\n\tif (input.kind === \"content\") {\n\t\tconst contentType = input.contentType ?? options.contentType ?? \"text/html\";\n\t\tif (input.path !== undefined) assertValidManifestPath(input.path);\n\t\tif (options.path !== undefined) assertValidManifestPath(options.path);\n\t\tconst path = input.path ?? options.path ?? entryForContentType(contentType);\n\t\tconst bytes = new TextEncoder().encode(input.content);\n\t\treturn singleStagedFile(path, contentType, bytes, options);\n\t}\n\n\tif (input.kind === \"source_url\") {\n\t\treturn buildSourceRequest(input.sourceUrl, options);\n\t}\n\n\t// input.kind === \"files\"\n\tconst files: PreparedUploadFile[] = input.files.map((file) => {\n\t\tassertValidManifestPath(file.path);\n\t\tconst bytes = fileBytes(file);\n\t\tconst contentType = file.contentType ?? detectBytesContentType(bytes);\n\t\treturn {\n\t\t\tpath: file.path,\n\t\t\tcontentType,\n\t\t\tsizeBytes: bytes.byteLength,\n\t\t\tgetBody: async () => bytes,\n\t\t};\n\t});\n\treturn buildStagedRequest(files, options, input.entry);\n}\n\n// ---------------------------------------------------------------------------\n// Orchestration helpers\n// ---------------------------------------------------------------------------\n\ntype StagedPublishOptions = { idempotencyKey?: string; ifRevision?: number };\n\nfunction errorResult<T>(result: DropthisResult<unknown>): DropthisResult<T> {\n\tif (!result.error) throw new Error(\"Expected an error result\");\n\treturn { data: null, error: result.error, headers: result.headers };\n}\n\n/**\n * Executes the staged-upload publish flow (single-PUT only).\n * Calls POST /uploads → PUT signed URL per file → POST /uploads/{id}/complete\n * → POST finalPath. (Paths are version-agnostic here; the transport prefixes /v1.)\n */\nexport async function publishStaged(\n\ttransport: Transport,\n\tprepared: Extract<PreparedPublishRequest, { kind: \"staged\" }>,\n\tfinalPath: string,\n\toptions: StagedPublishOptions = {},\n): Promise<DropthisResult<DropResponse>> {\n\tconst baseKey = options.idempotencyKey ?? `sdk-${crypto.randomUUID()}`;\n\n\t// Step 1: create upload session\n\tconst createResult = await transport.request<CreateUploadSessionResponse>(\n\t\t\"POST\",\n\t\t\"/uploads\",\n\t\t{\n\t\t\tbody: prepared.manifest,\n\t\t\tidempotencyKey: `${baseKey}:create-upload`,\n\t\t},\n\t);\n\tif (createResult.error) return errorResult(createResult);\n\n\t// Step 2: upload each file via single PUT\n\tfor (const file of prepared.files) {\n\t\tconst target = createResult.data.files.find((f) => f.path === file.path);\n\t\tif (!target) {\n\t\t\treturn createErrorResult(\n\t\t\t\t\"upload_target_missing\",\n\t\t\t\t`Upload target missing for ${file.path}`,\n\t\t\t\tnull,\n\t\t\t);\n\t\t}\n\t\tif (target.upload.strategy !== \"single_put\") {\n\t\t\treturn createErrorResult(\n\t\t\t\t\"unsupported_upload_strategy\",\n\t\t\t\t`Unsupported upload strategy \"${target.upload.strategy}\" for ${file.path}. This SDK uploads via single PUT only.`,\n\t\t\t\tnull,\n\t\t\t);\n\t\t}\n\t\tconst put = await transport.putSignedUrl(\n\t\t\ttarget.upload.url,\n\t\t\tawait file.getBody(),\n\t\t\ttarget.upload.headers,\n\t\t);\n\t\tif (put.error) return errorResult(put);\n\t}\n\n\t// Step 3: complete upload session\n\tconst completeResult = await transport.request<UploadSessionResponse>(\n\t\t\"POST\",\n\t\t`/uploads/${encodeURIComponent(createResult.data.uploadId)}/complete`,\n\t\t{\n\t\t\tbody: { files: {} },\n\t\t\tidempotencyKey: `${baseKey}:complete-upload`,\n\t\t},\n\t);\n\tif (completeResult.error) return errorResult(completeResult);\n\n\t// Step 4: final publish\n\tconst finalOptions: Parameters<Transport[\"request\"]>[2] = {\n\t\tbody: {\n\t\t\tuploadId: createResult.data.uploadId,\n\t\t\t...(Object.keys(prepared.options).length > 0\n\t\t\t\t? { options: prepared.options }\n\t\t\t\t: {}),\n\t\t\t...(prepared.metadata ? { metadata: prepared.metadata } : {}),\n\t\t},\n\t\tidempotencyKey: `${baseKey}:publish`,\n\t};\n\tif (options.ifRevision !== undefined)\n\t\tfinalOptions.ifRevision = options.ifRevision;\n\treturn transport.request<DropResponse>(\"POST\", finalPath, finalOptions);\n}\n\n/**\n * Executes the source-URL publish flow.\n * Sends a single POST to finalPath with { sourceUrl, options } and optional metadata.\n */\nexport async function publishSource(\n\ttransport: Transport,\n\tprepared: Extract<PreparedPublishRequest, { kind: \"source\" }>,\n\tfinalPath: string,\n\toptions: StagedPublishOptions = {},\n): Promise<DropthisResult<DropResponse>> {\n\tconst baseKey = options.idempotencyKey ?? `sdk-${crypto.randomUUID()}`;\n\treturn transport.request<DropResponse>(\"POST\", finalPath, {\n\t\tbody: {\n\t\t\tsourceUrl: prepared.sourceUrl,\n\t\t\t...(Object.keys(prepared.options).length > 0\n\t\t\t\t? { options: prepared.options }\n\t\t\t\t: {}),\n\t\t\t...(prepared.metadata ? { metadata: prepared.metadata } : {}),\n\t\t},\n\t\tidempotencyKey: `${baseKey}:publish`,\n\t\t...(options.ifRevision !== undefined\n\t\t\t? { ifRevision: options.ifRevision }\n\t\t\t: {}),\n\t});\n}\n","import type { Transport } from \"../transport.js\";\nimport type { AccountResponse, DropthisResult } from \"../types.js\";\n\nexport class AccountResource {\n\tconstructor(private readonly transport: Transport) {}\n\n\tget(): Promise<DropthisResult<AccountResponse>> {\n\t\treturn this.transport.request(\"GET\", \"/account\");\n\t}\n\n\tupdate(input: {\n\t\tdisplayName: string | null;\n\t}): Promise<DropthisResult<AccountResponse>> {\n\t\treturn this.transport.request(\"PATCH\", \"/account\", { body: input });\n\t}\n\n\tdelete(): Promise<DropthisResult<null>> {\n\t\treturn this.transport.request(\"DELETE\", \"/account\");\n\t}\n}\n","import type { Transport } from \"../transport.js\";\nimport type {\n\tApiKeyCreatedResponse,\n\tApiKeyResponse,\n\tDropthisResult,\n} from \"../types.js\";\n\nexport class ApiKeysResource {\n\tconstructor(private readonly transport: Transport) {}\n\n\tlist(): Promise<DropthisResult<{ object: \"list\"; data: ApiKeyResponse[] }>> {\n\t\treturn this.transport.request(\"GET\", \"/api-keys\");\n\t}\n\n\tcreate(input: {\n\t\tlabel: string;\n\t}): Promise<DropthisResult<ApiKeyCreatedResponse>> {\n\t\treturn this.transport.request(\"POST\", \"/api-keys\", { body: input });\n\t}\n\n\tdelete(keyId: string): Promise<DropthisResult<{ ok: true }>> {\n\t\treturn this.transport.request(\n\t\t\t\"DELETE\",\n\t\t\t`/api-keys/${encodeURIComponent(keyId)}`,\n\t\t);\n\t}\n}\n","import type { Transport } from \"../transport.js\";\nimport type {\n\tDropDeploymentResponse,\n\tDropthisResult,\n\tListDeploymentsParams,\n\tListDeploymentsResponse,\n} from \"../types.js\";\n\nexport class DeploymentsResource {\n\tconstructor(private readonly transport: Transport) {}\n\n\tlist(\n\t\tdropId: string,\n\t\tparams: ListDeploymentsParams = {},\n\t): Promise<DropthisResult<ListDeploymentsResponse>> {\n\t\treturn this.transport.request(\n\t\t\t\"GET\",\n\t\t\t`/drops/${encodeURIComponent(dropId)}/deployments`,\n\t\t\t{ params },\n\t\t);\n\t}\n\n\tget(\n\t\tdropId: string,\n\t\tdeploymentId: string,\n\t): Promise<DropthisResult<DropDeploymentResponse>> {\n\t\treturn this.transport.request(\n\t\t\t\"GET\",\n\t\t\t`/drops/${encodeURIComponent(dropId)}/deployments/${encodeURIComponent(deploymentId)}`,\n\t\t);\n\t}\n}\n","import type { DropthisResult, ListPage } from \"./types.js\";\n\nexport class CursorPage<T> implements ListPage<T> {\n\treadonly object = \"list\" as const;\n\treadonly data: T[];\n\treadonly hasMore: boolean;\n\treadonly nextCursor: string | null;\n\tprivate readonly fetchNextPage:\n\t\t| (() => Promise<DropthisResult<CursorPage<T>>>)\n\t\t| undefined;\n\n\tconstructor(input: {\n\t\tdata: T[];\n\t\thasMore: boolean;\n\t\tnextCursor: string | null;\n\t\tfetchNextPage?: (() => Promise<DropthisResult<CursorPage<T>>>) | undefined;\n\t}) {\n\t\tthis.data = input.data;\n\t\tthis.hasMore = input.hasMore;\n\t\tthis.nextCursor = input.nextCursor;\n\t\tthis.fetchNextPage = input.fetchNextPage;\n\t}\n\n\tasync autoPagingToArray(options: { limit?: number } = {}): Promise<T[]> {\n\t\tconst items: T[] = [];\n\t\tfor await (const item of this) {\n\t\t\titems.push(item);\n\t\t\tif (options.limit !== undefined && items.length >= options.limit) break;\n\t\t}\n\t\treturn items;\n\t}\n\n\tasync *[Symbol.asyncIterator](): AsyncIterableIterator<T> {\n\t\tfor (const item of this.data) yield item;\n\t\tlet current: CursorPage<T> = this;\n\t\twhile (current.hasMore && current.fetchNextPage) {\n\t\t\tconst next = await current.fetchNextPage();\n\t\t\tif (next.error) break;\n\t\t\tcurrent = next.data;\n\t\t\tfor (const item of current.data) yield item;\n\t\t}\n\t}\n}\n","import { CursorPage } from \"../pagination.js\";\nimport type { Transport } from \"../transport.js\";\nimport type {\n\tDropOptions,\n\tDropResponse,\n\tDropthisResult,\n\tListDropsParams,\n\tRequestControls,\n} from \"../types.js\";\n\nexport class DropsResource {\n\tconstructor(private readonly transport: Transport) {}\n\n\tasync list(\n\t\tparams: ListDropsParams = {},\n\t): Promise<DropthisResult<CursorPage<DropResponse>>> {\n\t\tconst result = await this.transport.request<{\n\t\t\tdrops: DropResponse[];\n\t\t\tnextCursor: string | null;\n\t\t}>(\"GET\", \"/drops\", {\n\t\t\tparams: params as Record<string, string | number | boolean>,\n\t\t});\n\t\tif (result.error) return result;\n\t\tconst page = new CursorPage<DropResponse>({\n\t\t\tdata: result.data.drops,\n\t\t\tnextCursor: result.data.nextCursor,\n\t\t\thasMore: result.data.nextCursor !== null,\n\t\t\tfetchNextPage: result.data.nextCursor\n\t\t\t\t? () => this.list({ ...params, cursor: result.data.nextCursor })\n\t\t\t\t: undefined,\n\t\t});\n\t\treturn { data: page, error: null, headers: result.headers };\n\t}\n\n\tget(dropId: string): Promise<DropthisResult<DropResponse>> {\n\t\treturn this.transport.request(\n\t\t\t\"GET\",\n\t\t\t`/drops/${encodeURIComponent(dropId)}`,\n\t\t);\n\t}\n\n\tupdate(\n\t\tdropId: string,\n\t\toptions: DropOptions & RequestControls = {},\n\t): Promise<DropthisResult<DropResponse>> {\n\t\tconst requestOptions: Parameters<Transport[\"request\"]>[2] = {\n\t\t\tbody: updateBody(options),\n\t\t};\n\t\tif (options.idempotencyKey)\n\t\t\trequestOptions.idempotencyKey = options.idempotencyKey;\n\t\tif (options.ifRevision !== undefined)\n\t\t\trequestOptions.ifRevision = options.ifRevision;\n\t\treturn this.transport.request(\n\t\t\t\"PATCH\",\n\t\t\t`/drops/${encodeURIComponent(dropId)}`,\n\t\t\trequestOptions,\n\t\t);\n\t}\n\n\tdelete(dropId: string): Promise<DropthisResult<null>> {\n\t\treturn this.transport.request(\n\t\t\t\"DELETE\",\n\t\t\t`/drops/${encodeURIComponent(dropId)}`,\n\t\t);\n\t}\n}\n\nconst SETTINGS = [\n\t\"title\",\n\t\"visibility\",\n\t\"password\",\n\t\"noindex\",\n\t\"expiresAt\",\n\t\"slug\",\n] as const;\n\nfunction updateBody(options: DropOptions & RequestControls): unknown {\n\tconst out: Record<string, unknown> = {};\n\tfor (const key of SETTINGS)\n\t\tif (options[key] !== undefined) out[key] = options[key];\n\treturn {\n\t\toptions: out,\n\t\t...(options.metadata !== undefined ? { metadata: options.metadata } : {}),\n\t};\n}\n","export function toCamelKey(key: string): string {\n\treturn key.replace(/_([a-z])/g, (_, char: string) => char.toUpperCase());\n}\n\nexport function toSnakeKey(key: string): string {\n\treturn key.replace(/[A-Z]/g, (char) => `_${char.toLowerCase()}`);\n}\n\nconst PASSTHROUGH_KEYS = new Set([\"metadata\"]);\n\nexport function toCamelCase(value: unknown): unknown {\n\tif (Array.isArray(value)) return value.map(toCamelCase);\n\tif (value && typeof value === \"object\") {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries(value).map(([key, item]) => [\n\t\t\t\ttoCamelKey(key),\n\t\t\t\tPASSTHROUGH_KEYS.has(key) ? item : toCamelCase(item),\n\t\t\t]),\n\t\t);\n\t}\n\treturn value;\n}\n\nexport function toSnakeCase(value: unknown): unknown {\n\tif (Array.isArray(value)) return value.map(toSnakeCase);\n\tif (value && typeof value === \"object\") {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries(value)\n\t\t\t\t.filter(([, item]) => item !== undefined)\n\t\t\t\t.map(([key, item]) => [\n\t\t\t\t\ttoSnakeKey(key),\n\t\t\t\t\tPASSTHROUGH_KEYS.has(key) ? item : toSnakeCase(item),\n\t\t\t\t]),\n\t\t);\n\t}\n\treturn value;\n}\n","import { toCamelCase, toSnakeCase } from \"./case.js\";\nimport { createErrorResult } from \"./errors.js\";\nimport type {\n\tDropthisClientOptions,\n\tDropthisResult,\n\tRequestOptions,\n} from \"./types.js\";\n\nconst DEFAULT_BASE_URL = \"https://api.dropthis.app\";\nconst SDK_VERSION = \"0.8.0\";\n\nexport class Transport {\n\treadonly apiKey: string | undefined;\n\treadonly baseUrl: string;\n\treadonly timeoutMs: number;\n\treadonly uploadTimeoutMs: number;\n\treadonly fetchImpl: typeof globalThis.fetch;\n\n\tconstructor(options: DropthisClientOptions | string = {}) {\n\t\tconst resolved =\n\t\t\ttypeof options === \"string\" ? { apiKey: options } : options;\n\t\tthis.apiKey =\n\t\t\tresolved.apiKey ??\n\t\t\t(typeof process !== \"undefined\"\n\t\t\t\t? process.env?.DROPTHIS_API_KEY\n\t\t\t\t: undefined);\n\t\t// All API endpoints live under the /v1 version prefix; fold it into the configured host\n\t\t// (default or custom) once, so resource paths stay version-agnostic (\"/drops\", …). Parse via\n\t\t// URL so a stray trailing slash, query, or hash on the base can't corrupt the request path.\n\t\tconst base = new URL(resolved.baseUrl ?? DEFAULT_BASE_URL);\n\t\tconst basePath = base.pathname.replace(/\\/+$/, \"\");\n\t\tbase.pathname = basePath.endsWith(\"/v1\") ? basePath : `${basePath}/v1`;\n\t\tbase.search = \"\";\n\t\tbase.hash = \"\";\n\t\tthis.baseUrl = base.toString().replace(/\\/+$/, \"\");\n\t\tthis.timeoutMs = resolved.timeoutMs ?? 30_000;\n\t\tthis.uploadTimeoutMs = resolved.uploadTimeoutMs ?? 120_000;\n\t\tthis.fetchImpl = resolved.fetch ?? globalThis.fetch;\n\t}\n\n\tasync putSignedUrl(\n\t\turl: string,\n\t\tbody: Uint8Array | Blob | ReadableStream,\n\t\theaders: Record<string, string>,\n\t): Promise<DropthisResult<{ etag: string | null }>> {\n\t\tconst controller = new AbortController();\n\t\tconst timeout = setTimeout(() => controller.abort(), this.uploadTimeoutMs);\n\t\ttry {\n\t\t\tconst request: RequestInit & { duplex?: \"half\" } = {\n\t\t\t\tmethod: \"PUT\",\n\t\t\t\theaders,\n\t\t\t\tbody: body as BodyInit,\n\t\t\t\tsignal: controller.signal,\n\t\t\t};\n\t\t\tif (body instanceof ReadableStream) request.duplex = \"half\";\n\t\t\tconst response = await this.fetchImpl(url, request);\n\t\t\tconst responseHeaders = headersToObject(response.headers);\n\t\t\tif (!response.ok) {\n\t\t\t\tconst text = await response.text();\n\t\t\t\treturn createErrorResult(\n\t\t\t\t\t`signed_upload_${response.status}`,\n\t\t\t\t\ttext || response.statusText,\n\t\t\t\t\tresponse.status,\n\t\t\t\t\t{ headers: responseHeaders },\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tdata: {\n\t\t\t\t\tetag: response.headers.get(\"ETag\") ?? responseHeaders.etag ?? null,\n\t\t\t\t},\n\t\t\t\terror: null,\n\t\t\t\theaders: responseHeaders,\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tconst message =\n\t\t\t\terror instanceof Error && error.name === \"AbortError\"\n\t\t\t\t\t? \"Request timed out\"\n\t\t\t\t\t: error instanceof Error\n\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t: \"Network error\";\n\t\t\treturn createErrorResult(\n\t\t\t\terror instanceof Error && error.name === \"AbortError\"\n\t\t\t\t\t? \"timeout\"\n\t\t\t\t\t: \"network_error\",\n\t\t\t\tmessage,\n\t\t\t\tnull,\n\t\t\t);\n\t\t} finally {\n\t\t\tclearTimeout(timeout);\n\t\t}\n\t}\n\n\tasync request<T>(\n\t\tmethod: string,\n\t\tpath: string,\n\t\toptions: RequestOptions & {\n\t\t\tbody?: unknown;\n\t\t\tbodyCase?: \"snake\" | \"raw\";\n\t\t\tparams?: Record<string, string | number | boolean | null | undefined>;\n\t\t} = {},\n\t): Promise<DropthisResult<T>> {\n\t\tconst authenticated = options.authenticated ?? true;\n\t\tif (authenticated && !this.apiKey) {\n\t\t\treturn createErrorResult<T>(\n\t\t\t\t\"missing_api_key\",\n\t\t\t\t\"No API key provided. Pass apiKey or set DROPTHIS_API_KEY.\",\n\t\t\t\tnull,\n\t\t\t);\n\t\t}\n\n\t\tconst headers: Record<string, string> = {\n\t\t\t\"user-agent\": `dropthis-node/${SDK_VERSION}`,\n\t\t};\n\t\tif (authenticated && this.apiKey)\n\t\t\theaders.authorization = `Bearer ${this.apiKey}`;\n\t\tif (options.idempotencyKey)\n\t\t\theaders[\"idempotency-key\"] = options.idempotencyKey;\n\t\tif (options.ifRevision !== undefined)\n\t\t\theaders[\"if-revision\"] = String(options.ifRevision);\n\t\tif (options.body !== undefined && !(options.body instanceof FormData))\n\t\t\theaders[\"content-type\"] = \"application/json\";\n\n\t\tconst url = new URL(`${this.baseUrl}${path}`);\n\t\tconst wireParams =\n\t\t\toptions.bodyCase === \"raw\"\n\t\t\t\t? options.params\n\t\t\t\t: (toSnakeCase(options.params ?? {}) as Record<string, unknown>);\n\t\tfor (const [key, value] of Object.entries(wireParams ?? {})) {\n\t\t\tif (value !== undefined && value !== null)\n\t\t\t\turl.searchParams.set(key, String(value));\n\t\t}\n\n\t\tconst controller = new AbortController();\n\t\tconst timeout = setTimeout(\n\t\t\t() => controller.abort(),\n\t\t\toptions.timeoutMs ?? this.timeoutMs,\n\t\t);\n\t\ttry {\n\t\t\tconst request: RequestInit = {\n\t\t\t\tmethod,\n\t\t\t\theaders,\n\t\t\t\tsignal: controller.signal,\n\t\t\t};\n\t\t\tif (options.body instanceof FormData) {\n\t\t\t\trequest.body = options.body;\n\t\t\t} else if (options.body !== undefined) {\n\t\t\t\tconst wireBody =\n\t\t\t\t\toptions.bodyCase === \"raw\" ? options.body : toSnakeCase(options.body);\n\t\t\t\trequest.body = JSON.stringify(wireBody);\n\t\t\t}\n\n\t\t\tconst response = await this.fetchImpl(url.toString(), request);\n\t\t\tconst responseHeaders = headersToObject(response.headers);\n\t\t\tconst text = await response.text();\n\t\t\tconst parsed = parseJson(text);\n\t\t\tif (!response.ok) {\n\t\t\t\tconst body =\n\t\t\t\t\tparsed && typeof parsed === \"object\"\n\t\t\t\t\t\t? (parsed as Record<string, unknown>)\n\t\t\t\t\t\t: {};\n\t\t\t\tconst message =\n\t\t\t\t\tstringValue(body.detail) ??\n\t\t\t\t\tstringValue(body.title) ??\n\t\t\t\t\tresponse.statusText;\n\t\t\t\tconst code =\n\t\t\t\t\tstringValue(body.code) ??\n\t\t\t\t\tstringValue(body.error_code) ??\n\t\t\t\t\t`http_${response.status}`;\n\t\t\t\tconst currentRevision = numberValue(body.current_revision);\n\t\t\t\tconst type = stringValue(body.type);\n\t\t\t\tconst title = stringValue(body.title);\n\t\t\t\tconst instance = stringValue(body.instance);\n\t\t\t\treturn createErrorResult<T>(code, message, response.status, {\n\t\t\t\t\tbody,\n\t\t\t\t\t...(type !== null ? { type } : {}),\n\t\t\t\t\t...(title !== null ? { title } : {}),\n\t\t\t\t\t...(instance !== null ? { instance } : {}),\n\t\t\t\t\tdetail: stringValue(body.detail),\n\t\t\t\t\tparam: stringValue(body.param),\n\t\t\t\t\t...(currentRevision !== undefined ? { currentRevision } : {}),\n\t\t\t\t\trequestId:\n\t\t\t\t\t\tstringValue(body.request_id) ??\n\t\t\t\t\t\tresponseHeaders[\"x-request-id\"] ??\n\t\t\t\t\t\tnull,\n\t\t\t\t\tsuggestion: stringValue(body.suggestion),\n\t\t\t\t\tretryable: booleanValue(body.retryable),\n\t\t\t\t\theaders: responseHeaders,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tdata: toCamelCase(parsed) as T,\n\t\t\t\terror: null,\n\t\t\t\theaders: responseHeaders,\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tconst message =\n\t\t\t\terror instanceof Error && error.name === \"AbortError\"\n\t\t\t\t\t? \"Request timed out\"\n\t\t\t\t\t: error instanceof Error\n\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t: \"Network error\";\n\t\t\treturn createErrorResult<T>(\n\t\t\t\terror instanceof Error && error.name === \"AbortError\"\n\t\t\t\t\t? \"timeout\"\n\t\t\t\t\t: \"network_error\",\n\t\t\t\tmessage,\n\t\t\t\tnull,\n\t\t\t);\n\t\t} finally {\n\t\t\tclearTimeout(timeout);\n\t\t}\n\t}\n}\n\nfunction headersToObject(headers: Headers): Record<string, string> {\n\tconst result: Record<string, string> = {};\n\theaders.forEach((value, key) => {\n\t\tresult[key.toLowerCase()] = value;\n\t});\n\treturn result;\n}\n\nfunction parseJson(text: string): unknown {\n\tif (!text) return null;\n\ttry {\n\t\treturn JSON.parse(text);\n\t} catch {\n\t\treturn text;\n\t}\n}\n\nfunction stringValue(value: unknown): string | null {\n\treturn typeof value === \"string\" ? value : null;\n}\n\nfunction numberValue(value: unknown): number | undefined {\n\treturn typeof value === \"number\" ? value : undefined;\n}\n\nfunction booleanValue(value: unknown): boolean | null {\n\treturn typeof value === \"boolean\" ? value : null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,IAAM,aAAa;AAEZ,SAAS,cAAc,SAAyB;AACtD,SAAO,QAAQ,QAAQ,YAAY,eAAe;AACnD;AAEO,SAAS,kBACf,MACA,SACA,YACA,QAYI,CAAC,GACe;AACpB,SAAO;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,MACN;AAAA,MACA,SAAS,cAAc,OAAO;AAAA,MAC9B;AAAA,MACA,GAAI,MAAM,OAAO,EAAE,MAAM,MAAM,KAAK,IAAI,CAAC;AAAA,MACzC,GAAI,MAAM,UAAU,SAAY,EAAE,OAAO,MAAM,MAAM,IAAI,CAAC;AAAA,MAC1D,GAAI,MAAM,WAAW,SAAY,EAAE,QAAQ,MAAM,OAAO,IAAI,CAAC;AAAA,MAC7D,GAAI,MAAM,aAAa,SAAY,EAAE,UAAU,MAAM,SAAS,IAAI,CAAC;AAAA,MACnE,GAAI,MAAM,UAAU,SAAY,EAAE,OAAO,MAAM,MAAM,IAAI,CAAC;AAAA,MAC1D,GAAI,MAAM,oBAAoB,SAC3B,EAAE,iBAAiB,MAAM,gBAAgB,IACzC,CAAC;AAAA,MACJ,GAAI,MAAM,cAAc,SAAY,EAAE,WAAW,MAAM,UAAU,IAAI,CAAC;AAAA,MACtE,GAAI,MAAM,eAAe,SACtB,EAAE,YAAY,MAAM,WAAW,IAC/B,CAAC;AAAA,MACJ,GAAI,MAAM,cAAc,SAAY,EAAE,WAAW,MAAM,UAAU,IAAI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xC,UAAM,OAAO,cAAc,OAAO;AAClC,QAAI;AACJ,QAAI;AACH,iBAAW,MAAM,gBAAgB,OAAO,IAAI;AAAA,IAC7C,SAAS,GAAG;AACX,aAAO,cAA4B,CAAC;AAAA,IACrC;AACA,UAAM,OAAO,UAAU,mBAAmB,MAAM,CAAC;AACjD,WAAO,SAAS,SAAS,WACtB,cAAc,KAAK,WAAW,UAAU,MAAM,IAAI,IAClD,cAAc,KAAK,WAAW,UAAU,MAAM,IAAI;AAAA,EACtD;AACD;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { l as DropthisClientOptions, k as DropsResource, A as AccountResource, b as ApiKeysResource, f as DeploymentsResource, I as InMemoryPublishInput, v as PublishOptions, n as DropthisResult, j as DropResponse, D as DeployOptions } from './drops-CWGyF-x1.cjs';
|
|
2
2
|
|
|
3
3
|
/** Workers-safe dropthis client. Pass an apiKey explicitly (no process.env on the edge). */
|
|
4
4
|
declare class DropthisEdge {
|
|
@@ -15,7 +15,7 @@ declare class DropthisEdge {
|
|
|
15
15
|
/** Publish a NEW drop from in-memory content. */
|
|
16
16
|
publish(input: InMemoryPublishInput, options?: PublishOptions): Promise<DropthisResult<DropResponse>>;
|
|
17
17
|
/** Publish a NEW content version to an existing drop, keeping its URL. */
|
|
18
|
-
deploy(dropId: string, input: InMemoryPublishInput, options?:
|
|
18
|
+
deploy(dropId: string, input: InMemoryPublishInput, options?: DeployOptions): Promise<DropthisResult<DropResponse>>;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export { DropthisEdge, InMemoryPublishInput };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { l as DropthisClientOptions, k as DropsResource, A as AccountResource, b as ApiKeysResource, f as DeploymentsResource, I as InMemoryPublishInput, v as PublishOptions, n as DropthisResult, j as DropResponse, D as DeployOptions } from './drops-CWGyF-x1.js';
|
|
2
2
|
|
|
3
3
|
/** Workers-safe dropthis client. Pass an apiKey explicitly (no process.env on the edge). */
|
|
4
4
|
declare class DropthisEdge {
|
|
@@ -15,7 +15,7 @@ declare class DropthisEdge {
|
|
|
15
15
|
/** Publish a NEW drop from in-memory content. */
|
|
16
16
|
publish(input: InMemoryPublishInput, options?: PublishOptions): Promise<DropthisResult<DropResponse>>;
|
|
17
17
|
/** Publish a NEW content version to an existing drop, keeping its URL. */
|
|
18
|
-
deploy(dropId: string, input: InMemoryPublishInput, options?:
|
|
18
|
+
deploy(dropId: string, input: InMemoryPublishInput, options?: DeployOptions): Promise<DropthisResult<DropResponse>>;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export { DropthisEdge, InMemoryPublishInput };
|
|
@@ -171,13 +171,28 @@ function validatePublishOptions(options) {
|
|
|
171
171
|
}
|
|
172
172
|
function optionsBody(options) {
|
|
173
173
|
validatePublishOptions(options);
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
174
|
+
const body = {};
|
|
175
|
+
if (options.title !== void 0) body.title = options.title;
|
|
176
|
+
if (options.visibility !== void 0) body.visibility = options.visibility;
|
|
177
|
+
if (options.password !== void 0) body.password = options.password;
|
|
178
|
+
if (options.noindex !== void 0) body.noindex = options.noindex;
|
|
179
|
+
if (options.expiresAt !== void 0) {
|
|
180
|
+
body.expiresAt = options.expiresAt instanceof Date ? options.expiresAt.toISOString() : options.expiresAt;
|
|
181
|
+
}
|
|
182
|
+
return body;
|
|
183
|
+
}
|
|
184
|
+
function deployOptions(options) {
|
|
185
|
+
const out = {};
|
|
186
|
+
if (options.entry !== void 0) out.entry = options.entry;
|
|
187
|
+
if (options.contentType !== void 0) out.contentType = options.contentType;
|
|
188
|
+
if (options.path !== void 0) out.path = options.path;
|
|
189
|
+
if (options.ignore !== void 0) out.ignore = options.ignore;
|
|
190
|
+
if (options.ignoreDefaults !== void 0)
|
|
191
|
+
out.ignoreDefaults = options.ignoreDefaults;
|
|
192
|
+
if (options.idempotencyKey !== void 0)
|
|
193
|
+
out.idempotencyKey = options.idempotencyKey;
|
|
194
|
+
if (options.ifRevision !== void 0) out.ifRevision = options.ifRevision;
|
|
195
|
+
return out;
|
|
181
196
|
}
|
|
182
197
|
function buildStagedRequest(files, options, entry) {
|
|
183
198
|
assertNonEmptyBundle(files.map((f) => f.path));
|
|
@@ -342,7 +357,7 @@ async function publishStaged(transport, prepared, finalPath, options = {}) {
|
|
|
342
357
|
const finalOptions = {
|
|
343
358
|
body: {
|
|
344
359
|
uploadId: createResult.data.uploadId,
|
|
345
|
-
options: prepared.options,
|
|
360
|
+
...Object.keys(prepared.options).length > 0 ? { options: prepared.options } : {},
|
|
346
361
|
...prepared.metadata ? { metadata: prepared.metadata } : {}
|
|
347
362
|
},
|
|
348
363
|
idempotencyKey: `${baseKey}:publish`
|
|
@@ -356,7 +371,7 @@ async function publishSource(transport, prepared, finalPath, options = {}) {
|
|
|
356
371
|
return transport.request("POST", finalPath, {
|
|
357
372
|
body: {
|
|
358
373
|
sourceUrl: prepared.sourceUrl,
|
|
359
|
-
options: prepared.options,
|
|
374
|
+
...Object.keys(prepared.options).length > 0 ? { options: prepared.options } : {},
|
|
360
375
|
...prepared.metadata ? { metadata: prepared.metadata } : {}
|
|
361
376
|
},
|
|
362
377
|
idempotencyKey: `${baseKey}:publish`,
|
|
@@ -554,7 +569,7 @@ function toSnakeCase(value) {
|
|
|
554
569
|
|
|
555
570
|
// src/transport.ts
|
|
556
571
|
var DEFAULT_BASE_URL = "https://api.dropthis.app";
|
|
557
|
-
var SDK_VERSION = "0.
|
|
572
|
+
var SDK_VERSION = "0.8.0";
|
|
558
573
|
var Transport = class {
|
|
559
574
|
apiKey;
|
|
560
575
|
baseUrl;
|
|
@@ -564,7 +579,12 @@ var Transport = class {
|
|
|
564
579
|
constructor(options = {}) {
|
|
565
580
|
const resolved = typeof options === "string" ? { apiKey: options } : options;
|
|
566
581
|
this.apiKey = resolved.apiKey ?? (typeof process !== "undefined" ? process.env?.DROPTHIS_API_KEY : void 0);
|
|
567
|
-
|
|
582
|
+
const base = new URL(resolved.baseUrl ?? DEFAULT_BASE_URL);
|
|
583
|
+
const basePath = base.pathname.replace(/\/+$/, "");
|
|
584
|
+
base.pathname = basePath.endsWith("/v1") ? basePath : `${basePath}/v1`;
|
|
585
|
+
base.search = "";
|
|
586
|
+
base.hash = "";
|
|
587
|
+
this.baseUrl = base.toString().replace(/\/+$/, "");
|
|
568
588
|
this.timeoutMs = resolved.timeoutMs ?? 3e4;
|
|
569
589
|
this.uploadTimeoutMs = resolved.uploadTimeoutMs ?? 12e4;
|
|
570
590
|
this.fetchImpl = resolved.fetch ?? globalThis.fetch;
|
|
@@ -762,14 +782,15 @@ var DropthisEdge = class {
|
|
|
762
782
|
}
|
|
763
783
|
/** Publish a NEW content version to an existing drop, keeping its URL. */
|
|
764
784
|
async deploy(dropId, input, options = {}) {
|
|
785
|
+
const opts = deployOptions(options);
|
|
765
786
|
let prepared;
|
|
766
787
|
try {
|
|
767
|
-
prepared = await resolveInMemory(input,
|
|
788
|
+
prepared = await resolveInMemory(input, opts);
|
|
768
789
|
} catch (e) {
|
|
769
790
|
return toErrorResult(e);
|
|
770
791
|
}
|
|
771
792
|
const path = `/drops/${encodeURIComponent(dropId)}/deployments`;
|
|
772
|
-
return prepared.kind === "source" ? publishSource(this.transport, prepared, path,
|
|
793
|
+
return prepared.kind === "source" ? publishSource(this.transport, prepared, path, opts) : publishStaged(this.transport, prepared, path, opts);
|
|
773
794
|
}
|
|
774
795
|
};
|
|
775
796
|
export {
|