@nitida/sdk 0.29.0 → 0.30.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/src/index.ts CHANGED
@@ -1109,6 +1109,32 @@ export type UploadResult = {
1109
1109
  * message about the wrong one.
1110
1110
  */
1111
1111
  sha: string;
1112
+ /**
1113
+ * The MIME the upload was stored under.
1114
+ *
1115
+ * ⭐ It exists because it did not, and that cost the THIRD 404 of this exact
1116
+ * family. Found 2026-08-23 by an agent running the getting-started doc
1117
+ * verbatim: `getAssetUrl(up, "original")` built `<sha>-o.bin` and 404'd,
1118
+ * while the object served fine at `-o.jpg`.
1119
+ *
1120
+ * `original` is the one preset whose extension is not fixed — it is the
1121
+ * bytes you uploaded, so the extension comes from the MIME (`ORIGINAL_EXT_BY_MIME`),
1122
+ * and `PRESET_EXT.original` is only the `"bin"` fallback for when nothing
1123
+ * says otherwise. `UploadResult` said nothing, so every caller handing an
1124
+ * upload result straight to a URL builder got the fallback.
1125
+ *
1126
+ * The pattern is now three for three — `sha256` vs `sha`, and this:
1127
+ * **a result type that omits what the next call needs turns the obvious
1128
+ * call into a silent 404.** The fix is never a better error message.
1129
+ */
1130
+ mime: string;
1131
+ /**
1132
+ * The extension the server actually stored the original under, when it said
1133
+ * so. Authoritative — it beats any client-side MIME table, because the
1134
+ * server keys the object off the uploaded filename for the cases no table
1135
+ * can close (`.mpga`, `.docx`, `.m4a` all arrive as octet-stream).
1136
+ */
1137
+ oext?: string | null;
1112
1138
  cdnUrl: string;
1113
1139
  };
1114
1140
 
@@ -1656,6 +1682,8 @@ export class NitidaClient {
1656
1682
  assetId: existing.id,
1657
1683
  sha256: sha,
1658
1684
  sha: sha.slice(0, 16),
1685
+ mime: existing.mime ?? mime,
1686
+ oext: existing.oext ?? null,
1659
1687
  cdnUrl: this.urlFor(existing, this.bestPresetForAsset(existing, mime)),
1660
1688
  };
1661
1689
  }
@@ -1682,6 +1710,8 @@ export class NitidaClient {
1682
1710
  assetId: presign.asset.id,
1683
1711
  sha256: sha,
1684
1712
  sha: sha.slice(0, 16),
1713
+ mime: presign.asset.mime ?? mime,
1714
+ oext: presign.asset.oext ?? null,
1685
1715
  cdnUrl: this.urlFor(presign.asset, this.defaultPresetForMime(mime)),
1686
1716
  };
1687
1717
  }
@@ -1733,6 +1763,8 @@ export class NitidaClient {
1733
1763
  assetId,
1734
1764
  sha256: sha,
1735
1765
  sha: sha.slice(0, 16),
1766
+ mime: final.mime ?? mime,
1767
+ oext: final.oext ?? null,
1736
1768
  cdnUrl: this.urlFor(final, this.bestPresetForAsset(final, mime)),
1737
1769
  };
1738
1770
  }