@embark-black-book/api-contract 0.5.0 → 0.11.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 CHANGED
@@ -216,6 +216,13 @@ function getCardImage(baseUrl: string, image: ApiMedia | null | undefined) {
216
216
  }
217
217
  ```
218
218
 
219
+ Available helpers:
220
+
221
+ - `getBestImageUrl(baseUrl, image, width, height?)`
222
+ - `resolveStrapiAssetUrl(baseUrl, assetUrl)`
223
+
224
+ `getBestImageUrl` uses typed media formats (`StrapiImageFormats`) and deterministic known widths:
225
+
219
226
  Format selection is deterministic and uses known Strapi image sizes:
220
227
 
221
228
  - `xsmall`: `64`
@@ -224,7 +231,29 @@ Format selection is deterministic and uses known Strapi image sizes:
224
231
  - `large`: `1000`
225
232
  - `xlarge`: `1920`
226
233
 
227
- The helper picks the smallest available format whose known size is greater than or equal to the requested render size. If no suitable format exists, or no formats are present, it falls back to the base image URL.
234
+ Selection behavior:
235
+
236
+ - Uses `max(width, height ?? 0)` as the requested render size.
237
+ - Picks the smallest available format whose known size is greater than or equal to that requested size.
238
+ - Falls back to `image.url` when only smaller formats exist.
239
+ - Falls back to `image.url` when `formats` is missing or empty.
240
+ - Resolves relative URLs (for both formats and base `image.url`) against the origin derived from `baseUrl`.
241
+ - Passes through absolute URLs unchanged.
242
+
243
+ ```ts
244
+ import {
245
+ getBestImageUrl,
246
+ resolveStrapiAssetUrl,
247
+ type ApiMedia,
248
+ } from "@embark-black-book/api-contract";
249
+
250
+ function buildImageUrls(baseUrl: string, image: ApiMedia | null | undefined) {
251
+ const cardImage = getBestImageUrl(baseUrl, image, 640, 360);
252
+ const baseImage = resolveStrapiAssetUrl(baseUrl, image?.url);
253
+
254
+ return { cardImage, baseImage };
255
+ }
256
+ ```
228
257
 
229
258
  ## Call Endpoint Without Token
230
259
 
@@ -335,7 +364,15 @@ async function renameAccordionCategory(
335
364
  - Run `npm --prefix package-contract run verify:publish`.
336
365
  - Update `package-contract/CHANGELOG.md` with release notes.
337
366
  - Bump version in `package-contract/package.json`.
338
- - Publish package (internal registry).
367
+ - cd package-contract
368
+ - npm publish
369
+
370
+ ## Update Granular Access Token
371
+
372
+ In order to publish to the private package, a granular access token is required. Tokens can only last up to 90 days. When the token expires,
373
+ log in at npmjs.com and generate a new similar access token. Then update the token locally as follows:
374
+
375
+ - npm config set //registry.npmjs.org/:\_authToken=NEW_TOKEN
339
376
 
340
377
  ## Output
341
378