@oktis-works/cms 0.10.9 → 0.10.10

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.
@@ -0,0 +1,33 @@
1
+ -- +migrate Up
2
+ -- Repairs content bodies stored as double-encoded jsonb strings.
3
+ --
4
+ -- The demo seed historically inserted the body document with
5
+ -- `to_jsonb($5::text)` after `JSON.stringify`, which wraps the document as a
6
+ -- jsonb STRING (the JSON text becomes the string value) instead of a jsonb
7
+ -- object. The theme renderer then received the raw JSON text and rendered an
8
+ -- empty body. Fixed at the source in the same release; this migration repairs
9
+ -- existing rows.
10
+ --
11
+ -- Safe/idempotent: only rows with jsonb_typeof(body) = 'string' whose inner
12
+ -- text parses as a JSON object/array are converted. Plain-text string bodies
13
+ -- and already-correct rows are left untouched, so re-running is a no-op.
14
+
15
+ DO $$
16
+ DECLARE
17
+ row_record RECORD;
18
+ inner_text text;
19
+ BEGIN
20
+ FOR row_record IN
21
+ SELECT id, body FROM content WHERE jsonb_typeof(body) = 'string'
22
+ LOOP
23
+ inner_text := row_record.body #>> '{}';
24
+ IF inner_text IS NOT NULL AND btrim(inner_text) ~ '^[\{\[]' THEN
25
+ BEGIN
26
+ UPDATE content SET body = inner_text::jsonb WHERE id = row_record.id;
27
+ EXCEPTION WHEN OTHERS THEN
28
+ -- inner text looked like a document but is not valid JSON — keep it
29
+ NULL;
30
+ END;
31
+ END IF;
32
+ END LOOP;
33
+ END $$;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oktis-works/cms",
3
- "version": "0.10.9",
3
+ "version": "0.10.10",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -22,10 +22,10 @@
22
22
  "dependencies": {
23
23
  "@oktis-works/auth": "^0.7.7",
24
24
  "@oktis-works/config": "^0.6.4",
25
- "@oktis-works/core": "^0.11.1",
26
- "@oktis-works/database": "^0.12.0",
25
+ "@oktis-works/core": "^0.11.2",
26
+ "@oktis-works/database": "^0.12.1",
27
27
  "@oktis-works/validation": "^0.7.0",
28
- "@oktis-works/theme-runtime": "^0.8.0"
28
+ "@oktis-works/theme-runtime": "^0.8.1"
29
29
  },
30
30
  "devDependencies": {
31
31
  "typescript": "5.7.3"