@nitida/sdk 0.36.0 → 0.36.2
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 +19 -9
- package/dist/index.d.ts +3 -0
- package/dist/index.js +16 -13
- package/dist/index.js.map +1 -1
- package/dist/server.js +16 -13
- package/dist/server.js.map +1 -1
- package/dist/web.js +23 -13
- package/dist/web.js.map +1 -1
- package/package.json +2 -2
- package/skills/nitida-sdk/SKILL.md +18 -5
- package/src/index.ts +23 -12
- package/src/web/index.ts +10 -0
package/dist/server.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import {
|
|
3
|
-
configureSlotResolver,
|
|
4
3
|
getAssetSrcSet,
|
|
5
4
|
getAssetUrl,
|
|
6
5
|
getHlsStreamingUrl,
|
|
@@ -119,13 +118,22 @@ var SlotsApi = class {
|
|
|
119
118
|
this.opts = opts;
|
|
120
119
|
}
|
|
121
120
|
opts;
|
|
121
|
+
/** This client's own auth/endpoint scope, threaded into every resolve so it
|
|
122
|
+
* never uses another client's key (audit N15). */
|
|
123
|
+
resolverConfig() {
|
|
124
|
+
return {
|
|
125
|
+
endpoint: this.opts.endpoint,
|
|
126
|
+
apiKey: this.opts.apiKey ?? null,
|
|
127
|
+
tenantCode: this.opts.tenantCode
|
|
128
|
+
};
|
|
129
|
+
}
|
|
122
130
|
/** Resolve one slot — returns `{slot, preset, url}` or `{slot: null, url: null}` when unbound. */
|
|
123
131
|
resolve(slotKey, options = {}) {
|
|
124
|
-
return resolveSlot(slotKey, options);
|
|
132
|
+
return resolveSlot(slotKey, { config: this.resolverConfig(), ...options });
|
|
125
133
|
}
|
|
126
134
|
/** Bulk-resolve N slots in one HTTP round-trip. */
|
|
127
135
|
resolveMany(slotKeys, options = {}) {
|
|
128
|
-
return resolveSlots(slotKeys, options);
|
|
136
|
+
return resolveSlots(slotKeys, { config: this.resolverConfig(), ...options });
|
|
129
137
|
}
|
|
130
138
|
/** List slots for the tenant (admin). Optional prefix filter for tree views. */
|
|
131
139
|
async list(opts = {}) {
|
|
@@ -217,7 +225,7 @@ var AssetsApi = class {
|
|
|
217
225
|
*/
|
|
218
226
|
async byHash(sha256) {
|
|
219
227
|
const r = await fetch(
|
|
220
|
-
endpointHref(this.opts, `/assets/by-hash/${sha256}`),
|
|
228
|
+
endpointHref(this.opts, `/assets/by-hash/${encodeURIComponent(sha256)}`),
|
|
221
229
|
{ headers: this.headers() }
|
|
222
230
|
);
|
|
223
231
|
if (r.status === 404) return null;
|
|
@@ -248,7 +256,7 @@ var AssetsApi = class {
|
|
|
248
256
|
}
|
|
249
257
|
/** Full DTO for an asset (admin view — includes audit-only fields). */
|
|
250
258
|
async get(assetId) {
|
|
251
|
-
const r = await fetch(endpointHref(this.opts, `/assets/${assetId}`), {
|
|
259
|
+
const r = await fetch(endpointHref(this.opts, `/assets/${encodeURIComponent(assetId)}`), {
|
|
252
260
|
headers: this.headers()
|
|
253
261
|
});
|
|
254
262
|
if (!r.ok) throw new Error(`asset get ${r.status}: ${await r.text()}`);
|
|
@@ -260,7 +268,7 @@ var AssetsApi = class {
|
|
|
260
268
|
* resolve to nothing.
|
|
261
269
|
*/
|
|
262
270
|
async bindings(assetId) {
|
|
263
|
-
const r = await fetch(endpointHref(this.opts, `/assets/${assetId}/slots`), {
|
|
271
|
+
const r = await fetch(endpointHref(this.opts, `/assets/${encodeURIComponent(assetId)}/slots`), {
|
|
264
272
|
headers: this.headers()
|
|
265
273
|
});
|
|
266
274
|
if (!r.ok) throw new Error(`asset bindings ${r.status}: ${await r.text()}`);
|
|
@@ -323,7 +331,7 @@ var AssetsApi = class {
|
|
|
323
331
|
*/
|
|
324
332
|
async regenerate(assetId, opts = {}) {
|
|
325
333
|
const r = await fetch(
|
|
326
|
-
endpointHref(this.opts, `/assets/${assetId}/regenerate`),
|
|
334
|
+
endpointHref(this.opts, `/assets/${encodeURIComponent(assetId)}/regenerate`),
|
|
327
335
|
{
|
|
328
336
|
method: "POST",
|
|
329
337
|
headers: { ...this.headers(), "Content-Type": "application/json" },
|
|
@@ -336,7 +344,7 @@ var AssetsApi = class {
|
|
|
336
344
|
}
|
|
337
345
|
/** Merge metadata into an asset (role / slot / description / tags). */
|
|
338
346
|
async patchMetadata(assetId, metadata) {
|
|
339
|
-
const r = await fetch(endpointHref(this.opts, `/assets/${assetId}`), {
|
|
347
|
+
const r = await fetch(endpointHref(this.opts, `/assets/${encodeURIComponent(assetId)}`), {
|
|
340
348
|
method: "PATCH",
|
|
341
349
|
headers: { ...this.headers(), "Content-Type": "application/json" },
|
|
342
350
|
body: JSON.stringify({ metadata })
|
|
@@ -577,11 +585,6 @@ var NitidaClient = class {
|
|
|
577
585
|
const cdn = opts.cdnBase ?? "https://8ok.uk";
|
|
578
586
|
setCdnBase(cdn);
|
|
579
587
|
setTenantId(opts.tenantId);
|
|
580
|
-
configureSlotResolver({
|
|
581
|
-
endpoint: opts.endpoint,
|
|
582
|
-
apiKey: opts.apiKey,
|
|
583
|
-
tenantCode: opts.tenantCode
|
|
584
|
-
});
|
|
585
588
|
this.slots = new SlotsApi(opts);
|
|
586
589
|
this.assets = new AssetsApi(opts);
|
|
587
590
|
this.usage = new UsageApi(opts);
|