@nitida/asset-client 0.20.2 → 0.20.4

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/index.d.cts CHANGED
@@ -876,7 +876,20 @@ type OriginalHints = {
876
876
  * const url = hasPreset(asset, "thumb") ? getAssetUrl(asset, "thumb") : null;
877
877
  * ```
878
878
  */
879
- declare function getAssetUrl(asset: Pick<AssetDTO, "sha"> & OriginalHints & VisibilityHint, preset: VariantPreset): string;
879
+ declare function getAssetUrl(
880
+ /**
881
+ * ⭐ `presets` ESTÁ EN EL TIPO PORQUE LA FUNCIÓN LO LEE.
882
+ *
883
+ * `transformFallbackFor` decide con este campo si devolver la clave de
884
+ * variante o caer a `/t/…width=N/`. Sin él en la firma, el tipo PROHIBÍA el
885
+ * campo que la implementación consulta: pasarlo era un error de compilación,
886
+ * y no pasarlo daba `…-x.webp` → 404 en silencio.
887
+ *
888
+ * Medido 2026-08-25 sobre un asset con `presets: "lmoqs"`:
889
+ * sin `presets` → /f/v/<sha>-x.webp 404
890
+ * con `presets` → /t/format=webp,width=3840/<sha>.webp 200
891
+ */
892
+ asset: Pick<AssetDTO, "sha"> & OriginalHints & VisibilityHint & Partial<Pick<AssetDTO, "presets">>, preset: VariantPreset): string;
880
893
  /**
881
894
  * The signed URL for one preset of a PRIVATE asset — what every refusal above
882
895
  * points at.
@@ -946,7 +959,9 @@ declare function getPrivateTransformUrl(asset: Pick<AssetDTO, "sha">, opts: Sign
946
959
  * hasPreset({ presets: "pv" }, "aiproxy"); // → false — video without the AI proxy
947
960
  * ```
948
961
  */
949
- declare function hasPreset(asset: Pick<AssetDTO, "presets">, preset: VariantPreset): boolean;
962
+ declare function hasPreset(asset: {
963
+ presets?: string | null;
964
+ }, preset: VariantPreset): boolean;
950
965
  declare function getAssetSrcSet(asset: Pick<AssetDTO, "sha" | "presets"> & VisibilityHint): string;
951
966
  /**
952
967
  * Compute the dimensions a variant would have given the source asset's
package/dist/index.d.ts CHANGED
@@ -876,7 +876,20 @@ type OriginalHints = {
876
876
  * const url = hasPreset(asset, "thumb") ? getAssetUrl(asset, "thumb") : null;
877
877
  * ```
878
878
  */
879
- declare function getAssetUrl(asset: Pick<AssetDTO, "sha"> & OriginalHints & VisibilityHint, preset: VariantPreset): string;
879
+ declare function getAssetUrl(
880
+ /**
881
+ * ⭐ `presets` ESTÁ EN EL TIPO PORQUE LA FUNCIÓN LO LEE.
882
+ *
883
+ * `transformFallbackFor` decide con este campo si devolver la clave de
884
+ * variante o caer a `/t/…width=N/`. Sin él en la firma, el tipo PROHIBÍA el
885
+ * campo que la implementación consulta: pasarlo era un error de compilación,
886
+ * y no pasarlo daba `…-x.webp` → 404 en silencio.
887
+ *
888
+ * Medido 2026-08-25 sobre un asset con `presets: "lmoqs"`:
889
+ * sin `presets` → /f/v/<sha>-x.webp 404
890
+ * con `presets` → /t/format=webp,width=3840/<sha>.webp 200
891
+ */
892
+ asset: Pick<AssetDTO, "sha"> & OriginalHints & VisibilityHint & Partial<Pick<AssetDTO, "presets">>, preset: VariantPreset): string;
880
893
  /**
881
894
  * The signed URL for one preset of a PRIVATE asset — what every refusal above
882
895
  * points at.
@@ -946,7 +959,9 @@ declare function getPrivateTransformUrl(asset: Pick<AssetDTO, "sha">, opts: Sign
946
959
  * hasPreset({ presets: "pv" }, "aiproxy"); // → false — video without the AI proxy
947
960
  * ```
948
961
  */
949
- declare function hasPreset(asset: Pick<AssetDTO, "presets">, preset: VariantPreset): boolean;
962
+ declare function hasPreset(asset: {
963
+ presets?: string | null;
964
+ }, preset: VariantPreset): boolean;
950
965
  declare function getAssetSrcSet(asset: Pick<AssetDTO, "sha" | "presets"> & VisibilityHint): string;
951
966
  /**
952
967
  * Compute the dimensions a variant would have given the source asset's
package/dist/index.js CHANGED
@@ -643,11 +643,12 @@ async function getPrivateTransformUrl(asset, opts, signingKey, signOpts) {
643
643
  );
644
644
  }
645
645
  function hasPreset(asset, preset) {
646
- if (preset === "mp3") return asset.presets.includes("mp3");
647
- return stripMultiCharTokens(asset.presets).includes(PRESET_SHORT[preset]);
646
+ const presets = asset.presets ?? "";
647
+ if (preset === "mp3") return presets.includes("mp3");
648
+ return stripMultiCharTokens(presets).includes(PRESET_SHORT[preset]);
648
649
  }
649
650
  function stripMultiCharTokens(presets) {
650
- return presets.replace(/transform-[0-9a-f]*/g, "").replace(/upscale_[a-z0-9_]*/g, "").replace(/mp3/g, "").replace(/u[2-8]|t[1248ghij]/g, "").replace(/pr/g, "");
651
+ return (presets ?? "").replace(/transform-[0-9a-f]*/g, "").replace(/upscale_[a-z0-9_]*/g, "").replace(/mp3/g, "").replace(/u[2-8]|t[1248ghij]/g, "").replace(/pr/g, "");
651
652
  }
652
653
  var IMAGE_PRESETS = ["thumb", "sm", "md", "lg", "xl"];
653
654
  function getAssetSrcSet(asset) {