@nitida/sdk 0.32.3 → 0.33.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/dist/index.d.ts +16 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/dist/server.js +10 -0
- package/dist/server.js.map +1 -1
- package/dist/web.js +10 -0
- package/dist/web.js.map +1 -1
- package/package.json +2 -2
- package/skills/nitida-sdk/SKILL.md +3 -1
- package/src/index.ts +40 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nitida/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0",
|
|
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.
|
|
76
|
+
"@nitida/asset-client": "^0.21.0",
|
|
77
77
|
"@nitida/asset-compressor-web": "^0.6.1",
|
|
78
78
|
"@nitida/asset-compressor-native": "^0.2.1"
|
|
79
79
|
},
|
|
@@ -574,7 +574,9 @@ That replaces the older hand-run provisioning scripts and SQL that used to live
|
|
|
574
574
|
| Poster | `getAssetUrl({sha}, 'poster')` | `/<tid b36>/v/<sha>-p.webp` |
|
|
575
575
|
| Sha from URL | `extractAssetSha(url)` | — |
|
|
576
576
|
|
|
577
|
-
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,
|
|
577
|
+
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, mp3=mp3`. ⚠️ `mp3` is the one irregular case: three characters, not one. Exts: images `webp`, video `mp4`.
|
|
578
|
+
|
|
579
|
+
⚠️ **`hls` is deliberately NOT in that list.** It has an internal short code (`h`), but it is never a URL you can fetch: a ladder is a PREFIX (`<sha16>-hls<dslHash>/master.m3u8`) whose `<dslHash>` is computed server-side, so a hand-built `<sha16>-h.m3u8` **404s on every asset** (measured). Use `getAssetUrl(asset, "hls")` or `getHlsStreamingUrl({ sha })` — see §3c — and never derive the path yourself.
|
|
578
580
|
|
|
579
581
|
|
|
580
582
|
## Private assets — `visibility`
|
package/src/index.ts
CHANGED
|
@@ -1090,6 +1090,27 @@ export type UploadOptions = {
|
|
|
1090
1090
|
*/
|
|
1091
1091
|
const DEFAULT_UPLOAD_PRESETS: RequestablePreset[] = ["original"];
|
|
1092
1092
|
|
|
1093
|
+
/**
|
|
1094
|
+
* Fallback for `UploadResult.kind` when the server DTO does not carry one.
|
|
1095
|
+
*
|
|
1096
|
+
* Mirrors what the asset-manager itself does — it branches on the MIME prefix
|
|
1097
|
+
* (`video/` at `process.routes.ts:149`, `audio/` at `:332`, `image/` at
|
|
1098
|
+
* `:972`) and files everything else as `other`. Kept in step deliberately: a
|
|
1099
|
+
* fallback that disagreed with the server would hand a caller a `kind` the
|
|
1100
|
+
* platform never assigned, and `getAssetUrl` now makes decisions on it.
|
|
1101
|
+
*
|
|
1102
|
+
* This should almost never fire — every DTO the API returns carries `kind`.
|
|
1103
|
+
* It exists so the field is never `undefined`, because `undefined` is exactly
|
|
1104
|
+
* how a builder silently opts out of a refusal it should have honoured.
|
|
1105
|
+
*/
|
|
1106
|
+
function kindForMime(mime: string | undefined): AssetDTO["kind"] {
|
|
1107
|
+
const m = (mime ?? "").toLowerCase();
|
|
1108
|
+
if (m.startsWith("video/")) return "video";
|
|
1109
|
+
if (m.startsWith("audio/")) return "audio";
|
|
1110
|
+
if (m.startsWith("image/")) return "image";
|
|
1111
|
+
return "other";
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1093
1114
|
export type UploadResult = {
|
|
1094
1115
|
assetId: string;
|
|
1095
1116
|
sha256: string;
|
|
@@ -1165,6 +1186,22 @@ export type UploadResult = {
|
|
|
1165
1186
|
* objeto no lo llevaba. El resultado era una URL pública para un asset
|
|
1166
1187
|
* privado, servida sin una queja, que después da 404.
|
|
1167
1188
|
*/
|
|
1189
|
+
/**
|
|
1190
|
+
* What the asset IS (`image` · `video` · `audio` · `document` · `other`).
|
|
1191
|
+
*
|
|
1192
|
+
* ⭐ It exists because it did not, and the guard caught it before anyone
|
|
1193
|
+
* else did — the FIFTH member of this family, after `sha`, `mime`, `oext`
|
|
1194
|
+
* and `presets`. When `getAssetUrl` learned to refuse `hls` on something
|
|
1195
|
+
* that can never have a ladder, it started READING `kind`; an
|
|
1196
|
+
* `UploadResult` without it silently opted out of the refusal and went
|
|
1197
|
+
* right back to building `/t/format=hls/<sha>.m3u8` — which does not 404,
|
|
1198
|
+
* it answers 200 with the image bytes.
|
|
1199
|
+
*
|
|
1200
|
+
* The rule this keeps re-teaching: a return type that omits what the next
|
|
1201
|
+
* call reads is a silent 404 (or worse, a silent 200). The fix is always to
|
|
1202
|
+
* carry the field, never to write a better error message about its absence.
|
|
1203
|
+
*/
|
|
1204
|
+
kind: AssetDTO["kind"];
|
|
1168
1205
|
visibility: "public" | "private";
|
|
1169
1206
|
/**
|
|
1170
1207
|
* La cadena compacta de variantes que EXISTEN (`"lmoqs"`, `"o"`, …).
|
|
@@ -1756,6 +1793,7 @@ export class NitidaClient {
|
|
|
1756
1793
|
// Same shape as the presign branch below, for the same reason. This
|
|
1757
1794
|
// DTO does carry `sha` today — but relying on that is how the other
|
|
1758
1795
|
// branch broke, and the value we hashed ourselves is authoritative.
|
|
1796
|
+
kind: existing.kind ?? kindForMime(mime),
|
|
1759
1797
|
visibility: existing.visibility ?? "public",
|
|
1760
1798
|
presets: existing.presets ?? "",
|
|
1761
1799
|
variants: existing.variants ?? [],
|
|
@@ -1850,6 +1888,7 @@ export class NitidaClient {
|
|
|
1850
1888
|
// ACTUALLY has, now that we waited for it — not from
|
|
1851
1889
|
// `defaultPresetForMime`, which is a guess made before anything exists.
|
|
1852
1890
|
// Guessing was safe only while this branch never ran.
|
|
1891
|
+
kind: settled.kind ?? kindForMime(mime),
|
|
1853
1892
|
visibility: settled.visibility ?? "public",
|
|
1854
1893
|
presets: settled.presets ?? "",
|
|
1855
1894
|
variants: settled.variants ?? [],
|
|
@@ -1909,6 +1948,7 @@ export class NitidaClient {
|
|
|
1909
1948
|
sha: sha.slice(0, 16),
|
|
1910
1949
|
mime: final.mime ?? mime,
|
|
1911
1950
|
oext: final.oext ?? null,
|
|
1951
|
+
kind: final.kind ?? kindForMime(final.mime ?? mime),
|
|
1912
1952
|
visibility: final.visibility ?? "public",
|
|
1913
1953
|
presets: final.presets ?? "",
|
|
1914
1954
|
variants: final.variants ?? [],
|