@nitida/sdk 0.27.0 → 0.27.1

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
@@ -227,6 +227,7 @@ export type {
227
227
  export {
228
228
  accessMessage,
229
229
  assertPublic,
230
+ assertSha,
230
231
  bestTextContrast,
231
232
  computeVariantDimensions,
232
233
  configureSlotResolver,
@@ -1018,6 +1019,22 @@ const DEFAULT_UPLOAD_PRESETS: RequestablePreset[] = ["original"];
1018
1019
  export type UploadResult = {
1019
1020
  assetId: string;
1020
1021
  sha256: string;
1022
+ /**
1023
+ * The SAME 16-hex prefix an `AssetDTO` carries, so the result of an upload can
1024
+ * be handed straight to any URL builder.
1025
+ *
1026
+ * ⭐ It exists because it did not, and that cost a real 404. A Haiku agent
1027
+ * evaluating the SDK on 2026-08-23 did the most natural thing there is —
1028
+ * `transform(await upload(file), { width: 1280 })` — and got
1029
+ * `https://8ok.uk/t/width=1280/undefined.webp`. The builders read `sha`; this
1030
+ * type only had `sha256`. TypeScript caught it; running through `bun`, or in
1031
+ * plain JS, nothing did.
1032
+ *
1033
+ * The guard (`assertSha`) is the backstop. This field is the actual fix: the
1034
+ * obvious call is now the correct one, which is worth more than a good error
1035
+ * message about the wrong one.
1036
+ */
1037
+ sha: string;
1021
1038
  cdnUrl: string;
1022
1039
  };
1023
1040
 
@@ -1563,6 +1580,7 @@ export class NitidaClient {
1563
1580
  return {
1564
1581
  assetId: existing.id,
1565
1582
  sha256: sha,
1583
+ sha: sha.slice(0, 16),
1566
1584
  cdnUrl: this.urlFor(existing, this.bestPresetForAsset(existing, mime)),
1567
1585
  };
1568
1586
  }
@@ -1588,6 +1606,7 @@ export class NitidaClient {
1588
1606
  return {
1589
1607
  assetId: presign.asset.id,
1590
1608
  sha256: sha,
1609
+ sha: sha.slice(0, 16),
1591
1610
  cdnUrl: this.urlFor(presign.asset, this.defaultPresetForMime(mime)),
1592
1611
  };
1593
1612
  }
@@ -1638,6 +1657,7 @@ export class NitidaClient {
1638
1657
  return {
1639
1658
  assetId,
1640
1659
  sha256: sha,
1660
+ sha: sha.slice(0, 16),
1641
1661
  cdnUrl: this.urlFor(final, this.bestPresetForAsset(final, mime)),
1642
1662
  };
1643
1663
  }
@@ -96,6 +96,7 @@ export {
96
96
  type AssetVariant,
97
97
  accessMessage,
98
98
  assertPublic,
99
+ assertSha,
99
100
  bestTextContrast,
100
101
  type ComposeMarketingComposition,
101
102
  type ComposeMarketingOptions,
package/src/web/index.ts CHANGED
@@ -113,6 +113,7 @@ export {
113
113
  type AssetVariant,
114
114
  accessMessage,
115
115
  assertPublic,
116
+ assertSha,
116
117
  bestTextContrast,
117
118
  type ComposeMarketingComposition,
118
119
  type ComposeMarketingOptions,