includio-cms 0.22.0 → 0.24.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.
Files changed (36) hide show
  1. package/API.md +1 -1
  2. package/CHANGELOG.md +42 -0
  3. package/DOCS.md +1169 -146
  4. package/ROADMAP.md +5 -330
  5. package/dist/core/server/entries/operations/get.bench.d.ts +1 -0
  6. package/dist/core/server/entries/operations/get.bench.js +68 -0
  7. package/dist/core/server/entries/operations/get.js +17 -7
  8. package/dist/core/server/fields/utils/imageStyles.bench.d.ts +1 -0
  9. package/dist/core/server/fields/utils/imageStyles.bench.js +82 -0
  10. package/dist/core/server/fields/utils/imageStyles.js +49 -53
  11. package/dist/core/server/media/operations/backgroundMaintenance.d.ts +6 -0
  12. package/dist/core/server/media/operations/backgroundMaintenance.js +6 -1
  13. package/dist/core/server/media/styles/operations/getImageStyle.d.ts +7 -0
  14. package/dist/core/server/media/styles/operations/getImageStyle.js +24 -0
  15. package/dist/db-postgres/index.d.ts +1 -1
  16. package/dist/db-postgres/index.js +27 -0
  17. package/dist/paraglide/messages/_index.d.ts +36 -3
  18. package/dist/paraglide/messages/_index.js +71 -3
  19. package/dist/paraglide/messages/en.d.ts +5 -0
  20. package/dist/paraglide/messages/en.js +14 -0
  21. package/dist/paraglide/messages/pl.d.ts +5 -0
  22. package/dist/paraglide/messages/pl.js +14 -0
  23. package/dist/types/adapters/db.d.ts +16 -0
  24. package/dist/types/adapters/db.js +8 -1
  25. package/dist/updates/0.23.0/index.d.ts +2 -0
  26. package/dist/updates/0.23.0/index.js +21 -0
  27. package/dist/updates/0.24.0/index.d.ts +2 -0
  28. package/dist/updates/0.24.0/index.js +20 -0
  29. package/dist/updates/index.js +3 -1
  30. package/package.json +2 -1
  31. package/dist/paraglide/messages/hello_world.d.ts +0 -5
  32. package/dist/paraglide/messages/hello_world.js +0 -33
  33. package/dist/paraglide/messages/login_hello.d.ts +0 -16
  34. package/dist/paraglide/messages/login_hello.js +0 -34
  35. package/dist/paraglide/messages/login_please_login.d.ts +0 -16
  36. package/dist/paraglide/messages/login_please_login.js +0 -34
package/API.md CHANGED
@@ -1,4 +1,4 @@
1
- # includio-cms — Public API v0.22.0
1
+ # includio-cms — Public API v0.24.0
2
2
 
3
3
  > Auto-generated by `scripts/generate-api-md.ts`. Do not edit by hand.
4
4
 
package/CHANGELOG.md CHANGED
@@ -3,6 +3,48 @@
3
3
  All notable changes to includio-cms are documented here.
4
4
  Generated from `src/lib/updates/` — do not edit manually.
5
5
 
6
+ ## 0.24.0 — 2026-04-30
7
+
8
+ Faza 11 — Performance Pass. Eliminacja N+1 w render path: `getImageStylesBatch` (jeden SELECT zamiast N×getImageStyle dla styles + srcset wariantów) + `_getRawEntries` z batchowanym `getEntryVersions` (jeden call zamiast per-entry). Sharp srcset pipeline odrefactorowany — Promise.all wokół per-style queries usunięty (jeden batch + sequential Sharp generation z try/catch dla missing entries). Background maintenance lock potwierdzony testami (concurrent invocation skipped). Bench infra: nowy projekt vitest `bench` + skrypt `pnpm bench` + 2 representative benchmarks (image styles + raw entries).
9
+
10
+ ### Added
11
+ - `databaseAdapter.getImageStylesBatch(requests)` — nowa metoda adaptera. Zwraca `Map<key, ImageStyle>` keyed przez `imageStyleKey(mediaFileId, style)`. Implementacja `db-postgres`: jeden SELECT `WHERE mediaFileId IN (...)` + JS-side filter po (name, width, height, quality, aspectRatio) matching unique index. Skala impactu: 100 entries × 3 styles × 4 srcset = ~1200 queries → 1 query per media file (~30 queries dla 30 unique files). Bench `getImageStyles`: ~750 ops/s (1.3ms p75) dla 1 media × 3 styles × srcset; baseline N+1 (72 sequential): ~11 ops/s — **71× speedup**.
12
+ - `_getRawEntries()` (`src/lib/core/server/entries/operations/get.ts`) zrefactorowany — zamiast per-entry `getEntryVersions({ entryIds: [entry.id] })` w `Promise.all(dbEntries.map(...))` (N+1) teraz jeden `getEntryVersions({ entryIds: dbEntries.map(e => e.id) })` + group by `entryId` w Map. Adapter API bez zmian (już obsługiwał array `entryIds`). Skala: 100 entries → 2 queries zamiast 101. Bench: 387 ops/s (~2.6ms) dla 100 entries; baseline N+1 (101 sequential): ~7.9 ops/s — **50× speedup**.
13
+ - Sharp srcset variant generation: `Promise.all(widths.map(getImageStyle))` całkowicie wyeliminowany w `imageStyles.ts`. Nowy flow: zebrać wszystkie style requesty (base + srcset variants), jeden `getImageStylesBatch()` call, fallback do `createImageStyle()` per missing z try/catch. Konsekwencje: jeden Sharp timeout (30s, env `INCLUDIO_SHARP_TIMEOUT_MS`) nie zabija batch innych wariantów — zachowanie identyczne jak `Promise.allSettled`, ale bez Promise.all w pipeline.
14
+ - `getImageStylesBatch(requests)` operations wrapper (`src/lib/core/server/media/styles/operations/getImageStyle.ts`): koordynuje DB lookup + Sharp generation. Krótkie ścieżki: empty requests → empty Map bez DB call; wszystkie hity → cache return bez `createImageStyle`. Failed Sharp → `console.warn` + omission, nie throw.
15
+ - `imageStyleKey(mediaFileId, style)` — stabilna helper key z `$lib/types/adapters/db.js` (eksport public). Format: `${mediaFileId}|${name}|${width||0}|${height||0}|${quality||0}|${aspectRatio||0}` — matchuje unique index na `image_styles`.
16
+ - Background maintenance — in-process lock (`state.running` na `globalThis`) potwierdzony test suitem: `runMaintenance` exported (`@internal`), test concurrent dwóch wywołań → drugie loguje `Skipping — previous run still active`, batch operations wywołane dokładnie 1×. Komment w pliku: dla cluster mode wrap w `pg_advisory_lock`.
17
+ - `pnpm bench` — nowy skrypt + dedykowany vitest project `bench` (vite.config.ts). Include `src/**/*.bench.ts`. 2 nowe benchmarki: `imageStyles.bench.ts` (real `getImageStyles` z mocked adapter latency 1ms + synthetic N+1 vs batch comparison), `get.bench.ts` (real `_getRawEntries` 100 entries + comparison). Istniejący `resolveTypographyOrphans.bench.ts` teraz uruchamiany w tej samej komendzie.
18
+ - Lazy adapter imports (OpenAI / Anthropic / Nodemailer) — verified no-op. Wszystkie 3 adaptery (`src/lib/{ai-claude,ai-openai,email-nodemailer}/index.ts`) już używają `await import()` + cached singleton w closure. Type imports (`import type`) nie ładują runtime code. Trigger: pierwszy call metody adaptera (np. `generateAltText`, `sendMail`).
19
+
20
+ ### Breaking
21
+ - `DatabaseAdapter.getImageStylesBatch` — nowa **wymagana** metoda interfejsu (`src/lib/types/adapters/db.ts`). Custom adapters muszą zaimplementować. Sygnatura: `(requests: ImageStyleRequest[]) => Promise<Map<string, ImageStyle>>`. Reference impl: `src/lib/db-postgres/index.ts` (jeden SELECT z `inArray` po `mediaFileId` + JS filter). Helper key: `imageStyleKey(mediaFileId, style)` z `$lib/types/adapters/db.js`.
22
+
23
+ ### Notes
24
+
25
+ Zero schema migration — używa istniejącej tabeli `image_styles` i unique indeksu. Hot path render: collection list z 100 entries × image fields powinien zobaczyć ~50-70× redukcję wall-time queries (mierzone via bench na mocked latency 1ms; real PG latency wyższa, więc bezwzględne win większe). Sharp generation pozostaje sekwencyjne dla missing styles per request — celowo, żeby nie obciążać CPU; background maintenance batch (`batchGenerateAllStyles`) prewarmuje DB. `runMaintenance` eksportowany jako `@internal` dla testów — nie zaliczany do public API surface.
26
+
27
+ ## 0.23.0 — 2026-04-30
28
+
29
+ Faza 10 — Documentation Pass. DOCS.md uzupełniony (REST cURL + error codes, Entries error handling + transaction patterns, Admin UI a11y guide, Adapter Contracts z interfaces + peer deps + lazy import, Shop retry-payment lifecycle, edge cases dla number/boolean/date/datetime). Nowe sekcje: Stability Promise (semver, @public/@experimental/@internal, deprecation timeline) i Security Model (CSRF, CSP, rate-limit, API keys, link do KNOWN-RISKS.md). Migration Guide rozszerzony o master cheatsheet 0.x → 1.0 (agregat 0.16-0.22). ROADMAP cleanup: pre-v1.0 historia → ROADMAP-ARCHIVE.md.
30
+
31
+ ### Added
32
+ - `docs/stability-promise/` — nowa strona: SemVer 2.0, JSDoc tagi (@public semver-protected, @experimental opt-in to change, @internal poza kontraktem), deprecation timeline (1 minor cycle z @deprecated → remove w MAJOR), reference do `API.md` jako single source of truth public surface.
33
+ - `docs/security/` — nowa strona: threat model in/out of scope, CSRF (Origin/Referer guard na `/admin/api/*`), CSP (`default-src self`, `unsafe-inline` na script/style + uzasadnienie TipTap/Paraglide), rate limiting (200/60s admin, 5/h forms, env override), API keys (opt-in `expiresAt`, audit `rotatedAt`, `generateApiKey()`), Sharp 30s timeout, link do `KNOWN-RISKS.md` (5 zaakceptowanych ryzyk).
34
+ - `docs/migration/` — sekcja "Migrating from 0.x to 1.0 — master cheatsheet": global find-replace (getEntry → resolveEntry, language → locale), per-version blocks dla 0.16.0, 0.18.0, 0.19.0, 0.20.0, 0.21.0, 0.22.0 z migration steps + code examples, suggested upgrade path (pnpm + check + db:push + test).
35
+ - `docs/adapters/` — sekcja "Adapter contracts": tabela 4 interfaces (DatabaseAdapter 38 metod, FilesAdapter 5+3 optional, EmailAdapter 1+config, AIAdapter 1) z source paths, peer deps required vs optional, lazy import pattern (przykład `email-nodemailer`), error contracts, best practices (timeouts, retry, partial state).
36
+ - `docs/api/` — REST cURL examples (GET/POST/PUT/DELETE, upload), tabela error responses (HTTP × `CmsError.code`: UNAUTHORIZED, ENTRY_NOT_FOUND, INVALID_DATA, MISSING_REQUIRED_PARAM, RATE_LIMITED, etc.), authentication (Bearer header), opt-in `expiresAt` w API keys. Remote Functions section zaktualizowana na `resolveEntry/resolveEntries/countEntries`.
37
+ - `docs/entries/` — sekcja "Error handling" (CmsError instanceof + stable codes), sekcja "Transaction patterns" (last-write-wins versioning, custom Drizzle tx z `cms.db.driver`, plugin hooks vs partial failure). Querying przepisany na `resolveEntry/resolveEntries/countEntries` (status enum: published/draft/scheduled, archived = ops nie status).
38
+ - `docs/admin-ui/` — sekcja "Accessibility": WCAG 2.1 AA targets per surface (color contrast, keyboard nav, focus management, skip-link, heading hierarchy, ARIA roles, reduced motion), pattern dla custom plugin panels.
39
+ - `docs/shop/retry-payment/` — pełen lifecycle (5 kroków + ASCII diagram), server endpoint scaffold, headless SDK + `createOrderState`, error responses (400/401/404/409/429/502 z `CmsError.code`), constraints (same totals, token-gated, rate-limited, idempotent gateway, no auto-retry), admin override.
40
+ - `docs/fields/{number,boolean,date,datetime}/` — sekcje "Edge cases": number (NaN/Infinity rejection, floating-point precision, integer-only via step:1, parseFloat guards), boolean (null vs false, no string coercion, defaultValue vs runtime backfill), date (no timezone, ISO-8601 calendar string, null handling, edge years), datetime (UTC storage + local render, DST traps, ISO datetime validation).
41
+ - `ROADMAP-ARCHIVE.md` (root) — pełna historia 0.0.69 → 0.16.0 wycięta z `ROADMAP.md`. `ROADMAP.md` zawiera od teraz wyłącznie v1.0+ (header + legenda + v1.0 + v1.x + Security + Backlog), z linkiem do archive.
42
+ - `_config/nav.ts` + `scripts/compile-docs.ts` — zsynchronizowane: dodane "Stability Promise" w Guides, "Security Model" w "Authentication & Security" (renamed z "Authentication"). Brakujący "InPost Carrier" w nav.ts dodany dla parity z compile-docs.
43
+
44
+ ### Notes
45
+
46
+ Brak code changes — only docs + ROADMAP cleanup. DOCS.md regeneruje się przez `pnpm docs:compile` (część `prepublishOnly`). Po publikacji pełen TOC widoczny w DOCS.md z 10 zaktualizowanymi/nowymi sekcjami. Dla user-facing changes — żadnych. Dla devów customizujących admin UI lub piszących adaptery — pełny stable contract w jednym miejscu.
47
+
6
48
  ## 0.22.0 — 2026-04-30
7
49
 
8
50
  Faza 9 — DX & config validation pass. `defineConfig()` waliduje config strict Zodem z czytelnymi błędami (path + hint), resolvery / operacje throwują typowane `CmsError` z `code` + `context`, CLI ma `--help` per subcommand i `--version`, README przepisany pod nowych userów (system requirements + 5-min quickstart), `.env.example` rozszerzony o wszystkie `INCLUDIO_*` envy, JSDoc na każdym `@public` symbolu (opis + `@param` + `@returns` + `@example`).