@nitida/sdk 0.24.1 → 0.25.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/README.md +128 -129
- package/dist/index.d.ts +28 -27
- package/dist/index.js +56 -11
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +9 -7
- package/dist/server.js +34 -11
- package/dist/server.js.map +1 -1
- package/dist/web.d.ts +11 -12
- package/dist/web.js +34 -11
- package/dist/web.js.map +1 -1
- package/package.json +2 -2
- package/skills/nitida-sdk/SKILL.md +39 -46
- package/src/index.ts +60 -26
- package/src/server/index.ts +9 -7
- package/src/web/index.ts +16 -17
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ResolveSlotOptions, SlotResolution, SlotDTO, VariantPreset, AssetDTO, AssetVariant, TransformOptions, SignedTransformOptions } from '@nitida/asset-client';
|
|
2
|
-
export { AssetDTO, AssetVariant, ResolveSlotOptions, SignedTransformOptions, SlotDTO, SlotResolution, TransformEffect, TransformFit, TransformFormat, TransformGravity, TransformOptions, VariantPreset, computeVariantDimensions, extractAssetSha, getAssetDimensions, getAssetSrcSet, getAssetUrl, getHlsStreamingUrl, getSignedTransformUrl, getTenantId, getTransformSrcSet, getTransformUrl, getVideoTransformUrl, hasPreset, serializeTransform, setTenantId, signTransformUrl } from '@nitida/asset-client';
|
|
2
|
+
export { AssetDTO, AssetPalette, AssetVariant, HlsRung, PRESET_EXT, PRESET_LONG, PRESET_MAX_DIM, PRESET_SHORT, PaletteSwatch, ResolveSlotOptions, SignedTransformOptions, SlotDTO, SlotResolution, TRANSFORM_WIDTHS, TransformEffect, TransformFit, TransformFormat, TransformGravity, TransformOptions, TransformWidth, VariantPreset, bestTextContrast, computeVariantDimensions, configureSlotResolver, contrastRatio, extractAssetSha, getAmbientGradient, getAssetDimensions, getAssetSrcSet, getAssetUrl, getCdnBase, getHlsLadder, getHlsStreamingUrl, getPaletteBlurBackground, getPaletteCssVars, getSignedTransformUrl, getTenantId, getTextColorForBackground, getTransformSrcSet, getTransformUrl, getVideoTransformUrl, hasPreset, hlsLadderAlignment, invalidateSlotCache, iteratePaletteSwatches, pickAmbientBackground, relativeLuminance, resolveSlot, resolveSlots, serializeTransform, setCdnBase, setTenantId, signTransformUrl } from '@nitida/asset-client';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @nitida/sdk — universal client for the aquienpz multi-tenant asset
|
|
@@ -7,8 +7,8 @@ export { AssetDTO, AssetVariant, ResolveSlotOptions, SignedTransformOptions, Slo
|
|
|
7
7
|
*
|
|
8
8
|
* One ergonomic facade over the underlying packages
|
|
9
9
|
* (`@nitida/asset-client` URL builders + `@aquienpz/asset-uploader-web`
|
|
10
|
-
* + the slot resolver). Auth is a
|
|
11
|
-
*
|
|
10
|
+
* + the slot resolver). Auth is a bearer API key (`amk_rt_*`), issued
|
|
11
|
+
* per tenant when the tenant is created; tenant scope comes from
|
|
12
12
|
* the key's metadata (`X-Tenant-Code` is log-only).
|
|
13
13
|
*
|
|
14
14
|
* Usage:
|
|
@@ -17,8 +17,8 @@ export { AssetDTO, AssetVariant, ResolveSlotOptions, SignedTransformOptions, Slo
|
|
|
17
17
|
*
|
|
18
18
|
* const aq = new NitidaClient({
|
|
19
19
|
* endpoint: "https://api.nitida.gofuture.space",
|
|
20
|
-
* apiKey: process.env.
|
|
21
|
-
* tenantCode: "
|
|
20
|
+
* apiKey: process.env.AQUIENPZ_API_KEY!, // amk_rt_* — server-only
|
|
21
|
+
* tenantCode: "acme-co",
|
|
22
22
|
* cdnBase: "https://8ok.uk", // optional override
|
|
23
23
|
* tenantId: 4, // required for tenant-prefixed URLs
|
|
24
24
|
* });
|
|
@@ -60,7 +60,7 @@ type NitidaClientOptions = {
|
|
|
60
60
|
*/
|
|
61
61
|
endpoint: string;
|
|
62
62
|
/**
|
|
63
|
-
*
|
|
63
|
+
* Bearer API key with the `amk_rt_*` prefix.
|
|
64
64
|
*
|
|
65
65
|
* **Server-only.** Omit when constructing from `@nitida/sdk/web` —
|
|
66
66
|
* your BFF / route handler injects the bearer header in proxy mode.
|
|
@@ -85,8 +85,8 @@ type NitidaClientOptions = {
|
|
|
85
85
|
* Tenant's HMAC signing key for transform URLs (Phase 3). Required
|
|
86
86
|
* only when calling `aq.transform(asset, opts, { sign: true })`.
|
|
87
87
|
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
88
|
+
* 32 random bytes, generated server-side on tenant creation; fetch
|
|
89
|
+
* via `GET /admin/tenants/:id` with an admin key. **Keep it
|
|
90
90
|
* server-side only** — do not ship in `NEXT_PUBLIC_*` env vars. Sign
|
|
91
91
|
* URLs from a BFF route handler, or pre-sign at build time.
|
|
92
92
|
*/
|
|
@@ -214,7 +214,7 @@ type UploadVideoOptions = {
|
|
|
214
214
|
hls?: boolean;
|
|
215
215
|
/**
|
|
216
216
|
* `true` → when the uploaded MP4 is ALREADY web-safe (H.264 + yuv420p),
|
|
217
|
-
* re-mux the `video` variant
|
|
217
|
+
* re-mux the `video` variant instead of re-encoding it. Use for
|
|
218
218
|
* delivery-ready uploads (the bytes are already H.264 High / yuv420p /
|
|
219
219
|
* +faststart / capped bitrate) to skip a wasteful re-encode + generational
|
|
220
220
|
* quality loss. Falls back to a full re-encode automatically when the source
|
|
@@ -239,8 +239,8 @@ type PresignUploadUrlOptions = {
|
|
|
239
239
|
presets?: VariantPreset[];
|
|
240
240
|
/**
|
|
241
241
|
* Pre-compression size of the source (useful when the browser ran
|
|
242
|
-
* compressorjs / heic2any before computing `bytes`).
|
|
243
|
-
*
|
|
242
|
+
* compressorjs / heic2any before computing `bytes`). Recorded
|
|
243
|
+
* server-side, so the savings show up in the admin usage dashboards.
|
|
244
244
|
*/
|
|
245
245
|
clientOriginalBytes?: number;
|
|
246
246
|
/** VIDEO-only delivery knobs forwarded into `/assets/process`. See {@link UploadVideoOptions}. */
|
|
@@ -318,8 +318,8 @@ declare class AssetsApi {
|
|
|
318
318
|
* const v = await aq.assets.variants(logoId);
|
|
319
319
|
* v.map((x) => x.preset); // → ("thumb" | "sm" | … | "original")[]
|
|
320
320
|
*
|
|
321
|
-
* ⚠️ Returns `[]` — not an error — against a server
|
|
322
|
-
* 2026-08-17
|
|
321
|
+
* ⚠️ Returns `[]` — not an error — against a server older than the
|
|
322
|
+
* 2026-08-17 release, which never sent the field at all. An empty
|
|
323
323
|
* array is therefore "no variants OR old server". For a plain existence
|
|
324
324
|
* check prefer `hasPreset(dto, preset)` on `dto.presets`, which every server
|
|
325
325
|
* version sends; use this when you need the URLs and sizes.
|
|
@@ -342,12 +342,13 @@ declare class AssetsApi {
|
|
|
342
342
|
* Passing no presets re-runs the FULL default pipeline for that
|
|
343
343
|
* asset's kind (thumb+sm+md+lg for images, poster+video for video).
|
|
344
344
|
*
|
|
345
|
-
* If the asset was uploaded original-only and the
|
|
346
|
-
* already
|
|
347
|
-
* bytes from
|
|
345
|
+
* If the asset was uploaded original-only and the ~24 h grace window
|
|
346
|
+
* on the uploaded bytes has already closed, the route falls back to
|
|
347
|
+
* reading the source bytes from the permanent `original` variant —
|
|
348
|
+
* no need to re-upload.
|
|
348
349
|
*
|
|
349
350
|
* Video presets are filtered to `["poster","video","aiproxy"]` and
|
|
350
|
-
* dispatched to
|
|
351
|
+
* dispatched to a background job (the call returns immediately
|
|
351
352
|
* with a dispatch handle; poll `aq.assets.get(id).status` for
|
|
352
353
|
* completion).
|
|
353
354
|
*/
|
|
@@ -509,8 +510,8 @@ type UploadOptions = {
|
|
|
509
510
|
/**
|
|
510
511
|
* Max time to wait for the asset to transition to `ready` (or `failed`)
|
|
511
512
|
* after dispatch. Default `5 * 60_000` (5 min). Bump higher for large
|
|
512
|
-
* videos / HLS transcodes —
|
|
513
|
-
*
|
|
513
|
+
* videos / HLS transcodes — processing time scales with input size,
|
|
514
|
+
* and with how much other work the platform is doing at that moment.
|
|
514
515
|
*
|
|
515
516
|
* Throws `Error("waitReady timeout for <id>")` if the deadline passes
|
|
516
517
|
* without the asset transitioning. The asset row stays in aquienpz
|
|
@@ -572,11 +573,11 @@ type UsageWindow = {
|
|
|
572
573
|
* encode passes, so a 7-rung HLS ladder over a 2-minute clip books 14.
|
|
573
574
|
*
|
|
574
575
|
* A re-encode of a video already ingested counts AGAIN. That is the point:
|
|
575
|
-
*
|
|
576
|
-
*
|
|
576
|
+
* an asset count cannot report it, because re-encoding an asset that already
|
|
577
|
+
* exists creates no new asset.
|
|
577
578
|
*
|
|
578
|
-
* A stream copy (
|
|
579
|
-
* nothing, so a tenant that ran no encoder reads `0` — and that `0` is real.
|
|
579
|
+
* A stream copy (`video: { passthrough: true }`, or an idempotent cache skip)
|
|
580
|
+
* books nothing, so a tenant that ran no encoder reads `0` — and that `0` is real.
|
|
580
581
|
*/
|
|
581
582
|
videoMinutes: number;
|
|
582
583
|
/** Encode passes behind `videoMinutes`. 0 when nothing was encoded. */
|
|
@@ -708,7 +709,7 @@ declare class NitidaClient {
|
|
|
708
709
|
* images).
|
|
709
710
|
*
|
|
710
711
|
* On the first request the route returns **202 Accepted** with
|
|
711
|
-
* `Retry-After: 10` while the
|
|
712
|
+
* `Retry-After: 10` while the encode runs (typically 5-30 s for a
|
|
712
713
|
* short clip). The response body includes `outputUrl` which is the
|
|
713
714
|
* eventual CDN URL — poll the same transform URL after the
|
|
714
715
|
* retry-after window to get a 302 redirect to it.
|
|
@@ -768,8 +769,8 @@ declare class NitidaClient {
|
|
|
768
769
|
*
|
|
769
770
|
* ⚠️ `presets` decides what exists FOREVER. Omit it and only `original` is written; ask for
|
|
770
771
|
* `["thumb"]` and the bytes you just uploaded are **not retrievable**. A variant not requested in
|
|
771
|
-
* this first ingest cannot be added later once the
|
|
772
|
-
* "97 files archived successfully, zero recoverable".
|
|
772
|
+
* this first ingest cannot be added later once the ~24 h grace window on the uploaded bytes
|
|
773
|
+
* closes — measured once as "97 files archived successfully, zero recoverable".
|
|
773
774
|
*
|
|
774
775
|
* @example Deliver an image on a site (the responsive ladder)
|
|
775
776
|
* ```ts
|
|
@@ -800,7 +801,7 @@ declare class NitidaClient {
|
|
|
800
801
|
* @example Video — and what does NOT work there
|
|
801
802
|
* ```ts
|
|
802
803
|
* // `original` is accepted and then silently DROPPED: /assets/process filters video presets to
|
|
803
|
-
* // {poster, video, aiproxy, probe} before dispatching the transcode
|
|
804
|
+
* // {poster, video, aiproxy, probe} before dispatching the background transcode.
|
|
804
805
|
* await aq.upload(clip, { fileName: "tour.mp4", presets: ["poster", "video"] });
|
|
805
806
|
*
|
|
806
807
|
* // Omit `aiproxy`/`probe` unless the asset really goes to a vision model — they cost encode
|
package/dist/index.js
CHANGED
|
@@ -16,21 +16,43 @@ import {
|
|
|
16
16
|
setTenantId
|
|
17
17
|
} from "@nitida/asset-client";
|
|
18
18
|
import {
|
|
19
|
+
bestTextContrast,
|
|
19
20
|
computeVariantDimensions,
|
|
21
|
+
configureSlotResolver as configureSlotResolver2,
|
|
22
|
+
contrastRatio,
|
|
20
23
|
extractAssetSha,
|
|
24
|
+
getAmbientGradient,
|
|
21
25
|
getAssetDimensions,
|
|
22
26
|
getAssetSrcSet as getAssetSrcSet2,
|
|
23
27
|
getAssetUrl as getAssetUrl2,
|
|
28
|
+
getCdnBase,
|
|
29
|
+
getHlsLadder,
|
|
24
30
|
getHlsStreamingUrl as getHlsStreamingUrl2,
|
|
31
|
+
getPaletteBlurBackground,
|
|
32
|
+
getPaletteCssVars,
|
|
25
33
|
getSignedTransformUrl as getSignedTransformUrl2,
|
|
26
34
|
getTenantId,
|
|
35
|
+
getTextColorForBackground,
|
|
27
36
|
getTransformSrcSet as getTransformSrcSet2,
|
|
28
37
|
getTransformUrl as getTransformUrl2,
|
|
29
38
|
getVideoTransformUrl as getVideoTransformUrl2,
|
|
30
39
|
hasPreset as hasPreset2,
|
|
40
|
+
hlsLadderAlignment,
|
|
41
|
+
invalidateSlotCache as invalidateSlotCache2,
|
|
42
|
+
iteratePaletteSwatches,
|
|
43
|
+
PRESET_EXT,
|
|
44
|
+
PRESET_LONG,
|
|
45
|
+
PRESET_MAX_DIM,
|
|
46
|
+
PRESET_SHORT,
|
|
47
|
+
pickAmbientBackground,
|
|
48
|
+
relativeLuminance,
|
|
49
|
+
resolveSlot as resolveSlot2,
|
|
50
|
+
resolveSlots as resolveSlots2,
|
|
31
51
|
serializeTransform,
|
|
52
|
+
setCdnBase as setCdnBase2,
|
|
32
53
|
setTenantId as setTenantId2,
|
|
33
|
-
signTransformUrl
|
|
54
|
+
signTransformUrl,
|
|
55
|
+
TRANSFORM_WIDTHS
|
|
34
56
|
} from "@nitida/asset-client";
|
|
35
57
|
function endpointUrl(opts, path, searchParams) {
|
|
36
58
|
const endpoint = opts.endpoint.replace(/\/+$/, "");
|
|
@@ -223,8 +245,8 @@ var AssetsApi = class {
|
|
|
223
245
|
* const v = await aq.assets.variants(logoId);
|
|
224
246
|
* v.map((x) => x.preset); // → ("thumb" | "sm" | … | "original")[]
|
|
225
247
|
*
|
|
226
|
-
* ⚠️ Returns `[]` — not an error — against a server
|
|
227
|
-
* 2026-08-17
|
|
248
|
+
* ⚠️ Returns `[]` — not an error — against a server older than the
|
|
249
|
+
* 2026-08-17 release, which never sent the field at all. An empty
|
|
228
250
|
* array is therefore "no variants OR old server". For a plain existence
|
|
229
251
|
* check prefer `hasPreset(dto, preset)` on `dto.presets`, which every server
|
|
230
252
|
* version sends; use this when you need the URLs and sizes.
|
|
@@ -250,12 +272,13 @@ var AssetsApi = class {
|
|
|
250
272
|
* Passing no presets re-runs the FULL default pipeline for that
|
|
251
273
|
* asset's kind (thumb+sm+md+lg for images, poster+video for video).
|
|
252
274
|
*
|
|
253
|
-
* If the asset was uploaded original-only and the
|
|
254
|
-
* already
|
|
255
|
-
* bytes from
|
|
275
|
+
* If the asset was uploaded original-only and the ~24 h grace window
|
|
276
|
+
* on the uploaded bytes has already closed, the route falls back to
|
|
277
|
+
* reading the source bytes from the permanent `original` variant —
|
|
278
|
+
* no need to re-upload.
|
|
256
279
|
*
|
|
257
280
|
* Video presets are filtered to `["poster","video","aiproxy"]` and
|
|
258
|
-
* dispatched to
|
|
281
|
+
* dispatched to a background job (the call returns immediately
|
|
259
282
|
* with a dispatch handle; poll `aq.assets.get(id).status` for
|
|
260
283
|
* completion).
|
|
261
284
|
*/
|
|
@@ -558,7 +581,7 @@ var NitidaClient = class {
|
|
|
558
581
|
* images).
|
|
559
582
|
*
|
|
560
583
|
* On the first request the route returns **202 Accepted** with
|
|
561
|
-
* `Retry-After: 10` while the
|
|
584
|
+
* `Retry-After: 10` while the encode runs (typically 5-30 s for a
|
|
562
585
|
* short clip). The response body includes `outputUrl` which is the
|
|
563
586
|
* eventual CDN URL — poll the same transform URL after the
|
|
564
587
|
* retry-after window to get a 302 redirect to it.
|
|
@@ -622,8 +645,8 @@ var NitidaClient = class {
|
|
|
622
645
|
*
|
|
623
646
|
* ⚠️ `presets` decides what exists FOREVER. Omit it and only `original` is written; ask for
|
|
624
647
|
* `["thumb"]` and the bytes you just uploaded are **not retrievable**. A variant not requested in
|
|
625
|
-
* this first ingest cannot be added later once the
|
|
626
|
-
* "97 files archived successfully, zero recoverable".
|
|
648
|
+
* this first ingest cannot be added later once the ~24 h grace window on the uploaded bytes
|
|
649
|
+
* closes — measured once as "97 files archived successfully, zero recoverable".
|
|
627
650
|
*
|
|
628
651
|
* @example Deliver an image on a site (the responsive ladder)
|
|
629
652
|
* ```ts
|
|
@@ -654,7 +677,7 @@ var NitidaClient = class {
|
|
|
654
677
|
* @example Video — and what does NOT work there
|
|
655
678
|
* ```ts
|
|
656
679
|
* // `original` is accepted and then silently DROPPED: /assets/process filters video presets to
|
|
657
|
-
* // {poster, video, aiproxy, probe} before dispatching the transcode
|
|
680
|
+
* // {poster, video, aiproxy, probe} before dispatching the background transcode.
|
|
658
681
|
* await aq.upload(clip, { fileName: "tour.mp4", presets: ["poster", "video"] });
|
|
659
682
|
*
|
|
660
683
|
* // Omit `aiproxy`/`probe` unless the asset really goes to a vision model — they cost encode
|
|
@@ -788,20 +811,42 @@ var NitidaClient = class {
|
|
|
788
811
|
};
|
|
789
812
|
export {
|
|
790
813
|
NitidaClient,
|
|
814
|
+
PRESET_EXT,
|
|
815
|
+
PRESET_LONG,
|
|
816
|
+
PRESET_MAX_DIM,
|
|
817
|
+
PRESET_SHORT,
|
|
818
|
+
TRANSFORM_WIDTHS,
|
|
819
|
+
bestTextContrast,
|
|
791
820
|
computeVariantDimensions,
|
|
821
|
+
configureSlotResolver2 as configureSlotResolver,
|
|
822
|
+
contrastRatio,
|
|
792
823
|
extractAssetSha,
|
|
824
|
+
getAmbientGradient,
|
|
793
825
|
getAssetDimensions,
|
|
794
826
|
getAssetSrcSet2 as getAssetSrcSet,
|
|
795
827
|
getAssetUrl2 as getAssetUrl,
|
|
828
|
+
getCdnBase,
|
|
829
|
+
getHlsLadder,
|
|
796
830
|
getHlsStreamingUrl2 as getHlsStreamingUrl,
|
|
831
|
+
getPaletteBlurBackground,
|
|
832
|
+
getPaletteCssVars,
|
|
797
833
|
getSignedTransformUrl2 as getSignedTransformUrl,
|
|
798
834
|
getTenantId,
|
|
835
|
+
getTextColorForBackground,
|
|
799
836
|
getTransformSrcSet2 as getTransformSrcSet,
|
|
800
837
|
getTransformUrl2 as getTransformUrl,
|
|
801
838
|
getVideoTransformUrl2 as getVideoTransformUrl,
|
|
802
839
|
hasPreset2 as hasPreset,
|
|
840
|
+
hlsLadderAlignment,
|
|
841
|
+
invalidateSlotCache2 as invalidateSlotCache,
|
|
842
|
+
iteratePaletteSwatches,
|
|
803
843
|
mimeFromFileName,
|
|
844
|
+
pickAmbientBackground,
|
|
845
|
+
relativeLuminance,
|
|
846
|
+
resolveSlot2 as resolveSlot,
|
|
847
|
+
resolveSlots2 as resolveSlots,
|
|
804
848
|
serializeTransform,
|
|
849
|
+
setCdnBase2 as setCdnBase,
|
|
805
850
|
setTenantId2 as setTenantId,
|
|
806
851
|
signTransformUrl
|
|
807
852
|
};
|