@dropthis/cli 0.20.0 → 0.21.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/README.md +55 -0
- package/dist/cli.cjs +172 -49
- package/dist/cli.cjs.map +1 -1
- package/node_modules/@dropthis/node/README.md +20 -2
- package/node_modules/@dropthis/node/dist/{drops-C92Gkuqx.d.cts → drops-CSahv_jA.d.cts} +70 -4
- package/node_modules/@dropthis/node/dist/{drops-C92Gkuqx.d.ts → drops-CSahv_jA.d.ts} +70 -4
- package/node_modules/@dropthis/node/dist/edge.cjs +76 -19
- package/node_modules/@dropthis/node/dist/edge.cjs.map +1 -1
- package/node_modules/@dropthis/node/dist/edge.d.cts +1 -1
- package/node_modules/@dropthis/node/dist/edge.d.ts +1 -1
- package/node_modules/@dropthis/node/dist/edge.mjs +76 -19
- package/node_modules/@dropthis/node/dist/edge.mjs.map +1 -1
- package/node_modules/@dropthis/node/dist/index.cjs +76 -19
- package/node_modules/@dropthis/node/dist/index.cjs.map +1 -1
- package/node_modules/@dropthis/node/dist/index.d.cts +2 -2
- package/node_modules/@dropthis/node/dist/index.d.ts +2 -2
- package/node_modules/@dropthis/node/dist/index.mjs +76 -19
- package/node_modules/@dropthis/node/dist/index.mjs.map +1 -1
- package/node_modules/@dropthis/node/package.json +1 -1
- package/package.json +49 -49
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { O as Transport, v as DropthisResult, E as EmailOtpResponse, M as SessionResponse, C as CreateUploadSessionRequest, e as CreateUploadSessionResponse, W as UploadSessionResponse, t as DropthisClientOptions, d as ApiKeysResource, a as AccountResource, s as DropsResource, H as PublishInput, h as DeploymentsResource, m as DomainsResource, J as PublishOptions, z as PreparedPublishRequest } from './drops-
|
|
2
|
-
export { A as AccountLimits, b as AccountResponse, c as ActionResolve, f as CursorPage, D as DeploymentContentFile, g as DeploymentContentManifest, i as DnsRecord, j as DomainDeletedResponse, k as DomainListResponse, l as DomainResponse, n as DropAction, o as DropContentFile, p as DropDeploymentResponse, q as DropOptions, r as DropResponse, u as DropthisErrorResponse, G as GetContentOptions, I as InMemoryPublishInput, L as Limitations, w as ListDeploymentsParams, x as ListDeploymentsResponse, y as ListPage, N as NextHint, P as PrepareOptions, B as PreparedUploadFile, F as PublishFileInput, R as RequestControls, K as RequestOptions, S as SHARED_POOL, T as TierInfo, U as UpdateContentOptions, Q as UploadManifestFile, V as UploadSessionFileResponse, X as UploadTarget } from './drops-
|
|
1
|
+
import { O as Transport, v as DropthisResult, E as EmailOtpResponse, M as SessionResponse, C as CreateUploadSessionRequest, e as CreateUploadSessionResponse, W as UploadSessionResponse, t as DropthisClientOptions, d as ApiKeysResource, a as AccountResource, s as DropsResource, H as PublishInput, h as DeploymentsResource, m as DomainsResource, J as PublishOptions, z as PreparedPublishRequest } from './drops-CSahv_jA.js';
|
|
2
|
+
export { A as AccountLimits, b as AccountResponse, c as ActionResolve, f as CursorPage, D as DeploymentContentFile, g as DeploymentContentManifest, i as DnsRecord, j as DomainDeletedResponse, k as DomainListResponse, l as DomainResponse, n as DropAction, o as DropContentFile, p as DropDeploymentResponse, q as DropOptions, r as DropResponse, u as DropthisErrorResponse, G as GetContentOptions, I as InMemoryPublishInput, L as Limitations, w as ListDeploymentsParams, x as ListDeploymentsResponse, y as ListPage, N as NextHint, P as PrepareOptions, B as PreparedUploadFile, F as PublishFileInput, R as RequestControls, K as RequestOptions, S as SHARED_POOL, T as TierInfo, U as UpdateContentOptions, Q as UploadManifestFile, V as UploadSessionFileResponse, X as UploadTarget } from './drops-CSahv_jA.js';
|
|
3
3
|
|
|
4
4
|
declare class AuthResource {
|
|
5
5
|
private readonly transport;
|
|
@@ -224,12 +224,26 @@ function buildStagedRequest(files, options, entry) {
|
|
|
224
224
|
assertNonEmptyBundle(files.map((f) => f.path));
|
|
225
225
|
const normalizedPaths = files.map((f) => normalizeManifestPath(f.path));
|
|
226
226
|
assertNoDuplicatePaths(normalizedPaths);
|
|
227
|
-
const manifestFiles = files.map(
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
227
|
+
const manifestFiles = files.map(
|
|
228
|
+
(file) => file.sourceUrl !== void 0 ? (
|
|
229
|
+
// Remote entry: the server fetches the bytes on /ingest. Emit sourceUrl
|
|
230
|
+
// plus optional metadata hints (contentType, sizeBytes, checksumSha256)
|
|
231
|
+
// when the caller declared them. The transport snake_cases all camelCase
|
|
232
|
+
// keys to source_url / content_type / size_bytes / checksum_sha256.
|
|
233
|
+
{
|
|
234
|
+
path: normalizeManifestPath(file.path),
|
|
235
|
+
sourceUrl: file.sourceUrl,
|
|
236
|
+
...file.contentType ? { contentType: file.contentType } : {},
|
|
237
|
+
...file.sizeBytes !== void 0 ? { sizeBytes: file.sizeBytes } : {},
|
|
238
|
+
...file.checksumSha256 ? { checksumSha256: file.checksumSha256 } : {}
|
|
239
|
+
}
|
|
240
|
+
) : {
|
|
241
|
+
path: normalizeManifestPath(file.path),
|
|
242
|
+
contentType: file.contentType,
|
|
243
|
+
sizeBytes: file.sizeBytes,
|
|
244
|
+
...file.checksumSha256 ? { checksumSha256: file.checksumSha256 } : {}
|
|
245
|
+
}
|
|
246
|
+
);
|
|
233
247
|
const resolvedEntry = entry ?? options.entry;
|
|
234
248
|
if (resolvedEntry !== void 0) assertValidManifestPath(resolvedEntry);
|
|
235
249
|
const manifest = {
|
|
@@ -275,9 +289,48 @@ function fileBytes(file) {
|
|
|
275
289
|
"missing_file_bytes",
|
|
276
290
|
`File "${file.path}" is missing content bytes.`,
|
|
277
291
|
file.path,
|
|
278
|
-
"Provide one of content, contentBase64, or bytes."
|
|
292
|
+
"Provide one of content, contentBase64, or bytes, or set sourceUrl."
|
|
279
293
|
);
|
|
280
294
|
}
|
|
295
|
+
function hasInlineBytes(file) {
|
|
296
|
+
return file.content !== void 0 || file.contentBase64 !== void 0 || file.bytes !== void 0;
|
|
297
|
+
}
|
|
298
|
+
function prepareBundleFile(file) {
|
|
299
|
+
assertValidManifestPath(file.path);
|
|
300
|
+
if (file.sourceUrl !== void 0) {
|
|
301
|
+
if (hasInlineBytes(file)) {
|
|
302
|
+
throw new PublishInputError(
|
|
303
|
+
"conflicting_file_source",
|
|
304
|
+
`File "${file.path}" sets both inline content and sourceUrl; pick one.`,
|
|
305
|
+
file.path,
|
|
306
|
+
"Drop sourceUrl to upload bytes, or drop content/contentBase64/bytes to fetch by reference."
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
if (!isHttpUrl(file.sourceUrl)) {
|
|
310
|
+
throw new PublishInputError(
|
|
311
|
+
"invalid_source_url",
|
|
312
|
+
`File "${file.path}" sourceUrl must be an http(s) URL.`,
|
|
313
|
+
file.path,
|
|
314
|
+
"Fetch the bytes first and pass them inline, or use an http(s) URL."
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
return {
|
|
318
|
+
path: file.path,
|
|
319
|
+
sourceUrl: file.sourceUrl,
|
|
320
|
+
...file.contentType ? { contentType: file.contentType } : {},
|
|
321
|
+
...file.sizeBytes !== void 0 ? { sizeBytes: file.sizeBytes } : {},
|
|
322
|
+
...file.checksumSha256 ? { checksumSha256: file.checksumSha256 } : {}
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
const bytes = fileBytes(file);
|
|
326
|
+
const contentType = file.contentType ?? detectBytesContentType(bytes);
|
|
327
|
+
return {
|
|
328
|
+
path: file.path,
|
|
329
|
+
contentType,
|
|
330
|
+
sizeBytes: bytes.byteLength,
|
|
331
|
+
getBody: async () => bytes
|
|
332
|
+
};
|
|
333
|
+
}
|
|
281
334
|
function singleStagedFile(path, contentType, bytes, options) {
|
|
282
335
|
return buildStagedRequest(
|
|
283
336
|
[
|
|
@@ -320,20 +373,11 @@ async function resolveInMemory(input, options = {}) {
|
|
|
320
373
|
if (input.kind === "source_url") {
|
|
321
374
|
return buildSourceRequest(input.sourceUrl, options);
|
|
322
375
|
}
|
|
323
|
-
const files = input.files.map(
|
|
324
|
-
assertValidManifestPath(file.path);
|
|
325
|
-
const bytes = fileBytes(file);
|
|
326
|
-
const contentType = file.contentType ?? detectBytesContentType(bytes);
|
|
327
|
-
return {
|
|
328
|
-
path: file.path,
|
|
329
|
-
contentType,
|
|
330
|
-
sizeBytes: bytes.byteLength,
|
|
331
|
-
getBody: async () => bytes
|
|
332
|
-
};
|
|
333
|
-
});
|
|
376
|
+
const files = input.files.map(prepareBundleFile);
|
|
334
377
|
return buildStagedRequest(files, options, input.entry);
|
|
335
378
|
}
|
|
336
379
|
var UPLOAD_CONCURRENCY = 5;
|
|
380
|
+
var INGEST_TIMEOUT_MS = 12e4;
|
|
337
381
|
function errorResult(result) {
|
|
338
382
|
if (!result.error) throw new Error("Expected an error result");
|
|
339
383
|
return { data: null, error: result.error, headers: result.headers };
|
|
@@ -389,6 +433,7 @@ async function publishStaged(transport, prepared, finalPath, options = {}) {
|
|
|
389
433
|
if (createResult.error) return errorResult(createResult);
|
|
390
434
|
const jobs = [];
|
|
391
435
|
for (const file of prepared.files) {
|
|
436
|
+
if (file.sourceUrl !== void 0) continue;
|
|
392
437
|
const target = createResult.data.files.find((f) => f.path === file.path);
|
|
393
438
|
if (!target) {
|
|
394
439
|
return createErrorResult(
|
|
@@ -408,6 +453,18 @@ async function publishStaged(transport, prepared, finalPath, options = {}) {
|
|
|
408
453
|
}
|
|
409
454
|
const uploadFailure = await uploadStagedFiles(transport, jobs);
|
|
410
455
|
if (uploadFailure) return uploadFailure;
|
|
456
|
+
const hasRemote = prepared.files.some((f) => f.sourceUrl !== void 0);
|
|
457
|
+
if (hasRemote) {
|
|
458
|
+
const ingestResult = await transport.request(
|
|
459
|
+
"POST",
|
|
460
|
+
`/uploads/${encodeURIComponent(createResult.data.uploadId)}/ingest`,
|
|
461
|
+
{
|
|
462
|
+
idempotencyKey: `${baseKey}:ingest-upload`,
|
|
463
|
+
timeoutMs: INGEST_TIMEOUT_MS
|
|
464
|
+
}
|
|
465
|
+
);
|
|
466
|
+
if (ingestResult.error) return errorResult(ingestResult);
|
|
467
|
+
}
|
|
411
468
|
const completeResult = await transport.request(
|
|
412
469
|
"POST",
|
|
413
470
|
`/uploads/${encodeURIComponent(createResult.data.uploadId)}/complete`,
|
|
@@ -1018,7 +1075,7 @@ function toSnakeCase(value) {
|
|
|
1018
1075
|
|
|
1019
1076
|
// src/transport.ts
|
|
1020
1077
|
var DEFAULT_BASE_URL = "https://api.dropthis.app";
|
|
1021
|
-
var SDK_VERSION = "0.
|
|
1078
|
+
var SDK_VERSION = "0.19.0";
|
|
1022
1079
|
var Transport = class {
|
|
1023
1080
|
apiKey;
|
|
1024
1081
|
baseUrl;
|