nca-ai-cms-astro-plugin 1.1.4 → 1.1.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/README.md CHANGED
@@ -85,6 +85,9 @@ ncaAiCms({
85
85
  | `/api/prompts` | Manage prompt templates |
86
86
  | `/api/scheduler` | Manage scheduled posts |
87
87
  | `/api/articles/*` | Article operations |
88
+ | `/api/db/export` | Export settings + prompts as JSON |
89
+ | `/api/db/import` | Import settings + prompts (merge/upsert) |
90
+ | `/api/db/download` | Download raw SQLite database backup |
88
91
 
89
92
  All `/api/*` and `/editor` routes are protected by cookie-based authentication.
90
93
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nca-ai-cms-astro-plugin",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/index.ts",
@@ -294,37 +294,40 @@ export function SettingsTab() {
294
294
  <div style={{ ...styles.plannerForm, flexDirection: 'row', alignItems: 'center' }}>
295
295
  <span style={{ ...styles.label, marginRight: 'auto' }}>Datenbank-Verwaltung</span>
296
296
  <a
297
- href="/api/db/download"
297
+ href="/api/db/export"
298
298
  style={{ ...styles.editButton, textDecoration: 'none', display: 'inline-flex', alignItems: 'center', gap: '0.4rem' }}
299
299
  >
300
- ↓ DB herunterladen
300
+ ↓ DB exportieren
301
301
  </a>
302
302
  <label style={{ ...styles.editButton, cursor: 'pointer', display: 'inline-flex', alignItems: 'center', gap: '0.4rem', margin: 0 }}>
303
- ↑ DB hochladen
303
+ ↑ DB importieren
304
304
  <input
305
305
  type="file"
306
- accept=".db,.sqlite,.sqlite3"
306
+ accept=".json"
307
307
  style={styles.srOnly}
308
308
  onChange={async (e) => {
309
309
  const file = e.target.files?.[0];
310
310
  if (!file) return;
311
- if (!confirm(`Datenbank "${file.name}" hochladen? Die aktuelle DB wird ueberschrieben.`)) {
311
+ if (!confirm(`Datenbank "${file.name}" importieren? Die aktuellen Daten werden ersetzt.`)) {
312
312
  e.target.value = '';
313
313
  return;
314
314
  }
315
- const formData = new FormData();
316
- formData.append('database', file);
317
315
  try {
318
- const res = await fetch('/api/db/upload', { method: 'POST', body: formData });
316
+ const text = await file.text();
317
+ JSON.parse(text);
318
+ const res = await fetch('/api/db/import', {
319
+ method: 'POST',
320
+ headers: { 'Content-Type': 'application/json' },
321
+ body: text,
322
+ });
319
323
  const data = await res.json();
320
324
  if (res.ok) {
321
- alert('Datenbank hochgeladen. Seite wird neu geladen.');
322
- window.location.reload();
325
+ loadData();
323
326
  } else {
324
- alert('Fehler: ' + (data.error || 'Upload fehlgeschlagen'));
327
+ alert('Fehler: ' + (data.error || 'Import fehlgeschlagen'));
325
328
  }
326
329
  } catch {
327
- alert('Upload fehlgeschlagen');
330
+ alert('Import fehlgeschlagen. Bitte eine gueltige JSON-Datei waehlen.');
328
331
  }
329
332
  e.target.value = '';
330
333
  }}
package/update.md CHANGED
@@ -1,3 +1,47 @@
1
+ # v1.1.5
2
+
3
+ ## Refactor: Settings import/export with merge semantics
4
+
5
+ ### New: JSON settings export/import endpoints
6
+ - `GET /api/db/export` — exports site settings and prompts as a JSON file download
7
+ - `POST /api/db/import` — imports settings and/or prompts with upsert (merge) semantics
8
+
9
+ ### Import features
10
+ - **Merge, not replace** — importing prompts won't delete your settings, importing settings won't delete your prompts
11
+ - **Partial import** — payload only needs to include the sections you want to update (`siteSettings`, `prompts`, or both)
12
+ - **No restart needed** — uses the live `astro:db` connection, no file replacement, no connection disruption
13
+ - **Validation** — payload is validated before import with clear error messages
14
+
15
+ ### Breaking: SQLite file upload removed
16
+ - `POST /api/db/upload` now returns `410 Gone` with migration instructions
17
+ - The old SQLite file upload caused infinite redirect loops by breaking the live DB connection
18
+ - Use `GET /api/db/export` + `POST /api/db/import` instead
19
+
20
+ ### Export format
21
+ ```json
22
+ {
23
+ "version": 1,
24
+ "exportedAt": "2026-03-24T12:00:00.000Z",
25
+ "siteSettings": [{ "key": "content.branche", "value": "Tech", "updatedAt": "..." }],
26
+ "prompts": [{ "id": "p1", "name": "Blog", "category": "content", "promptText": "...", "updatedAt": "..." }]
27
+ }
28
+ ```
29
+
30
+ ### Cleanup
31
+ - Removed dead `dbUploadUtils.ts` and its tests
32
+ - Upload test updated for 410 stub
33
+
34
+ ---
35
+
36
+ # v1.1.3 / v1.1.4
37
+
38
+ ## Internal: DB upload refactoring (superseded by v1.1.5)
39
+ - Extracted upload utilities to `dbUploadUtils.ts`
40
+ - Added `DbTransferService` with JSON export/import
41
+ - These versions contained intermediate work that was refined in v1.1.5
42
+
43
+ ---
44
+
1
45
  # v1.1.2
2
46
 
3
47
  ## Feature: Delete button in InlineEditor