@dropthis/cli 0.20.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,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-C92Gkuqx.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-C92Gkuqx.js';
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-DNwOp7g_.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-DNwOp7g_.js';
3
3
 
4
4
  declare class AuthResource {
5
5
  private readonly transport;
@@ -218,18 +218,34 @@ function updateContentOptions(options) {
218
218
  if (options.idempotencyKey !== void 0)
219
219
  out.idempotencyKey = options.idempotencyKey;
220
220
  if (options.ifRevision !== void 0) out.ifRevision = options.ifRevision;
221
+ if (options.mode !== void 0) out.mode = options.mode;
222
+ if (options.deletePaths !== void 0) out.deletePaths = options.deletePaths;
221
223
  return out;
222
224
  }
223
225
  function buildStagedRequest(files, options, entry) {
224
226
  assertNonEmptyBundle(files.map((f) => f.path));
225
227
  const normalizedPaths = files.map((f) => normalizeManifestPath(f.path));
226
228
  assertNoDuplicatePaths(normalizedPaths);
227
- const manifestFiles = files.map((file) => ({
228
- path: normalizeManifestPath(file.path),
229
- contentType: file.contentType,
230
- sizeBytes: file.sizeBytes,
231
- ...file.checksumSha256 ? { checksumSha256: file.checksumSha256 } : {}
232
- }));
229
+ const manifestFiles = files.map(
230
+ (file) => file.sourceUrl !== void 0 ? (
231
+ // Remote entry: the server fetches the bytes on /ingest. Emit sourceUrl
232
+ // plus optional metadata hints (contentType, sizeBytes, checksumSha256)
233
+ // when the caller declared them. The transport snake_cases all camelCase
234
+ // keys to source_url / content_type / size_bytes / checksum_sha256.
235
+ {
236
+ path: normalizeManifestPath(file.path),
237
+ sourceUrl: file.sourceUrl,
238
+ ...file.contentType ? { contentType: file.contentType } : {},
239
+ ...file.sizeBytes !== void 0 ? { sizeBytes: file.sizeBytes } : {},
240
+ ...file.checksumSha256 ? { checksumSha256: file.checksumSha256 } : {}
241
+ }
242
+ ) : {
243
+ path: normalizeManifestPath(file.path),
244
+ contentType: file.contentType,
245
+ sizeBytes: file.sizeBytes,
246
+ ...file.checksumSha256 ? { checksumSha256: file.checksumSha256 } : {}
247
+ }
248
+ );
233
249
  const resolvedEntry = entry ?? options.entry;
234
250
  if (resolvedEntry !== void 0) assertValidManifestPath(resolvedEntry);
235
251
  const manifest = {
@@ -275,9 +291,48 @@ function fileBytes(file) {
275
291
  "missing_file_bytes",
276
292
  `File "${file.path}" is missing content bytes.`,
277
293
  file.path,
278
- "Provide one of content, contentBase64, or bytes."
294
+ "Provide one of content, contentBase64, or bytes, or set sourceUrl."
279
295
  );
280
296
  }
297
+ function hasInlineBytes(file) {
298
+ return file.content !== void 0 || file.contentBase64 !== void 0 || file.bytes !== void 0;
299
+ }
300
+ function prepareBundleFile(file) {
301
+ assertValidManifestPath(file.path);
302
+ if (file.sourceUrl !== void 0) {
303
+ if (hasInlineBytes(file)) {
304
+ throw new PublishInputError(
305
+ "conflicting_file_source",
306
+ `File "${file.path}" sets both inline content and sourceUrl; pick one.`,
307
+ file.path,
308
+ "Drop sourceUrl to upload bytes, or drop content/contentBase64/bytes to fetch by reference."
309
+ );
310
+ }
311
+ if (!isHttpUrl(file.sourceUrl)) {
312
+ throw new PublishInputError(
313
+ "invalid_source_url",
314
+ `File "${file.path}" sourceUrl must be an http(s) URL.`,
315
+ file.path,
316
+ "Fetch the bytes first and pass them inline, or use an http(s) URL."
317
+ );
318
+ }
319
+ return {
320
+ path: file.path,
321
+ sourceUrl: file.sourceUrl,
322
+ ...file.contentType ? { contentType: file.contentType } : {},
323
+ ...file.sizeBytes !== void 0 ? { sizeBytes: file.sizeBytes } : {},
324
+ ...file.checksumSha256 ? { checksumSha256: file.checksumSha256 } : {}
325
+ };
326
+ }
327
+ const bytes = fileBytes(file);
328
+ const contentType = file.contentType ?? detectBytesContentType(bytes);
329
+ return {
330
+ path: file.path,
331
+ contentType,
332
+ sizeBytes: bytes.byteLength,
333
+ getBody: async () => bytes
334
+ };
335
+ }
281
336
  function singleStagedFile(path, contentType, bytes, options) {
282
337
  return buildStagedRequest(
283
338
  [
@@ -320,20 +375,17 @@ async function resolveInMemory(input, options = {}) {
320
375
  if (input.kind === "source_url") {
321
376
  return buildSourceRequest(input.sourceUrl, options);
322
377
  }
323
- const files = input.files.map((file) => {
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
- });
378
+ const files = input.files.map(prepareBundleFile);
334
379
  return buildStagedRequest(files, options, input.entry);
335
380
  }
381
+ function partialUpdateBody(options) {
382
+ return {
383
+ ...options.mode !== void 0 ? { mode: options.mode } : {},
384
+ ...options.deletePaths !== void 0 ? { deletePaths: options.deletePaths } : {}
385
+ };
386
+ }
336
387
  var UPLOAD_CONCURRENCY = 5;
388
+ var INGEST_TIMEOUT_MS = 12e4;
337
389
  function errorResult(result) {
338
390
  if (!result.error) throw new Error("Expected an error result");
339
391
  return { data: null, error: result.error, headers: result.headers };
@@ -389,6 +441,7 @@ async function publishStaged(transport, prepared, finalPath, options = {}) {
389
441
  if (createResult.error) return errorResult(createResult);
390
442
  const jobs = [];
391
443
  for (const file of prepared.files) {
444
+ if (file.sourceUrl !== void 0) continue;
392
445
  const target = createResult.data.files.find((f) => f.path === file.path);
393
446
  if (!target) {
394
447
  return createErrorResult(
@@ -408,6 +461,18 @@ async function publishStaged(transport, prepared, finalPath, options = {}) {
408
461
  }
409
462
  const uploadFailure = await uploadStagedFiles(transport, jobs);
410
463
  if (uploadFailure) return uploadFailure;
464
+ const hasRemote = prepared.files.some((f) => f.sourceUrl !== void 0);
465
+ if (hasRemote) {
466
+ const ingestResult = await transport.request(
467
+ "POST",
468
+ `/uploads/${encodeURIComponent(createResult.data.uploadId)}/ingest`,
469
+ {
470
+ idempotencyKey: `${baseKey}:ingest-upload`,
471
+ timeoutMs: INGEST_TIMEOUT_MS
472
+ }
473
+ );
474
+ if (ingestResult.error) return errorResult(ingestResult);
475
+ }
411
476
  const completeResult = await transport.request(
412
477
  "POST",
413
478
  `/uploads/${encodeURIComponent(createResult.data.uploadId)}/complete`,
@@ -420,7 +485,8 @@ async function publishStaged(transport, prepared, finalPath, options = {}) {
420
485
  body: {
421
486
  uploadId: createResult.data.uploadId,
422
487
  ...Object.keys(prepared.options).length > 0 ? { options: prepared.options } : {},
423
- ...prepared.metadata ? { metadata: prepared.metadata } : {}
488
+ ...prepared.metadata ? { metadata: prepared.metadata } : {},
489
+ ...partialUpdateBody(options)
424
490
  },
425
491
  idempotencyKey: `${baseKey}:publish`
426
492
  };
@@ -434,7 +500,8 @@ async function publishSource(transport, prepared, finalPath, options = {}) {
434
500
  body: {
435
501
  sourceUrl: prepared.sourceUrl,
436
502
  ...Object.keys(prepared.options).length > 0 ? { options: prepared.options } : {},
437
- ...prepared.metadata ? { metadata: prepared.metadata } : {}
503
+ ...prepared.metadata ? { metadata: prepared.metadata } : {},
504
+ ...partialUpdateBody(options)
438
505
  },
439
506
  idempotencyKey: `${baseKey}:publish`,
440
507
  ...options.ifRevision !== void 0 ? { ifRevision: options.ifRevision } : {}
@@ -1018,7 +1085,7 @@ function toSnakeCase(value) {
1018
1085
 
1019
1086
  // src/transport.ts
1020
1087
  var DEFAULT_BASE_URL = "https://api.dropthis.app";
1021
- var SDK_VERSION = "0.18.0";
1088
+ var SDK_VERSION = "0.20.0";
1022
1089
  var Transport = class {
1023
1090
  apiKey;
1024
1091
  baseUrl;