Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
102 lines
4.3 KiB
Markdown
102 lines
4.3 KiB
Markdown
# Live: Add Feed - URL preview/sync + CSV upload (Local Demo Co)
|
|
|
|
**When:** 2026-08-04
|
|
**Tenant:** Local Demo Co (`ee246275-dec0-4446-9e83-58d0c16c258a`)
|
|
**API:** http://127.0.0.1:8080
|
|
**Web:** http://127.0.0.1:5174
|
|
**Auth:** `Authorization: Bearer dk_demo_local_descrybe_test_key_v1`
|
|
|
|
## Verdict
|
|
|
|
**PASS** (real HTTP against Local Demo Co; worker running). No fake passes.
|
|
|
|
| Flow | Result |
|
|
|------|--------|
|
|
| URL create -> extract-schema (preview) -> map -> sync -> sample process | PASS |
|
|
| CSV multipart create -> extract-schema -> map -> sync -> sample process | PASS |
|
|
| Sync before mappings | **400** `no field mappings defined for feed` (expected) |
|
|
|
|
## Correct order
|
|
|
|
```
|
|
Add Feed (URL or CSV file)
|
|
-> status = unmapped
|
|
-> POST .../extract-schema (preview fields)
|
|
-> PUT .../mappings (status -> mapped; sets options.item_path for XML)
|
|
-> POST .../sync (raw_products)
|
|
-> POST .../sync-process-sample (or POST /api/v1/process)
|
|
```
|
|
|
|
Do **not** sync before mappings. FTP/FTPS supplier URLs still return 400 (`ftp/ftps feed sync is not supported yet`).
|
|
|
|
## Fixes applied during this live run
|
|
|
|
1. **New feeds start as `unmapped`** (`Create` INSERT in `internal/feeds/service.go`) so Sync stays gated until mapping; PUT mappings flips `unmapped` -> `mapped`.
|
|
2. **Feeds UI** (`apps/web/src/routes/feeds/+page.svelte`): after create, navigate to `/feeds/{id}/mapping`; block Sync when status is `unmapped`; sync toast no longer says "Next: map fields" after a successful sync.
|
|
|
|
## Evidence - URL (HTTPS Enim sample)
|
|
|
|
| Step | HTTP | Notes |
|
|
|------|------|-------|
|
|
| `POST /api/v1/feeds` JSON | 201 | Feed `453f6efa-...` (Live URL Test); Enim XML URL |
|
|
| `POST .../extract-schema` | 200 | 17 fields, `item_path=Export/Item`, preview present |
|
|
| Sync without map | 400 | `no field mappings defined for feed` |
|
|
| `PUT .../mappings` | 200 | name/brand/gtin/... |
|
|
| `POST .../sync` | 202 | **34** products synced, job `completed` |
|
|
| `POST .../sync-process-sample` (`limit:3`, `skip_sync:true`, `normalize`) | 202 | job `ae90ffc4-...` -> **completed** |
|
|
|
|
## Evidence - CSV upload
|
|
|
|
| Step | HTTP | Notes |
|
|
|------|------|-------|
|
|
| `POST /api/v1/feeds` multipart (`name`, `feed_type=csv`, `file`) | 201 | Feed `8d1d9e53-...`; `options.source_path` + `source_kind=csv` |
|
|
| `POST .../extract-schema` | 200 | 7 fields (EAN, Title, ...); preview = CSV head |
|
|
| `PUT .../mappings` | 200 | gtin/name/description/brand/price/stock/main_image |
|
|
| `POST .../sync` | 202 | **3** products synced |
|
|
| Sample process | 202 -> completed | job `53fede44-...`; all 3 raw -> `processed`; 3 processed products (quality grade C) |
|
|
|
|
## Retest after fix (CSV)
|
|
|
|
| Step | Result |
|
|
|------|--------|
|
|
| Create | 201, **status=`unmapped`** (`474f5343-...`) |
|
|
| Sync early | 400 mappings required |
|
|
| Map | status -> **`mapped`** |
|
|
| Sync | 202, 1 product |
|
|
| Sample process | job completed |
|
|
|
|
## Copy/paste
|
|
|
|
```powershell
|
|
$H = @{ Authorization = "Bearer dk_demo_local_descrybe_test_key_v1"; "Content-Type" = "application/json" }
|
|
$base = "http://127.0.0.1:8080/api/v1"
|
|
|
|
# URL create
|
|
Invoke-RestMethod -Method POST -Uri "$base/feeds" -Headers $H -Body (@{
|
|
name = "My URL feed"; url = "https://www.enim.si/xml/A11109019400_nov/A1nov.xml"
|
|
feed_type = "xml"; sync_interval_minutes = 1440
|
|
} | ConvertTo-Json)
|
|
|
|
# CSV create (curl multipart preferred on Windows)
|
|
# curl -H "Authorization: Bearer dk_demo_local_descrybe_test_key_v1" `
|
|
# -F "name=My CSV feed" -F "feed_type=csv" -F "file=@sample.csv;type=text/csv" `
|
|
# http://127.0.0.1:8080/api/v1/feeds
|
|
|
|
# Preview / map / sync / sample (replace FEED_ID)
|
|
Invoke-RestMethod -Method POST -Uri "$base/feeds/FEED_ID/extract-schema" -Headers $H -Body "{}"
|
|
# PUT mappings via --data-binary @file.json to avoid PowerShell quote mangling, then:
|
|
Invoke-RestMethod -Method POST -Uri "$base/feeds/FEED_ID/sync" -Headers $H -Body "{}"
|
|
Invoke-RestMethod -Method POST -Uri "$base/feeds/FEED_ID/sync-process-sample" -Headers $H -Body (@{
|
|
limit = 3; skip_sync = $true; processing_type = "normalize"
|
|
} | ConvertTo-Json)
|
|
```
|
|
|
|
Worker required: `scripts/run-api.ps1 worker` (or `bin/worker.exe`).
|
|
|
|
## Related
|
|
|
|
- [e2e-feeds-process-export.md](e2e-feeds-process-export.md) - map -> process -> export on existing demo feeds
|
|
- [qa-local-demo.md](qa-local-demo.md) - Local Demo Co checklist
|
|
- [demo-user.md](demo-user.md) - credentials
|
|
|