@dropthis/cli 0.17.0 → 0.19.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.
@@ -78,11 +78,14 @@ await dropthis.drops.updateSettings("drop_abc123", { title: "New title" });
78
78
 
79
79
  ### Resolve a URL back to its drop
80
80
 
81
- Lost the `drop_…` id? Resolve the drop's URL (or bare slug) back to the drop. The slug is
82
- parsed client-side from the first hostname label of a dropthis hostname
83
- (`<slug>.dropthis.app`, or `<slug>.` + your configured `baseUrl` host), then matched against
84
- your own drops via `GET /drops?slug=`. Custom-domain URLs are not resolvable yet — they are
85
- rejected client-side with an `invalid_drop_url` error, without hitting the API.
81
+ Lost the `drop_…` id? Resolve any public locator a drop URL, a custom-domain URL, or a bare
82
+ vanity/shared slug back to the drop. The target is sent to the server (`POST /drops/resolve`),
83
+ which owner-scopes and decomposes it; you get the full drop back, or `null` when nothing of yours
84
+ matches. Passing a `drop_…` id round-trips to an owner-scoped lookup.
85
+
86
+ > Persist the drop_… id. URLs, raw_url, and slugs are locators, not identifiers — a vanity slug is
87
+ > renameable and the pool host rotates, so a stored URL can drift; the id never moves. Treat
88
+ > drop_… as an opaque case-sensitive string.
86
89
 
87
90
  ```typescript
88
91
  const { data } = await dropthis.drops.resolve("https://my-report.dropthis.app/");
@@ -280,7 +283,8 @@ const dropthis = new Dropthis("sk_...");
280
283
  await dropthis.drops.list({ limit: 20 });
281
284
  await dropthis.drops.list({ domain: "reports.example.com" }); // only drops mounted on a custom domain
282
285
  await dropthis.drops.get("drop_abc123");
283
- await dropthis.drops.resolve("https://my-report.dropthis.app/"); // URL/slug → drop (or null)
286
+ await dropthis.drops.resolve("https://my-report.dropthis.app/"); // any locator → drop (or null)
287
+ await dropthis.drops.resolve("drop_abc123"); // a bare id round-trips too
284
288
  await dropthis.drops.getContent("drop_abc123"); // manifest of served files
285
289
  await dropthis.drops.getContent("drop_abc123", { path: "index.html" }); // one file's bytes
286
290
  await dropthis.drops.updateSettings("drop_abc123", { title: "Updated" });
@@ -628,14 +628,7 @@ declare class CursorPage<T> implements ListPage<T> {
628
628
  declare class DropsResource<TInput = PublishInput> {
629
629
  private readonly transport;
630
630
  private readonly resolveInput;
631
- private parentHosts?;
632
631
  constructor(transport: Transport, resolveInput: PublishInputResolver<TInput>);
633
- /**
634
- * Hostnames the SDK can attribute to dropthis for slug parsing: the canonical
635
- * viewer domain plus the configured baseUrl's host (covers staging/self-hosted
636
- * setups where drops are served under the API's own domain).
637
- */
638
- private allowedParentHosts;
639
632
  /**
640
633
  * Publish content to a NEW permanent public URL; returns the created drop (with its `drop_…` id).
641
634
  * Use to publish / share / post / put online / make public a report, dashboard, site, or file.
@@ -670,15 +663,17 @@ declare class DropsResource<TInput = PublishInput> {
670
663
  /** Fetch one drop by its `drop_…` id (not the slug/URL). GET /drops/{id}. */
671
664
  get(dropId: string): Promise<DropthisResult<DropResponse>>;
672
665
  /**
673
- * Resolve a drop URL (or bare slug) back to the drop the way to recover a lost
674
- * `drop_…` id. The slug is parsed client-side from the first hostname label of a
675
- * dropthis-attributable hostname (`https://<slug>.dropthis.app/…`, or `<slug>.` +
676
- * the configured baseUrl's host), then matched owner-scoped via GET /drops?slug=.
677
- * Returns the drop, or `data: null` when no drop of yours has that slug.
678
- * Custom-domain URLs are rejected client-side with `invalid_drop_url` — they are
679
- * not resolvable yet.
666
+ * Resolve a public locator (a drop URL, a custom-domain URL, or a bare vanity/shared
667
+ * slug) back to the drop the way to recover a lost `drop_…` id. Sends the raw target
668
+ * to the server (POST /drops/resolve), which owner-scopes and decomposes it. Returns the
669
+ * full drop, or `data: null` when nothing of yours matches. A `drop_…` id passed as the
670
+ * target round-trips to an owner-scoped id lookup (null instead of 404).
671
+ *
672
+ * Persist the drop_… id. URLs, raw_url, and slugs are locators, not identifiers — a vanity
673
+ * slug is renameable and the pool host rotates, so a stored URL can drift; the id never
674
+ * moves. Treat drop_… as an opaque case-sensitive string.
680
675
  */
681
- resolve(urlOrSlug: string): Promise<DropthisResult<DropResponse | null>>;
676
+ resolve(target: string): Promise<DropthisResult<DropResponse | null>>;
682
677
  /**
683
678
  * Read back what a drop is serving (owner-only; works regardless of any viewer
684
679
  * password). By default returns the JSON manifest of the CURRENT deployment's files;
@@ -628,14 +628,7 @@ declare class CursorPage<T> implements ListPage<T> {
628
628
  declare class DropsResource<TInput = PublishInput> {
629
629
  private readonly transport;
630
630
  private readonly resolveInput;
631
- private parentHosts?;
632
631
  constructor(transport: Transport, resolveInput: PublishInputResolver<TInput>);
633
- /**
634
- * Hostnames the SDK can attribute to dropthis for slug parsing: the canonical
635
- * viewer domain plus the configured baseUrl's host (covers staging/self-hosted
636
- * setups where drops are served under the API's own domain).
637
- */
638
- private allowedParentHosts;
639
632
  /**
640
633
  * Publish content to a NEW permanent public URL; returns the created drop (with its `drop_…` id).
641
634
  * Use to publish / share / post / put online / make public a report, dashboard, site, or file.
@@ -670,15 +663,17 @@ declare class DropsResource<TInput = PublishInput> {
670
663
  /** Fetch one drop by its `drop_…` id (not the slug/URL). GET /drops/{id}. */
671
664
  get(dropId: string): Promise<DropthisResult<DropResponse>>;
672
665
  /**
673
- * Resolve a drop URL (or bare slug) back to the drop the way to recover a lost
674
- * `drop_…` id. The slug is parsed client-side from the first hostname label of a
675
- * dropthis-attributable hostname (`https://<slug>.dropthis.app/…`, or `<slug>.` +
676
- * the configured baseUrl's host), then matched owner-scoped via GET /drops?slug=.
677
- * Returns the drop, or `data: null` when no drop of yours has that slug.
678
- * Custom-domain URLs are rejected client-side with `invalid_drop_url` — they are
679
- * not resolvable yet.
666
+ * Resolve a public locator (a drop URL, a custom-domain URL, or a bare vanity/shared
667
+ * slug) back to the drop the way to recover a lost `drop_…` id. Sends the raw target
668
+ * to the server (POST /drops/resolve), which owner-scopes and decomposes it. Returns the
669
+ * full drop, or `data: null` when nothing of yours matches. A `drop_…` id passed as the
670
+ * target round-trips to an owner-scoped id lookup (null instead of 404).
671
+ *
672
+ * Persist the drop_… id. URLs, raw_url, and slugs are locators, not identifiers — a vanity
673
+ * slug is renameable and the pool host rotates, so a stored URL can drift; the id never
674
+ * moves. Treat drop_… as an opaque case-sensitive string.
680
675
  */
681
- resolve(urlOrSlug: string): Promise<DropthisResult<DropResponse | null>>;
676
+ resolve(target: string): Promise<DropthisResult<DropResponse | null>>;
682
677
  /**
683
678
  * Read back what a drop is serving (owner-only; works regardless of any viewer
684
679
  * password). By default returns the JSON manifest of the CURRENT deployment's files;
@@ -604,23 +604,6 @@ var DropsResource = class {
604
604
  }
605
605
  transport;
606
606
  resolveInput;
607
- parentHosts;
608
- /**
609
- * Hostnames the SDK can attribute to dropthis for slug parsing: the canonical
610
- * viewer domain plus the configured baseUrl's host (covers staging/self-hosted
611
- * setups where drops are served under the API's own domain).
612
- */
613
- allowedParentHosts() {
614
- if (!this.parentHosts) {
615
- const hosts = /* @__PURE__ */ new Set([CANONICAL_VIEWER_HOST]);
616
- try {
617
- hosts.add(new URL(this.transport.baseUrl).hostname.replace(/\.$/, ""));
618
- } catch {
619
- }
620
- this.parentHosts = hosts;
621
- }
622
- return this.parentHosts;
623
- }
624
607
  /**
625
608
  * Publish content to a NEW permanent public URL; returns the created drop (with its `drop_…` id).
626
609
  * Use to publish / share / post / put online / make public a report, dashboard, site, or file.
@@ -690,31 +673,25 @@ var DropsResource = class {
690
673
  );
691
674
  }
692
675
  /**
693
- * Resolve a drop URL (or bare slug) back to the drop the way to recover a lost
694
- * `drop_…` id. The slug is parsed client-side from the first hostname label of a
695
- * dropthis-attributable hostname (`https://<slug>.dropthis.app/…`, or `<slug>.` +
696
- * the configured baseUrl's host), then matched owner-scoped via GET /drops?slug=.
697
- * Returns the drop, or `data: null` when no drop of yours has that slug.
698
- * Custom-domain URLs are rejected client-side with `invalid_drop_url` — they are
699
- * not resolvable yet.
676
+ * Resolve a public locator (a drop URL, a custom-domain URL, or a bare vanity/shared
677
+ * slug) back to the drop the way to recover a lost `drop_…` id. Sends the raw target
678
+ * to the server (POST /drops/resolve), which owner-scopes and decomposes it. Returns the
679
+ * full drop, or `data: null` when nothing of yours matches. A `drop_…` id passed as the
680
+ * target round-trips to an owner-scoped id lookup (null instead of 404).
681
+ *
682
+ * Persist the drop_… id. URLs, raw_url, and slugs are locators, not identifiers — a vanity
683
+ * slug is renameable and the pool host rotates, so a stored URL can drift; the id never
684
+ * moves. Treat drop_… as an opaque case-sensitive string.
700
685
  */
701
- async resolve(urlOrSlug) {
702
- const slug = parseSlug(urlOrSlug, this.allowedParentHosts());
703
- if (slug === null) {
704
- return createErrorResult(
705
- "invalid_drop_url",
706
- `Could not resolve a drop slug from "${urlOrSlug}". Pass a canonical drop URL like https://<slug>.dropthis.app/ or the bare slug \u2014 custom-domain URLs cannot be resolved yet.`,
707
- null
708
- );
709
- }
710
- const result = await this.transport.request("GET", "/drops", { params: { slug } });
686
+ async resolve(target) {
687
+ const result = await this.transport.request(
688
+ "POST",
689
+ "/drops/resolve",
690
+ { body: { target } }
691
+ );
711
692
  if (result.error)
712
693
  return { data: null, error: result.error, headers: result.headers };
713
- return {
714
- data: result.data.drops[0] ?? null,
715
- error: null,
716
- headers: result.headers
717
- };
694
+ return { data: result.data.data, error: null, headers: result.headers };
718
695
  }
719
696
  async getContent(dropId, options = {}) {
720
697
  const base = options.deploymentId !== void 0 ? `/drops/${encodeURIComponent(dropId)}/deployments/${encodeURIComponent(options.deploymentId)}/content` : `/drops/${encodeURIComponent(dropId)}/content`;
@@ -773,25 +750,6 @@ var DropsResource = class {
773
750
  );
774
751
  }
775
752
  };
776
- var CANONICAL_VIEWER_HOST = "dropthis.app";
777
- function parseSlug(input, allowedParents) {
778
- const value = input.trim();
779
- if (!value) return null;
780
- if (!/[./]/.test(value)) return value;
781
- const withScheme = /^[a-z][a-z0-9+.-]*:\/\//i.test(value) ? value : `https://${value}`;
782
- let hostname;
783
- try {
784
- hostname = new URL(withScheme).hostname;
785
- } catch {
786
- return null;
787
- }
788
- hostname = hostname.replace(/\.$/, "");
789
- const dot = hostname.indexOf(".");
790
- if (dot <= 0) return null;
791
- const slug = hostname.slice(0, dot);
792
- const parent = hostname.slice(dot + 1);
793
- return allowedParents.has(parent) ? slug : null;
794
- }
795
753
  var SETTINGS = [
796
754
  "title",
797
755
  "visibility",
@@ -846,7 +804,7 @@ function toSnakeCase(value) {
846
804
 
847
805
  // src/transport.ts
848
806
  var DEFAULT_BASE_URL = "https://api.dropthis.app";
849
- var SDK_VERSION = "0.16.0";
807
+ var SDK_VERSION = "0.17.0";
850
808
  var Transport = class {
851
809
  apiKey;
852
810
  baseUrl;