@nitida/sdk 0.30.2 → 0.31.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/README.md CHANGED
@@ -544,7 +544,7 @@ Two delivery paths, **by design**:
544
544
 
545
545
  | Kind | Builder | URL shape | Tenant in path? |
546
546
  |---|---|---|---|
547
- | Variant / preset | `urlFor`, `srcSetFor`, upload `cdnUrl` | `<cdn>/<tenantId b36>/v/<sha>-<preset>.<ext>` | **Yes** — `/4/v/<sha>-lg.webp` |
547
+ | Variant / preset | `urlFor`, `srcSetFor`, upload `cdnUrl` | `<cdn>/<tenantId b36>/v/<sha>-<preset>.<ext>` | **Yes** — `/4/v/<sha>-l.webp` |
548
548
  | On-the-fly transform | `transform`, `transformSrcSet` | `<cdn>/t/<dsl>/<sha>.<ext>` | **No** — `/t/width=1280,.../<sha>.webp` |
549
549
 
550
550
  The transform service is content-addressed by `sha` and resizes from the source on demand,
@@ -661,7 +661,13 @@ with `aq.assets.regenerate()` (no re-upload required).
661
661
  // Default: only the original variant lands on the CDN.
662
662
  const { assetId, cdnUrl } = await aq.upload(logoFile);
663
663
  // asset.presets === "o"
664
- // cdnUrl = https://8ok.uk/<sha>-o.svg
664
+ // cdnUrl = https://8ok.uk/<tid b36>/v/<sha>-o.svg ← the tenant segment is not optional
665
+
666
+ // Processing is asynchronous. `upload()` returns as soon as the bytes are
667
+ // accepted; the variants are not on the CDN yet. Wait for them:
668
+ const ready = await aq.assets.waitReady(assetId, 90_000); // MILLISECONDS
669
+ // ready.presets is the compact string ("o", "lmoqs", …), ALPHABETICALLY
670
+ // sorted — not in the order you asked for.
665
671
  ```
666
672
 
667
673
  **Responsive ladder (the old default — now explicit):**
@@ -1307,12 +1313,25 @@ server-side pipeline (a platform-wide addition, not a per-tenant one).
1307
1313
 
1308
1314
  ### CDN URL format
1309
1315
 
1310
- `<cdnBase>/<sha16>-<presetCode>.<ext>`
1316
+ `<cdnBase>/<tenantId base36>/v/<sha16>-<presetCode>.<ext>`
1317
+
1318
+ Example: `https://8ok.uk/f/v/c482458e824c730e-q.webp` — the `thumb` preset of
1319
+ sha `c482458e…` as WebP, for **tenant 15** (`15` in base36 is `f`).
1320
+
1321
+ ⚠️ **The tenant segment is not optional, and it is base36.** `/15/…` 404s;
1322
+ so does a bare `/<sha16>-q.webp` with no tenant at all. Nothing serves that
1323
+ shape — it is not a legacy path, it is a 404. Call `setTenantId(id)` once at
1324
+ boot (or construct a `NitidaClient` with `tenantId`, which does it for you);
1325
+ without it the builders **throw** rather than hand you a URL that cannot work.
1326
+
1327
+ Within one tenant the path is content-addressed: the same source bytes always
1328
+ produce the same URL, and that URL never invalidates.
1311
1329
 
1312
- Example: `https://8ok.uk/c482458e824c730e-q.webp` (the `thumb` preset of
1313
- sha `c482458e…` rendered as WebP). The path is content-addressed, so the
1314
- same source bytes produce the same URL regardless of which tenant uploaded
1315
- them and the same URL never invalidates.
1330
+ > Before `@nitida/asset-client@0.20.0` this section documented the bare
1331
+ > `<cdnBase>/<sha16>-<preset>.<ext>` form, with an example that 404s, and said
1332
+ > the URL was the same "regardless of which tenant uploaded them". That stopped
1333
+ > being true at the tenant-prefix cutover. If you copied a URL from an older
1334
+ > README, add the `<tid b36>/v/` segment.
1316
1335
 
1317
1336
  ## Auth
1318
1337
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nitida/sdk",
3
- "version": "0.30.2",
3
+ "version": "0.31.1",
4
4
  "description": "nitida — the media SDK: browser and mobile upload with resume, client-side compression, on-the-fly transforms behind a CDN, video transcode, HLS ladders and AI proxies. Multi-tenant.",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -73,7 +73,7 @@
73
73
  },
74
74
  "peerDependencies": {
75
75
  "react": ">=18",
76
- "@nitida/asset-client": "^0.19.1",
76
+ "@nitida/asset-client": "^0.20.1",
77
77
  "@nitida/asset-compressor-web": "^0.6.1",
78
78
  "@nitida/asset-compressor-native": "^0.2.1"
79
79
  },
@@ -60,7 +60,7 @@ import { setCdnBase, setTenantId } from "@nitida/asset-client";
60
60
  const TENANT_ID = Number(process.env.NEXT_PUBLIC_NITIDA_TENANT_ID) || /* your id */ 0;
61
61
 
62
62
  setCdnBase("https://8ok.uk"); // OPTIONAL — this is already the default; set it only if you were given another host
63
- setTenantId(TENANT_ID); // REQUIRED for video URLs (base36 variant prefix) see §3
63
+ setTenantId(TENANT_ID); // REQUIRED for EVERY variant URL — images too (base36 prefix), see §3
64
64
  ```
65
65
 
66
66
  `NEXT_PUBLIC_*` so the tenant id reaches the client bundle (hero/about videos render client-side). The runtime read-only consumer needs only these public vars — the `amk_rt_*` runtime key is for **uploads** (server-only), not for building URLs.
@@ -100,7 +100,9 @@ Output URL shape: `https://8ok.uk/t/format=webp,width=640/<sha16>.webp`.
100
100
  different bytes from the same photo.
101
101
 
102
102
  ```ts
103
- // ⚠️ `setCdnBase` is NOT re-exported by `@nitida/sdk` (but `setTenantId` is).
103
+ // Both `setCdnBase` and `setTenantId` ARE re-exported by `@nitida/sdk`
104
+ // and `@nitida/sdk/server` (measured 2026-08-24 on 0.31.0). An older note here
105
+ // said `setCdnBase` was not — it is.
104
106
  import { setCdnBase, type TransformWidth } from "@nitida/asset-client";
105
107
  import { getTransformSrcSet, getTransformUrl } from "@nitida/sdk";
106
108
 
@@ -517,7 +519,7 @@ That replaces the older hand-run provisioning scripts and SQL that used to live
517
519
  | Poster | `getAssetUrl({sha}, 'poster')` | `/<tid b36>/v/<sha>-p.webp` |
518
520
  | Sha from URL | `extractAssetSha(url)` | — |
519
521
 
520
- Variant preset short codes: `thumb=q, sm=s, md=m, lg=l, xl=x, original=o, poster=p, video=v`. Exts: images `webp`, video `mp4`.
522
+ Variant preset short codes — **all of them**: `thumb=q, sm=s, md=m, lg=l, xl=x, original=o, poster=p, video=v, aiproxy=a, hls=h, mp3=mp3`. ⚠️ `mp3` is the one irregular case: three characters, not one. Exts: images `webp`, video `mp4`.
521
523
 
522
524
 
523
525
  ## Private assets — `visibility`