includio-cms 0.15.3 → 0.15.5
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/CHANGELOG.md +28 -0
- package/DOCS.md +6 -2
- package/ROADMAP.md +6 -0
- package/dist/admin/components/fields/media-field.svelte +54 -2
- package/dist/admin/components/media/file/file-details.svelte +65 -0
- package/dist/admin/remote/media.remote.d.ts +1 -0
- package/dist/admin/remote/media.remote.js +5 -0
- package/dist/cli/scaffold/admin.js +59 -0
- package/dist/cmp/types.d.ts +25 -0
- package/dist/cmp/types.js +1 -0
- package/dist/core/cms.d.ts +2 -0
- package/dist/core/cms.js +2 -0
- package/dist/core/server/cmp/getCountryFromHeaders.d.ts +10 -0
- package/dist/core/server/cmp/getCountryFromHeaders.js +30 -0
- package/dist/core/server/cmp/operations/create.d.ts +17 -0
- package/dist/core/server/cmp/operations/create.js +38 -0
- package/dist/core/server/cmp/operations/get.d.ts +2 -0
- package/dist/core/server/cmp/operations/get.js +8 -0
- package/dist/core/server/cmp/operations/list.d.ts +3 -0
- package/dist/core/server/cmp/operations/list.js +15 -0
- package/dist/core/server/cmp/truncateIpAddress.d.ts +7 -0
- package/dist/core/server/cmp/truncateIpAddress.js +57 -0
- package/dist/core/server/fields/resolveImageFields.d.ts +5 -0
- package/dist/core/server/fields/resolveImageFields.js +9 -1
- package/dist/core/server/forms/submissions/operations/create.js +11 -5
- package/dist/core/server/generator/generator.js +22 -6
- package/dist/core/server/media/operations/backgroundMaintenance.js +51 -20
- package/dist/core/server/media/operations/findMediaReferences.d.ts +16 -0
- package/dist/core/server/media/operations/findMediaReferences.js +60 -0
- package/dist/db-postgres/index.js +46 -1
- package/dist/db-postgres/schema/consentLog.d.ts +17 -0
- package/dist/db-postgres/schema/consentLog.js +4 -1
- package/dist/paraglide/messages/_index.d.ts +3 -36
- package/dist/paraglide/messages/_index.js +3 -71
- package/dist/paraglide/messages/hello_world.d.ts +5 -0
- package/dist/paraglide/messages/hello_world.js +33 -0
- package/dist/paraglide/messages/login_hello.d.ts +16 -0
- package/dist/paraglide/messages/login_hello.js +34 -0
- package/dist/paraglide/messages/login_please_login.d.ts +16 -0
- package/dist/paraglide/messages/login_please_login.js +34 -0
- package/dist/sveltekit/server/handle.js +1 -1
- package/dist/types/adapters/db.d.ts +7 -1
- package/dist/types/cms.d.ts +3 -0
- package/dist/types/consent.d.ts +11 -0
- package/dist/updates/0.15.4/index.d.ts +2 -0
- package/dist/updates/0.15.4/index.js +14 -0
- package/dist/updates/0.15.5/index.d.ts +2 -0
- package/dist/updates/0.15.5/index.js +15 -0
- package/dist/updates/index.js +3 -1
- package/package.json +1 -1
- package/dist/paraglide/messages/en.d.ts +0 -5
- package/dist/paraglide/messages/en.js +0 -14
- package/dist/paraglide/messages/pl.d.ts +0 -5
- package/dist/paraglide/messages/pl.js +0 -14
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,34 @@
|
|
|
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.15.5 — 2026-04-23
|
|
7
|
+
|
|
8
|
+
Media field recovers from orphan references; delete dialog shows usage breakdown + replace hint. X-Frame-Options relaxed to SAMEORIGIN. Background maintenance no longer duplicates on Vite HMR. Runtime generator no longer triggers an infinite SSR reload loop in dev.
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Admin media library: delete dialog (`FileDetails`) teraz pokazuje breakdown użyć pliku per kolekcja/single ("Plik jest używany w: Strony: 1") oraz hint wskazujący na funkcję **Zamień plik** (która zachowuje ID → wszystkie referencje). Dane ładowane asynchronicznie przez nowy remote query `findMediaReferences(id)` uruchamiany w momencie otwarcia dialogu. Scope (MVP): tylko najnowsza wersja per entry; historia poza zakresem. Walker po schematach (`media`, `file`, `seo.ogImage`, `object`, `blocks`, `content` z inline blocks) wyekstrahowany z `resolveImageFields.ts` jako reużywalne `extractMediaIdsFromData(data, fields)`.
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
- `media-field.svelte` nie blokuje już edycji entry gdy pole media wskazuje na usunięty plik (orphan reference). Wcześniej render wchodził w `{:else if singleFile}` z `singleFile=null` po nieudanym `getFileById`, co wyrzucało UI do pustego diva bez przycisków Zmień/Usuń — user zablokowany, nie mógł wstawić nowego obrazu. Nowa gałąź `{:else}` renderuje dashed warning placeholder ("Brakujący plik" / "Missing file") z zachowanymi kontrolkami. Analogicznie dla multi-media: per-item fallback pozwala usunąć pojedynczy orphan z tablicy bez czyszczenia pozostałych.
|
|
15
|
+
- `X-Frame-Options` zmieniony z `DENY` na `SAMEORIGIN` w middleware `securityHeaders`. Wcześniej `DENY` blokował nawet same-origin framing, przez co admin CMS nie mógł załadować preview entry w iframe (`previewUrl` w konfiguracji kolekcji/single). Safari egzekwuje to rygorystycznie ("Refused to display ... in a frame because it set X-Frame-Options to DENY"). `SAMEORIGIN` dalej chroni przed clickjackingiem z obcych domen.
|
|
16
|
+
- `startBackgroundMaintenance()` jest teraz idempotentne. Wcześniej każde wywołanie tworzyło nowy `setTimeout`/`setInterval` bez czyszczenia poprzedniego — w `pnpm dev` Vite HMR re-executuje `hooks.server.ts` (i tym samym `initCMS()`) przy każdej zmianie, więc po kilku edycjach działało N równoległych przebiegów maintenance. Stan timerów (`pendingTimeout`, `timer`, `running`, `lastResult`, `nextRunAt`) przeniesiony na `globalThis[Symbol.for("includio.maintenance.state")]`, żeby przeżył re-eval modułu w dev. Dodany guard: gdy timer już zaplanowany, kolejne `start()` loguje `already scheduled, skipping` i wychodzi. `stopBackgroundMaintenance()` teraz czyści również initial 30s `setTimeout`, nie tylko interval. Dodany `import.meta.hot.dispose()` czyszczący timery gdy Vite unlinkuje moduł.
|
|
17
|
+
- `generateRuntime()` (`generator.ts`) nie zapisuje już plików gdy treść się nie zmieniła. Wcześniej każdy wywołanie `includioCMS()` (a więc każdy SSR reload Vite) bezwarunkowo `writeFileSync` na 5 plikach w `src/lib/cms/runtime/` (`api.ts`, `types.ts`, `schemas.ts`, `schema.ts`, `remote.ts`) — co aktualizowało mtime, Vite wykrywał zmianę, robił `(ssr) page reload`, znów wołał `includioCMS()` → znów zapis → nieskończona pętla reload w `pnpm dev`, blokująca pracę. Nowy helper `writeIfChanged(filePath, content)` najpierw czyta plik i zapisuje wyłącznie gdy treść się różni.
|
|
18
|
+
|
|
19
|
+
## 0.15.4 — 2026-04-21
|
|
20
|
+
|
|
21
|
+
Forms: auto-scaffolded public submission endpoint + decoupled notification emails from submission success.
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
- CLI scaffold (`pnpm includio scaffold admin`) now emits `src/routes/api/forms/[slug]/submit/+server.ts` — the public POST endpoint for form submissions. Previously each project had to hand-roll this file (the handler lives in the library, but SvelteKit does not load routes from `node_modules`). New projects get it out-of-the-box; existing projects can run `includio scaffold admin` to generate it without overwriting other admin files.
|
|
25
|
+
- Added `ideas/health-check-module.md` — proposal for built-in `/api/health` + `/api/health/ready` endpoints, opt-in SMTP verify, and a ręczny "Test SMTP connection / Send test mail" section in the admin maintenance page. Context: diagnosing a silent SMTP misconfiguration in a live project required grepping through library internals; a one-click diagnostics panel would have surfaced the empty `EMAIL_HOST` immediately.
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
- `createFormSubmission()` now keeps the notification-email call in a separate `try/catch` from the DB write. Before: if SMTP was misconfigured (empty `EMAIL_HOST` locally, unreachable relay, etc.) the whole operation returned `false` → endpoint responded `500 "Submission failed"` even though the submission was already persisted. After: DB failure still returns `false` (critical path); email failure is logged via `console.error` and the submission succeeds with `200`.
|
|
29
|
+
|
|
30
|
+
### Notes
|
|
31
|
+
|
|
32
|
+
No SQL migration. No API signature changes. Existing projects that already have a hand-rolled `src/routes/api/forms/[slug]/submit/+server.ts` keep working — scaffold skips existing files unless `--force` is passed.
|
|
33
|
+
|
|
6
34
|
## 0.15.3 — 2026-04-16
|
|
7
35
|
|
|
8
36
|
Shop: InPost carrier adapter — Geowidget v5 picker + ShipX shipment + webhook auto-status.
|
package/DOCS.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Includio CMS Documentation (v0.15.
|
|
1
|
+
# Includio CMS Documentation (v0.15.5)
|
|
2
2
|
|
|
3
3
|
> This file is auto-generated from the docs site. For the latest version, update the package.
|
|
4
4
|
|
|
@@ -2743,9 +2743,13 @@ Forms can be submitted from your frontend via a public POST endpoint:
|
|
|
2743
2743
|
|
|
2744
2744
|
```
|
|
2745
2745
|
POST /api/forms/{slug}/submit
|
|
2746
|
-
Content-Type: multipart/form-data
|
|
2746
|
+
Content-Type: multipart/form-data # or application/json for file-less payloads
|
|
2747
2747
|
```
|
|
2748
2748
|
|
|
2749
|
+
> **Auto-generated endpoint:** Running `includio scaffold admin` generates `src/routes/api/forms/[slug]/submit/+server.ts` automatically — no manual setup required. To customize (extra middleware, logging, honeypot handling), edit the generated file; it won't be overwritten unless you re-run scaffold with `--force`.
|
|
2750
|
+
|
|
2751
|
+
> **Notification emails are best-effort:** If a form has `notificationEmailAddresses` set and email sending fails (e.g. misconfigured SMTP), the submission is still saved and the endpoint returns `200`. The error is logged to `console.error` — check server logs if you stop receiving notifications.
|
|
2752
|
+
|
|
2749
2753
|
### Submitting from Frontend
|
|
2750
2754
|
|
|
2751
2755
|
```typescript
|
package/ROADMAP.md
CHANGED
|
@@ -318,6 +318,12 @@
|
|
|
318
318
|
- [x] `[feature]` `[P2]` `inpostAdapter()` — Geowidget v5 (`<InpostPicker>` Svelte + raw config endpoint), ShipX shipment create + auto-buy + label PDF + cancel, webhook → status + tracking, per-shipping-method service config, customer tracking display in `<OrderStatus>` + email templates
|
|
319
319
|
- [x] `[chore]` `[P2]` Verbose logging on adapter auto-confirm flow (offer prep wait, buy POST, polling) for sandbox debugging
|
|
320
320
|
|
|
321
|
+
## 0.15.4 — Forms submission scaffold + best-effort notification emails
|
|
322
|
+
|
|
323
|
+
- [x] `[feature]` `[P1]` CLI scaffold emits `src/routes/api/forms/[slug]/submit/+server.ts` — public form submit endpoint auto-generated, no manual setup per project <!-- files: src/lib/cli/scaffold/admin.ts, src/lib/cli/scaffold/admin.spec.ts -->
|
|
324
|
+
- [x] `[fix]` `[P0]` `createFormSubmission` — split try/catch so SMTP failure no longer returns `false` (endpoint responded 500 even though submission was persisted); notification email is best-effort, logged via `console.error` <!-- files: src/lib/core/server/forms/submissions/operations/create.ts -->
|
|
325
|
+
- [ ] `[feature]` `[P1]` Built-in `/api/health` + `/api/health/ready` with per-adapter checks (db/files/email/ai) + ręczny SMTP diagnostics panel in maintenance page <!-- files: ideas/health-check-module.md -->
|
|
326
|
+
|
|
321
327
|
## 0.16.0 — SEO module
|
|
322
328
|
|
|
323
329
|
- [ ] `[feature]` `[P1]` SERP preview + character limits for title/description <!-- files: src/lib/admin/components/fields/seo-field.svelte -->
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
a11yMissingAudioDesc: string;
|
|
31
31
|
a11yMissingBoth: string;
|
|
32
32
|
a11yHint: string;
|
|
33
|
+
missingFile: string;
|
|
33
34
|
}
|
|
34
35
|
> = {
|
|
35
36
|
pl: {
|
|
@@ -41,7 +42,8 @@
|
|
|
41
42
|
a11yMissingTranscript: 'Brakuje transkrypcji',
|
|
42
43
|
a11yMissingAudioDesc: 'Brakuje audiodeskrypcji',
|
|
43
44
|
a11yMissingBoth: 'Brakuje transkrypcji i audiodeskrypcji',
|
|
44
|
-
a11yHint: 'Uzupełnij w bibliotece mediów'
|
|
45
|
+
a11yHint: 'Uzupełnij w bibliotece mediów',
|
|
46
|
+
missingFile: 'Brakujący plik'
|
|
45
47
|
},
|
|
46
48
|
en: {
|
|
47
49
|
selectMedia: 'Select media',
|
|
@@ -52,7 +54,8 @@
|
|
|
52
54
|
a11yMissingTranscript: 'Transcript missing',
|
|
53
55
|
a11yMissingAudioDesc: 'Audio description missing',
|
|
54
56
|
a11yMissingBoth: 'Transcript and audio description missing',
|
|
55
|
-
a11yHint: 'Add it in the media library'
|
|
57
|
+
a11yHint: 'Add it in the media library',
|
|
58
|
+
missingFile: 'Missing file'
|
|
56
59
|
}
|
|
57
60
|
};
|
|
58
61
|
|
|
@@ -195,6 +198,17 @@
|
|
|
195
198
|
</button>
|
|
196
199
|
{/snippet}
|
|
197
200
|
|
|
201
|
+
{#snippet missingPlaceholder()}
|
|
202
|
+
<div
|
|
203
|
+
class="flex aspect-square w-full flex-col items-center justify-center gap-2 rounded-2xl border-2 border-dashed border-warning/50 bg-warning/5 p-6"
|
|
204
|
+
>
|
|
205
|
+
<div class="rounded-full bg-warning/10 p-3">
|
|
206
|
+
<AlertTriangle class="h-6 w-6 text-warning" />
|
|
207
|
+
</div>
|
|
208
|
+
<span class="text-sm text-warning">{lang[interfaceLanguage.current].missingFile}</span>
|
|
209
|
+
</div>
|
|
210
|
+
{/snippet}
|
|
211
|
+
|
|
198
212
|
{#snippet mediaActions(onRemove: () => void)}
|
|
199
213
|
<div class="flex items-center justify-between gap-2 mt-1.5">
|
|
200
214
|
<Button size="sm" variant="secondary" class="h-8" onclick={openPicker}>
|
|
@@ -224,6 +238,9 @@
|
|
|
224
238
|
{@render imagePreview(file)}
|
|
225
239
|
{/if}
|
|
226
240
|
{@render mediaActions(() => { value = ''; })}
|
|
241
|
+
{:else}
|
|
242
|
+
{@render missingPlaceholder()}
|
|
243
|
+
{@render mediaActions(() => { value = ''; })}
|
|
227
244
|
{/if}
|
|
228
245
|
{:else if Array.isArray(value) && value.length > 0}
|
|
229
246
|
{@const valueArr = value}
|
|
@@ -262,7 +279,42 @@
|
|
|
262
279
|
{/if}
|
|
263
280
|
</div>
|
|
264
281
|
{@render mediaActions(() => { value = field.multiple ? [] : ''; })}
|
|
282
|
+
{:else}
|
|
283
|
+
<div class="relative">
|
|
284
|
+
{@render missingPlaceholder()}
|
|
285
|
+
{#if valueArr.length > 1}
|
|
286
|
+
<div class="absolute inset-x-0 top-1/2 flex -translate-y-1/2 justify-between px-1 pointer-events-none">
|
|
287
|
+
<button
|
|
288
|
+
type="button"
|
|
289
|
+
class="pointer-events-auto flex h-8 w-8 items-center justify-center rounded-full bg-white/80 backdrop-blur shadow-md transition hover:bg-white hover:scale-105 dark:bg-background/80 dark:hover:bg-background"
|
|
290
|
+
onclick={() => { currentIndex = currentIndex > 0 ? currentIndex - 1 : valueArr.length - 1; }}
|
|
291
|
+
>
|
|
292
|
+
<ChevronLeft class="h-5 w-5" />
|
|
293
|
+
</button>
|
|
294
|
+
<button
|
|
295
|
+
type="button"
|
|
296
|
+
class="pointer-events-auto flex h-8 w-8 items-center justify-center rounded-full bg-white/80 backdrop-blur shadow-md transition hover:bg-white hover:scale-105 dark:bg-background/80 dark:hover:bg-background"
|
|
297
|
+
onclick={() => { currentIndex = currentIndex < valueArr.length - 1 ? currentIndex + 1 : 0; }}
|
|
298
|
+
>
|
|
299
|
+
<ChevronRight class="h-5 w-5" />
|
|
300
|
+
</button>
|
|
301
|
+
</div>
|
|
302
|
+
<div class="absolute top-2 right-2 rounded-full bg-plum-darker/60 px-2 py-0.5 text-xs font-medium text-white backdrop-blur">
|
|
303
|
+
{currentIndex + 1} / {valueArr.length}
|
|
304
|
+
</div>
|
|
305
|
+
{/if}
|
|
306
|
+
</div>
|
|
307
|
+
{@render mediaActions(() => {
|
|
308
|
+
if (Array.isArray(value)) {
|
|
309
|
+
const next = value.filter((_, i) => i !== currentIndex);
|
|
310
|
+
value = field.multiple ? next : next[0] ?? '';
|
|
311
|
+
if (currentIndex >= next.length) currentIndex = Math.max(0, next.length - 1);
|
|
312
|
+
}
|
|
313
|
+
})}
|
|
265
314
|
{/if}
|
|
315
|
+
{:else}
|
|
316
|
+
{@render missingPlaceholder()}
|
|
317
|
+
{@render mediaActions(() => { value = field.multiple ? [] : ''; })}
|
|
266
318
|
{/if}
|
|
267
319
|
{/if}
|
|
268
320
|
</div>
|
|
@@ -31,6 +31,19 @@
|
|
|
31
31
|
let deleteDialogOpen = $state(false);
|
|
32
32
|
let videoError = $state(false);
|
|
33
33
|
|
|
34
|
+
type ReferenceResult = {
|
|
35
|
+
total: number;
|
|
36
|
+
byCollection: Array<{ collection: string; label: string; count: number; kind: 'collection' | 'single' }>;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const referencesQuery = $derived(
|
|
40
|
+
deleteDialogOpen ? remotes.findMediaReferences(file.id) : null
|
|
41
|
+
);
|
|
42
|
+
const referencesLoading = $derived(!!referencesQuery && !referencesQuery.ready);
|
|
43
|
+
const references = $derived(
|
|
44
|
+
referencesQuery && referencesQuery.ready ? (referencesQuery.current as ReferenceResult) : null
|
|
45
|
+
);
|
|
46
|
+
|
|
34
47
|
$effect(() => {
|
|
35
48
|
file.url;
|
|
36
49
|
videoError = false;
|
|
@@ -43,6 +56,12 @@
|
|
|
43
56
|
deleteConfirmTitle: string;
|
|
44
57
|
deleteConfirmDesc: string;
|
|
45
58
|
deleteCancel: string;
|
|
59
|
+
usedInLoading: string;
|
|
60
|
+
usedInTitle: string;
|
|
61
|
+
missingAfterDelete: string;
|
|
62
|
+
replaceHintBefore: string;
|
|
63
|
+
replaceHintCta: string;
|
|
64
|
+
replaceHintAfter: string;
|
|
46
65
|
fileNameLabel: string;
|
|
47
66
|
fileUrlLabel: string;
|
|
48
67
|
fileAltLabel: string;
|
|
@@ -81,6 +100,12 @@
|
|
|
81
100
|
deleteConfirmTitle: 'Usunąć plik?',
|
|
82
101
|
deleteConfirmDesc: 'Plik zostanie trwale usunięty.',
|
|
83
102
|
deleteCancel: 'Anuluj',
|
|
103
|
+
usedInLoading: 'Liczenie użyć…',
|
|
104
|
+
usedInTitle: 'Plik jest używany w:',
|
|
105
|
+
missingAfterDelete: 'Po usunięciu te pola zostaną oznaczone jako brakujące.',
|
|
106
|
+
replaceHintBefore: 'Jeśli chcesz tylko zmienić obraz, użyj funkcji',
|
|
107
|
+
replaceHintCta: 'Zamień plik',
|
|
108
|
+
replaceHintAfter: ' — zachowa wszystkie referencje.',
|
|
84
109
|
replaceFileLabel: 'Zamień plik',
|
|
85
110
|
fileNameLabel: 'Nazwa pliku',
|
|
86
111
|
fileUrlLabel: 'URL',
|
|
@@ -118,6 +143,12 @@
|
|
|
118
143
|
deleteConfirmTitle: 'Delete file?',
|
|
119
144
|
deleteConfirmDesc: 'The file will be permanently deleted.',
|
|
120
145
|
deleteCancel: 'Cancel',
|
|
146
|
+
usedInLoading: 'Counting usages…',
|
|
147
|
+
usedInTitle: 'This file is used in:',
|
|
148
|
+
missingAfterDelete: 'After deletion these fields will be marked as missing.',
|
|
149
|
+
replaceHintBefore: 'If you only want to change the image, use the',
|
|
150
|
+
replaceHintCta: 'Replace file',
|
|
151
|
+
replaceHintAfter: ' action — it keeps all references intact.',
|
|
121
152
|
fileNameLabel: 'File name',
|
|
122
153
|
fileUrlLabel: 'URL',
|
|
123
154
|
fileAltLabel: 'Alt text',
|
|
@@ -565,6 +596,40 @@
|
|
|
565
596
|
<AlertDialog.Content>
|
|
566
597
|
<AlertDialog.Title>{lang[interfaceLanguage.current].deleteConfirmTitle}</AlertDialog.Title>
|
|
567
598
|
<AlertDialog.Description>{lang[interfaceLanguage.current].deleteConfirmDesc}</AlertDialog.Description>
|
|
599
|
+
|
|
600
|
+
{#if referencesLoading}
|
|
601
|
+
<div class="mt-2 flex items-center gap-2 text-sm text-muted-foreground">
|
|
602
|
+
<div class="h-3 w-3 animate-pulse rounded-full bg-muted"></div>
|
|
603
|
+
<span>{lang[interfaceLanguage.current].usedInLoading}</span>
|
|
604
|
+
</div>
|
|
605
|
+
{:else if references && references.total > 0}
|
|
606
|
+
<div class="mt-2 space-y-3 text-sm">
|
|
607
|
+
<div class="rounded-md border border-warning/40 bg-warning/5 p-3">
|
|
608
|
+
<div class="flex items-start gap-2">
|
|
609
|
+
<AlertTriangle class="h-4 w-4 text-warning mt-0.5 shrink-0" />
|
|
610
|
+
<div class="flex-1 min-w-0">
|
|
611
|
+
<p class="font-medium text-foreground">{lang[interfaceLanguage.current].usedInTitle}</p>
|
|
612
|
+
<ul class="mt-1.5 space-y-0.5">
|
|
613
|
+
{#each references.byCollection as ref}
|
|
614
|
+
<li class="text-muted-foreground">
|
|
615
|
+
<span class="font-medium text-foreground">{ref.label}</span>: {ref.count}
|
|
616
|
+
</li>
|
|
617
|
+
{/each}
|
|
618
|
+
</ul>
|
|
619
|
+
<p class="mt-2 text-xs text-muted-foreground">{lang[interfaceLanguage.current].missingAfterDelete}</p>
|
|
620
|
+
</div>
|
|
621
|
+
</div>
|
|
622
|
+
</div>
|
|
623
|
+
<p class="text-xs text-muted-foreground">
|
|
624
|
+
{lang[interfaceLanguage.current].replaceHintBefore}
|
|
625
|
+
<span class="inline-flex items-center gap-1 rounded border border-border bg-muted/50 px-1.5 py-0.5 font-medium text-foreground">
|
|
626
|
+
<Replace class="h-3 w-3" />
|
|
627
|
+
{lang[interfaceLanguage.current].replaceHintCta}
|
|
628
|
+
</span>{lang[interfaceLanguage.current].replaceHintAfter}
|
|
629
|
+
</p>
|
|
630
|
+
</div>
|
|
631
|
+
{/if}
|
|
632
|
+
|
|
568
633
|
<AlertDialog.Footer>
|
|
569
634
|
<AlertDialog.Cancel>{lang[interfaceLanguage.current].deleteCancel}</AlertDialog.Cancel>
|
|
570
635
|
<AlertDialog.Action
|
|
@@ -33,6 +33,7 @@ export declare const getMediaTagsWithCounts: import("@sveltejs/kit").RemoteQuery
|
|
|
33
33
|
count: number;
|
|
34
34
|
}[]>;
|
|
35
35
|
export declare const getFileById: import("@sveltejs/kit").RemoteQueryFunction<string, MediaFile | null>;
|
|
36
|
+
export declare const findMediaReferences: import("@sveltejs/kit").RemoteQueryFunction<string, import("../../core/server/media/operations/findMediaReferences.js").MediaReferenceResult>;
|
|
36
37
|
export declare const deleteMediaFile: import("@sveltejs/kit").RemoteCommand<string, Promise<void>>;
|
|
37
38
|
export declare const bulkDeleteMediaFiles: import("@sveltejs/kit").RemoteCommand<{
|
|
38
39
|
ids: string[];
|
|
@@ -2,6 +2,7 @@ import { command, query } from '$app/server';
|
|
|
2
2
|
import { setAlt, renameMediaFile as renameMediaFileOperation, updateMediaAccessibility as updateMediaAccessibilityOp } from '../../core/server/media/operations/updateFile.js';
|
|
3
3
|
import z from 'zod';
|
|
4
4
|
import { deleteMediaFile as deleteMediaFileFn, bulkDeleteMediaFiles as bulkDeleteMediaFilesFn } from '../../core/server/media/operations/deleteMediaFile.js';
|
|
5
|
+
import { findMediaReferences as findMediaReferencesFn } from '../../core/server/media/operations/findMediaReferences.js';
|
|
5
6
|
import { getFile, getFiles, countFiles, getMediaTagsWithCounts as getMediaTagsWithCountsFn } from '../../core/server/media/operations/getFiles.js';
|
|
6
7
|
import { getMediaTags as getMediaTagsFn, createMediaTag as createMediaTagFn, updateMediaTag as updateMediaTagFn, deleteMediaTag as deleteMediaTagFn, setMediaFileTags as setMediaFileTagsFn, bulkSetMediaFileTags as bulkSetMediaFileTagsFn } from '../../core/server/media/operations/tags.js';
|
|
7
8
|
import { requireAuth } from './middleware/auth.js';
|
|
@@ -70,6 +71,10 @@ export const getMediaTagsWithCounts = query(async () => {
|
|
|
70
71
|
export const getFileById = query(z.string().uuid(), async (id) => {
|
|
71
72
|
return getFile(id);
|
|
72
73
|
});
|
|
74
|
+
export const findMediaReferences = query(z.string().uuid(), async (id) => {
|
|
75
|
+
requireAuth();
|
|
76
|
+
return findMediaReferencesFn(id);
|
|
77
|
+
});
|
|
73
78
|
export const deleteMediaFile = command(z.string().uuid(), async (id) => {
|
|
74
79
|
requireAuth();
|
|
75
80
|
return deleteMediaFileFn(id);
|
|
@@ -340,6 +340,65 @@ export const { GET, POST, PATCH, PUT, DELETE } = createAdminApiHandler();
|
|
|
340
340
|
import { createRestApiHandler } from 'includio-cms/admin/api/rest/handler';
|
|
341
341
|
|
|
342
342
|
export const { GET, POST, PUT, DELETE } = createRestApiHandler();
|
|
343
|
+
`
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
path: 'api/forms/[slug]/submit/+server.ts',
|
|
347
|
+
content: `${GENERATED_COMMENT_TS}
|
|
348
|
+
import { json } from '@sveltejs/kit';
|
|
349
|
+
import type { RequestHandler } from './$types';
|
|
350
|
+
import { createFormSubmission, parseFormDataForSubmission } from 'includio-cms/sveltekit/server';
|
|
351
|
+
import { getCMS } from 'includio-cms/core';
|
|
352
|
+
|
|
353
|
+
const counts = new Map<string, { count: number; resetAt: number }>();
|
|
354
|
+
const LIMIT = 5;
|
|
355
|
+
const WINDOW = 60 * 60 * 1000;
|
|
356
|
+
|
|
357
|
+
function checkRateLimit(ip: string): boolean {
|
|
358
|
+
const now = Date.now();
|
|
359
|
+
const entry = counts.get(ip);
|
|
360
|
+
if (!entry || now > entry.resetAt) {
|
|
361
|
+
counts.set(ip, { count: 1, resetAt: now + WINDOW });
|
|
362
|
+
return true;
|
|
363
|
+
}
|
|
364
|
+
if (entry.count >= LIMIT) return false;
|
|
365
|
+
entry.count++;
|
|
366
|
+
return true;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
export const POST: RequestHandler = async (event) => {
|
|
370
|
+
const slug = event.params.slug;
|
|
371
|
+
const ip = event.getClientAddress();
|
|
372
|
+
if (!checkRateLimit(ip)) return json({ error: 'Rate limit exceeded' }, { status: 429 });
|
|
373
|
+
|
|
374
|
+
const contentType = event.request.headers.get('content-type') || '';
|
|
375
|
+
const isMultipart = contentType.includes('multipart/form-data');
|
|
376
|
+
let data: Record<string, unknown>;
|
|
377
|
+
|
|
378
|
+
try {
|
|
379
|
+
if (isMultipart) {
|
|
380
|
+
const config = getCMS().getFormBySlug(slug);
|
|
381
|
+
const formData = await event.request.formData();
|
|
382
|
+
data = await parseFormDataForSubmission(formData, config.fields);
|
|
383
|
+
} else {
|
|
384
|
+
data = await event.request.json();
|
|
385
|
+
}
|
|
386
|
+
} catch (err) {
|
|
387
|
+
return json({ error: err instanceof Error ? err.message : 'Invalid request' }, { status: 400 });
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
try {
|
|
391
|
+
const success = await createFormSubmission({
|
|
392
|
+
slug,
|
|
393
|
+
data,
|
|
394
|
+
ip,
|
|
395
|
+
userAgent: event.request.headers.get('user-agent') || undefined
|
|
396
|
+
});
|
|
397
|
+
return success ? json({ success: true }) : json({ error: 'Submission failed' }, { status: 500 });
|
|
398
|
+
} catch (err) {
|
|
399
|
+
return json({ error: err instanceof Error ? err.message : 'Unknown error' }, { status: 400 });
|
|
400
|
+
}
|
|
401
|
+
};
|
|
343
402
|
`
|
|
344
403
|
}
|
|
345
404
|
];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface ResolvedCmpConfig {
|
|
2
|
+
enabled: boolean;
|
|
3
|
+
version: string;
|
|
4
|
+
policyVersion: string;
|
|
5
|
+
gtmConsentMode: boolean;
|
|
6
|
+
categories: {
|
|
7
|
+
analytics: boolean;
|
|
8
|
+
marketing: boolean;
|
|
9
|
+
preferences: boolean;
|
|
10
|
+
};
|
|
11
|
+
strings: Record<string, CmpStrings>;
|
|
12
|
+
}
|
|
13
|
+
export interface CmpStrings {
|
|
14
|
+
bannerTitle?: string;
|
|
15
|
+
bannerBody?: string;
|
|
16
|
+
acceptAll?: string;
|
|
17
|
+
rejectAll?: string;
|
|
18
|
+
customize?: string;
|
|
19
|
+
settingsTitle?: string;
|
|
20
|
+
save?: string;
|
|
21
|
+
necessary?: string;
|
|
22
|
+
analytics?: string;
|
|
23
|
+
marketing?: string;
|
|
24
|
+
preferences?: string;
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/core/cms.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import type { AIAdapter } from '../types/adapters/ai.js';
|
|
|
10
10
|
import type { EmailAdapter } from '../types/adapters/email.js';
|
|
11
11
|
import { betterAuth } from 'better-auth';
|
|
12
12
|
import type { ResolvedShopConfig } from '../shop/types.js';
|
|
13
|
+
import type { ResolvedCmpConfig } from '../cmp/types.js';
|
|
13
14
|
export declare class CMS implements ICMS {
|
|
14
15
|
private config;
|
|
15
16
|
databaseAdapter: DatabaseAdapter;
|
|
@@ -26,6 +27,7 @@ export declare class CMS implements ICMS {
|
|
|
26
27
|
typographyConfig: TypographyConfig;
|
|
27
28
|
sidebarHelp: boolean;
|
|
28
29
|
shopConfig: ResolvedShopConfig | null;
|
|
30
|
+
cmpConfig: ResolvedCmpConfig | null;
|
|
29
31
|
plugins: PluginConfig[];
|
|
30
32
|
customFields: Map<string, CustomFieldDefinition>;
|
|
31
33
|
apiKeys: ApiKeyConfig[];
|
package/dist/core/cms.js
CHANGED
|
@@ -20,6 +20,7 @@ export class CMS {
|
|
|
20
20
|
typographyConfig;
|
|
21
21
|
sidebarHelp;
|
|
22
22
|
shopConfig;
|
|
23
|
+
cmpConfig;
|
|
23
24
|
plugins = [];
|
|
24
25
|
customFields = new Map();
|
|
25
26
|
apiKeys = [];
|
|
@@ -34,6 +35,7 @@ export class CMS {
|
|
|
34
35
|
this.typographyConfig = config.typography || {};
|
|
35
36
|
this.sidebarHelp = config.sidebarHelp ?? true;
|
|
36
37
|
this.shopConfig = config.shop ?? null;
|
|
38
|
+
this.cmpConfig = config.cmp ?? null;
|
|
37
39
|
this.collections = {};
|
|
38
40
|
this.singles = {};
|
|
39
41
|
this.forms = {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract 2-letter ISO country code from request headers.
|
|
3
|
+
* Priority:
|
|
4
|
+
* 1. `cf-ipcountry` (Cloudflare)
|
|
5
|
+
* 2. `x-vercel-ip-country` (Vercel)
|
|
6
|
+
* 3. `x-country-code` (generic proxy)
|
|
7
|
+
* 4. Fallback: parse `Accept-Language` region subtag (e.g. `pl-PL` → `PL`)
|
|
8
|
+
* Returns 'XX' when no reliable source available.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getCountryFromHeaders(headers: Headers): string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract 2-letter ISO country code from request headers.
|
|
3
|
+
* Priority:
|
|
4
|
+
* 1. `cf-ipcountry` (Cloudflare)
|
|
5
|
+
* 2. `x-vercel-ip-country` (Vercel)
|
|
6
|
+
* 3. `x-country-code` (generic proxy)
|
|
7
|
+
* 4. Fallback: parse `Accept-Language` region subtag (e.g. `pl-PL` → `PL`)
|
|
8
|
+
* Returns 'XX' when no reliable source available.
|
|
9
|
+
*/
|
|
10
|
+
export function getCountryFromHeaders(headers) {
|
|
11
|
+
const providerCountry = headers.get('cf-ipcountry') ??
|
|
12
|
+
headers.get('x-vercel-ip-country') ??
|
|
13
|
+
headers.get('x-country-code');
|
|
14
|
+
if (providerCountry) {
|
|
15
|
+
const normalized = providerCountry.trim().toUpperCase();
|
|
16
|
+
if (/^[A-Z]{2}$/.test(normalized))
|
|
17
|
+
return normalized;
|
|
18
|
+
}
|
|
19
|
+
const acceptLanguage = headers.get('accept-language');
|
|
20
|
+
if (acceptLanguage) {
|
|
21
|
+
const first = acceptLanguage.split(',')[0].trim();
|
|
22
|
+
const region = first.split('-')[1] ?? first.split('_')[1];
|
|
23
|
+
if (region) {
|
|
24
|
+
const normalized = region.split(';')[0].trim().toUpperCase();
|
|
25
|
+
if (/^[A-Z]{2}$/.test(normalized))
|
|
26
|
+
return normalized;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return 'XX';
|
|
30
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { RequestEvent } from '@sveltejs/kit';
|
|
2
|
+
import type { ConsentLogData } from '../../../../types/consent.js';
|
|
3
|
+
export interface CreateCmpConsentLogInput {
|
|
4
|
+
consents: ConsentLogData['consents'];
|
|
5
|
+
consentModeStatus: ConsentLogData['consentModeStatus'];
|
|
6
|
+
parentLogId?: string | null;
|
|
7
|
+
}
|
|
8
|
+
export interface CreateCmpConsentLogResult {
|
|
9
|
+
id: string;
|
|
10
|
+
timestamp: Date;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Creates a consent log from a SvelteKit request event.
|
|
14
|
+
* Extracts IP/UA/URL/language from headers, truncates the IP,
|
|
15
|
+
* pulls cmpVersion/policyVersion from the CMS cmpConfig.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createCmpConsentLog(event: RequestEvent, input: CreateCmpConsentLogInput): Promise<CreateCmpConsentLogResult>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
+
import { getCMS } from '../../../cms.js';
|
|
3
|
+
import { truncateIpAddress } from '../truncateIpAddress.js';
|
|
4
|
+
import { getCountryFromHeaders } from '../getCountryFromHeaders.js';
|
|
5
|
+
/**
|
|
6
|
+
* Creates a consent log from a SvelteKit request event.
|
|
7
|
+
* Extracts IP/UA/URL/language from headers, truncates the IP,
|
|
8
|
+
* pulls cmpVersion/policyVersion from the CMS cmpConfig.
|
|
9
|
+
*/
|
|
10
|
+
export async function createCmpConsentLog(event, input) {
|
|
11
|
+
const cms = getCMS();
|
|
12
|
+
if (!cms.cmpConfig) {
|
|
13
|
+
throw new Error('CMP is not configured. Pass `cmp: defineCmp({...})` to your CMS config.');
|
|
14
|
+
}
|
|
15
|
+
const rawIp = event.request.headers.get('x-forwarded-for')?.split(',')[0]?.trim() ??
|
|
16
|
+
event.request.headers.get('x-real-ip') ??
|
|
17
|
+
event.getClientAddress();
|
|
18
|
+
const ipAddressTruncated = truncateIpAddress(rawIp);
|
|
19
|
+
const countryCode = getCountryFromHeaders(event.request.headers);
|
|
20
|
+
const language = event.request.headers.get('accept-language')?.split(',')[0]?.trim() ?? 'unknown';
|
|
21
|
+
const userAgent = event.request.headers.get('user-agent') ?? 'unknown';
|
|
22
|
+
const url = event.request.headers.get('referer') ?? event.url.toString();
|
|
23
|
+
const data = {
|
|
24
|
+
id: uuidv4(),
|
|
25
|
+
ipAddressTruncated,
|
|
26
|
+
countryCode,
|
|
27
|
+
language,
|
|
28
|
+
userAgent,
|
|
29
|
+
url,
|
|
30
|
+
consents: input.consents,
|
|
31
|
+
consentModeStatus: input.consentModeStatus,
|
|
32
|
+
cmpVersion: cms.cmpConfig.version,
|
|
33
|
+
policyVersion: cms.cmpConfig.policyVersion,
|
|
34
|
+
parentLogId: input.parentLogId ?? null
|
|
35
|
+
};
|
|
36
|
+
await cms.databaseAdapter.createConsentLog(data);
|
|
37
|
+
return { id: data.id, timestamp: new Date() };
|
|
38
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { getCMS } from '../../../cms.js';
|
|
2
|
+
export async function getConsentLog(id) {
|
|
3
|
+
const adapter = getCMS().databaseAdapter;
|
|
4
|
+
if (!adapter.getConsentLog) {
|
|
5
|
+
throw new Error('Database adapter does not implement getConsentLog. Use includio-cms db-postgres ≥ 0.16.0 or implement the method.');
|
|
6
|
+
}
|
|
7
|
+
return adapter.getConsentLog(id);
|
|
8
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ConsentLogRecord, GetConsentLogsFilters } from '../../../../types/consent.js';
|
|
2
|
+
export declare function getConsentLogs(filters?: GetConsentLogsFilters): Promise<ConsentLogRecord[]>;
|
|
3
|
+
export declare function countConsentLogs(filters?: Omit<GetConsentLogsFilters, 'limit' | 'offset'>): Promise<number>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getCMS } from '../../../cms.js';
|
|
2
|
+
export async function getConsentLogs(filters = {}) {
|
|
3
|
+
const adapter = getCMS().databaseAdapter;
|
|
4
|
+
if (!adapter.getConsentLogs) {
|
|
5
|
+
throw new Error('Database adapter does not implement getConsentLogs. Use includio-cms db-postgres ≥ 0.16.0 or implement the method.');
|
|
6
|
+
}
|
|
7
|
+
return adapter.getConsentLogs(filters);
|
|
8
|
+
}
|
|
9
|
+
export async function countConsentLogs(filters = {}) {
|
|
10
|
+
const adapter = getCMS().databaseAdapter;
|
|
11
|
+
if (!adapter.countConsentLogs) {
|
|
12
|
+
throw new Error('Database adapter does not implement countConsentLogs. Use includio-cms db-postgres ≥ 0.16.0 or implement the method.');
|
|
13
|
+
}
|
|
14
|
+
return adapter.countConsentLogs(filters);
|
|
15
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GDPR-compliant IP anonymization.
|
|
3
|
+
* IPv4: zero last octet (e.g. 192.168.1.42 → 192.168.1.0)
|
|
4
|
+
* IPv6: zero last 80 bits / keep /48 prefix (e.g. 2001:db8:abcd:1234::1 → 2001:db8:abcd::)
|
|
5
|
+
* Invalid input → 'unknown'
|
|
6
|
+
*/
|
|
7
|
+
export declare function truncateIpAddress(ip: string | null | undefined): string;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GDPR-compliant IP anonymization.
|
|
3
|
+
* IPv4: zero last octet (e.g. 192.168.1.42 → 192.168.1.0)
|
|
4
|
+
* IPv6: zero last 80 bits / keep /48 prefix (e.g. 2001:db8:abcd:1234::1 → 2001:db8:abcd::)
|
|
5
|
+
* Invalid input → 'unknown'
|
|
6
|
+
*/
|
|
7
|
+
export function truncateIpAddress(ip) {
|
|
8
|
+
if (!ip)
|
|
9
|
+
return 'unknown';
|
|
10
|
+
const trimmed = ip.trim();
|
|
11
|
+
if (!trimmed)
|
|
12
|
+
return 'unknown';
|
|
13
|
+
if (trimmed.includes('.') && !trimmed.includes(':')) {
|
|
14
|
+
return truncateIpv4(trimmed);
|
|
15
|
+
}
|
|
16
|
+
if (trimmed.includes(':')) {
|
|
17
|
+
return truncateIpv6(trimmed);
|
|
18
|
+
}
|
|
19
|
+
return 'unknown';
|
|
20
|
+
}
|
|
21
|
+
function truncateIpv4(ip) {
|
|
22
|
+
const parts = ip.split('.');
|
|
23
|
+
if (parts.length !== 4)
|
|
24
|
+
return 'unknown';
|
|
25
|
+
for (let i = 0; i < 4; i++) {
|
|
26
|
+
const n = Number(parts[i]);
|
|
27
|
+
if (!Number.isInteger(n) || n < 0 || n > 255)
|
|
28
|
+
return 'unknown';
|
|
29
|
+
}
|
|
30
|
+
return `${parts[0]}.${parts[1]}.${parts[2]}.0`;
|
|
31
|
+
}
|
|
32
|
+
function truncateIpv6(ip) {
|
|
33
|
+
const stripped = ip.split('%')[0];
|
|
34
|
+
const doubleColon = stripped.indexOf('::');
|
|
35
|
+
let groups;
|
|
36
|
+
if (doubleColon !== -1) {
|
|
37
|
+
const left = stripped.slice(0, doubleColon);
|
|
38
|
+
const right = stripped.slice(doubleColon + 2);
|
|
39
|
+
const leftGroups = left ? left.split(':') : [];
|
|
40
|
+
const rightGroups = right ? right.split(':') : [];
|
|
41
|
+
const missing = 8 - leftGroups.length - rightGroups.length;
|
|
42
|
+
if (missing < 0)
|
|
43
|
+
return 'unknown';
|
|
44
|
+
groups = [...leftGroups, ...Array(missing).fill('0'), ...rightGroups];
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
groups = stripped.split(':');
|
|
48
|
+
}
|
|
49
|
+
if (groups.length !== 8)
|
|
50
|
+
return 'unknown';
|
|
51
|
+
for (const g of groups) {
|
|
52
|
+
if (!/^[0-9a-fA-F]{0,4}$/.test(g))
|
|
53
|
+
return 'unknown';
|
|
54
|
+
}
|
|
55
|
+
const prefix = groups.slice(0, 3).map((g) => g.toLowerCase().replace(/^0+(?=.)/, '') || '0');
|
|
56
|
+
return `${prefix.join(':')}::`;
|
|
57
|
+
}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import type { EntryData, PopulatedEntryData } from '../../../types/entries.js';
|
|
2
2
|
import type { Field } from '../../../types/fields.js';
|
|
3
|
+
/**
|
|
4
|
+
* Walk entry data according to the field schema and collect all media file UUID references.
|
|
5
|
+
* Covers media/file/seo/object/blocks/content (incl. inline blocks inside content).
|
|
6
|
+
*/
|
|
7
|
+
export declare function extractMediaIdsFromData(data: EntryData, fields: Field[]): string[];
|
|
3
8
|
export declare function resolveMediaFields(data: EntryData, fields: Field[]): Promise<PopulatedEntryData>;
|