@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.
@@ -778,23 +778,6 @@ var DropsResource = class {
778
778
  }
779
779
  transport;
780
780
  resolveInput;
781
- parentHosts;
782
- /**
783
- * Hostnames the SDK can attribute to dropthis for slug parsing: the canonical
784
- * viewer domain plus the configured baseUrl's host (covers staging/self-hosted
785
- * setups where drops are served under the API's own domain).
786
- */
787
- allowedParentHosts() {
788
- if (!this.parentHosts) {
789
- const hosts = /* @__PURE__ */ new Set([CANONICAL_VIEWER_HOST]);
790
- try {
791
- hosts.add(new URL(this.transport.baseUrl).hostname.replace(/\.$/, ""));
792
- } catch {
793
- }
794
- this.parentHosts = hosts;
795
- }
796
- return this.parentHosts;
797
- }
798
781
  /**
799
782
  * Publish content to a NEW permanent public URL; returns the created drop (with its `drop_…` id).
800
783
  * Use to publish / share / post / put online / make public a report, dashboard, site, or file.
@@ -864,31 +847,25 @@ var DropsResource = class {
864
847
  );
865
848
  }
866
849
  /**
867
- * Resolve a drop URL (or bare slug) back to the drop the way to recover a lost
868
- * `drop_…` id. The slug is parsed client-side from the first hostname label of a
869
- * dropthis-attributable hostname (`https://<slug>.dropthis.app/…`, or `<slug>.` +
870
- * the configured baseUrl's host), then matched owner-scoped via GET /drops?slug=.
871
- * Returns the drop, or `data: null` when no drop of yours has that slug.
872
- * Custom-domain URLs are rejected client-side with `invalid_drop_url` — they are
873
- * not resolvable yet.
850
+ * Resolve a public locator (a drop URL, a custom-domain URL, or a bare vanity/shared
851
+ * slug) back to the drop the way to recover a lost `drop_…` id. Sends the raw target
852
+ * to the server (POST /drops/resolve), which owner-scopes and decomposes it. Returns the
853
+ * full drop, or `data: null` when nothing of yours matches. A `drop_…` id passed as the
854
+ * target round-trips to an owner-scoped id lookup (null instead of 404).
855
+ *
856
+ * Persist the drop_… id. URLs, raw_url, and slugs are locators, not identifiers — a vanity
857
+ * slug is renameable and the pool host rotates, so a stored URL can drift; the id never
858
+ * moves. Treat drop_… as an opaque case-sensitive string.
874
859
  */
875
- async resolve(urlOrSlug) {
876
- const slug = parseSlug(urlOrSlug, this.allowedParentHosts());
877
- if (slug === null) {
878
- return createErrorResult(
879
- "invalid_drop_url",
880
- `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.`,
881
- null
882
- );
883
- }
884
- const result = await this.transport.request("GET", "/drops", { params: { slug } });
860
+ async resolve(target) {
861
+ const result = await this.transport.request(
862
+ "POST",
863
+ "/drops/resolve",
864
+ { body: { target } }
865
+ );
885
866
  if (result.error)
886
867
  return { data: null, error: result.error, headers: result.headers };
887
- return {
888
- data: result.data.drops[0] ?? null,
889
- error: null,
890
- headers: result.headers
891
- };
868
+ return { data: result.data.data, error: null, headers: result.headers };
892
869
  }
893
870
  async getContent(dropId, options = {}) {
894
871
  const base = options.deploymentId !== void 0 ? `/drops/${encodeURIComponent(dropId)}/deployments/${encodeURIComponent(options.deploymentId)}/content` : `/drops/${encodeURIComponent(dropId)}/content`;
@@ -947,25 +924,6 @@ var DropsResource = class {
947
924
  );
948
925
  }
949
926
  };
950
- var CANONICAL_VIEWER_HOST = "dropthis.app";
951
- function parseSlug(input, allowedParents) {
952
- const value = input.trim();
953
- if (!value) return null;
954
- if (!/[./]/.test(value)) return value;
955
- const withScheme = /^[a-z][a-z0-9+.-]*:\/\//i.test(value) ? value : `https://${value}`;
956
- let hostname;
957
- try {
958
- hostname = new URL(withScheme).hostname;
959
- } catch {
960
- return null;
961
- }
962
- hostname = hostname.replace(/\.$/, "");
963
- const dot = hostname.indexOf(".");
964
- if (dot <= 0) return null;
965
- const slug = hostname.slice(0, dot);
966
- const parent = hostname.slice(dot + 1);
967
- return allowedParents.has(parent) ? slug : null;
968
- }
969
927
  var SETTINGS = [
970
928
  "title",
971
929
  "visibility",
@@ -1060,7 +1018,7 @@ function toSnakeCase(value) {
1060
1018
 
1061
1019
  // src/transport.ts
1062
1020
  var DEFAULT_BASE_URL = "https://api.dropthis.app";
1063
- var SDK_VERSION = "0.16.0";
1021
+ var SDK_VERSION = "0.17.0";
1064
1022
  var Transport = class {
1065
1023
  apiKey;
1066
1024
  baseUrl;