feat: добавить endpoint picture/srcset

- добавлен contract DTO для picture sources и fallback image
- реализована выдача versioned Gateway URLs по static presets
- обновлена документация business API и dev smoke flow
This commit is contained in:
2026-05-05 13:35:25 +03:00
parent 3ec1e51bea
commit 56d551b43b
6 changed files with 279 additions and 2 deletions

View File

@@ -111,12 +111,13 @@ POST /assets
GET /assets
GET /assets/:publicId
POST /assets/:publicId/versions
GET /assets/:publicId/picture
GET /assets/:publicId/variants
POST /assets/:publicId/variants
DELETE /assets/:id
```
Сейчас реализованы `POST /assets`, `GET /assets`, `GET /assets/:publicId`, `POST /assets/:publicId/versions`, `GET /assets/:publicId/variants`, `POST /assets/:publicId/variants`.
Сейчас реализованы `POST /assets`, `GET /assets`, `GET /assets/:publicId`, `POST /assets/:publicId/versions`, `GET /assets/:publicId/picture`, `GET /assets/:publicId/variants`, `POST /assets/:publicId/variants`.
`POST /assets` request:
@@ -194,6 +195,35 @@ Response:
Новая версия становится `currentVersion` asset. Старые Gateway URLs с `/v1/` остаются immutable и не требуют purge.
`GET /assets/:publicId/picture?preset=card&sizes=100vw` response:
```json
{
"publicId": "asset_demo",
"preset": "card",
"version": 2,
"quality": 80,
"sizes": "100vw",
"widths": [320, 640, 960],
"image": {
"src": "http://localhost:8888/images/asset_demo/v2/card?w=960&q=80&f=jpg",
"format": "jpg",
"type": "image/jpeg",
"width": 960,
"height": 0
},
"sources": [
{
"format": "avif",
"type": "image/avif",
"srcSet": "http://localhost:8888/images/asset_demo/v2/card?w=320&q=80&f=avif 320w, http://localhost:8888/images/asset_demo/v2/card?w=640&q=80&f=avif 640w, http://localhost:8888/images/asset_demo/v2/card?w=960&q=80&f=avif 960w"
}
]
}
```
Endpoint не ставит generation jobs: Gateway lazy path сгенерирует bytes на первом запросе или отдаст cache/S3.
## Variants
```text

View File

@@ -90,6 +90,7 @@ curl -sS -X POST http://localhost:3001/api/assets \
curl -sS http://localhost:3001/api/presets
curl -sS http://localhost:3001/api/assets
curl -sS http://localhost:3001/api/assets/asset_demo
curl -sS 'http://localhost:3001/api/assets/asset_demo/picture?preset=card&sizes=100vw'
curl -sS http://localhost:3001/api/assets/asset_demo/variants
```