@eutobias/serenojs 0.1.2 → 0.1.4

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 (46) hide show
  1. package/README.md +21 -6
  2. package/admin-dist/assets/index-CEMJnHOP.js +22 -0
  3. package/admin-dist/assets/index-Di8sAvwO.css +2 -0
  4. package/admin-dist/assets/marked.esm-BBttRptN.js +77 -0
  5. package/admin-dist/assets/purify.es-Bz-uQoIK.js +3 -0
  6. package/admin-dist/index.html +2 -2
  7. package/dist/config.d.ts +2 -2
  8. package/dist/core/backup.server.js +71 -4
  9. package/dist/core/db.server.js +29 -1
  10. package/dist/core/schema.js +8 -1
  11. package/dist/core/types.d.ts +15 -4
  12. package/dist/core/validation.js +61 -0
  13. package/dist/ui/admin/collection-manager.js +1 -1
  14. package/dist/ui/admin/display.js +7 -0
  15. package/dist/ui/admin/field-control.d.ts +3 -1
  16. package/dist/ui/admin/field-control.js +10 -2
  17. package/dist/ui/admin/i18n.js +26 -0
  18. package/dist/ui/admin/object-list-control.d.ts +15 -0
  19. package/dist/ui/admin/object-list-control.js +42 -0
  20. package/dist/ui/admin/rich-text-control.d.ts +15 -0
  21. package/dist/ui/admin/rich-text-control.js +62 -0
  22. package/dist/ui/admin/rich-text-icons.d.ts +8 -0
  23. package/dist/ui/admin/rich-text-icons.js +18 -0
  24. package/dist/ui/index.d.ts +1 -0
  25. package/dist/ui/index.js +1 -0
  26. package/dist/ui/markdown-preview.d.ts +10 -0
  27. package/dist/ui/markdown-preview.js +34 -0
  28. package/package.json +4 -1
  29. package/src/admin/styles.css +152 -0
  30. package/src/config.ts +2 -1
  31. package/src/core/backup.server.ts +81 -4
  32. package/src/core/db.server.ts +34 -1
  33. package/src/core/schema.ts +8 -1
  34. package/src/core/types.ts +18 -3
  35. package/src/core/validation.ts +71 -0
  36. package/src/ui/admin/collection-manager.tsx +1 -0
  37. package/src/ui/admin/display.tsx +13 -1
  38. package/src/ui/admin/field-control.tsx +43 -2
  39. package/src/ui/admin/i18n.tsx +28 -0
  40. package/src/ui/admin/object-list-control.tsx +154 -0
  41. package/src/ui/admin/rich-text-control.tsx +173 -0
  42. package/src/ui/admin/rich-text-icons.tsx +125 -0
  43. package/src/ui/index.ts +1 -0
  44. package/src/ui/markdown-preview.tsx +42 -0
  45. package/admin-dist/assets/index-D2m0Eb4k.css +0 -2
  46. package/admin-dist/assets/index-Ddgw58Iy.js +0 -9
package/README.md CHANGED
@@ -31,8 +31,9 @@ consumed by any frontend.
31
31
  and field labels from the schema are not translated.
32
32
  - **Headless-ready** — the REST API is the content delivery layer; the admin is
33
33
  only an editing client. Any frontend or stack can consume the content.
34
- - **Rich field types** — text, e-mail, textarea, number, boolean, select, date,
35
- relation, media, media-list and list.
34
+ - **Rich field types** — text, e-mail, textarea, richtext (Markdown),
35
+ number, boolean, select, date, relation, media, media-list, list and
36
+ object-list (array of objects).
36
37
  - **Content localization (i18n)** — localized fields stored per locale
37
38
  (`name_pt`, `name_en`, ...) with nested API/form values.
38
39
  - **Relations** — `one-to-one`, `one-to-many` and `many-to-many`, with cascade
@@ -61,8 +62,8 @@ Peer dependencies: `waku`, `react`, `react-dom`.
61
62
  ### Create a new project (recommended)
62
63
 
63
64
  The fastest way to start is the official starter. It generates a Waku app with
64
- the admin panel, REST API, auth, media, backups, SQLite configuration, a small
65
- todos example app and agent skills already wired up.
65
+ the admin panel, REST API, auth, media, backups, SQLite configuration, a
66
+ field-showcase example app and agent skills already wired up.
66
67
 
67
68
  ```sh
68
69
  npm create start-serenojs@latest my-app
@@ -314,6 +315,7 @@ Available icons: `archive`, `box`, `fileText`, `folder`, `grid`, `image`,
314
315
  | `relation` | `{ to, type }?` | `relation` | Target collection and relation type |
315
316
  | `accept` | `string[]?` | `media`, `media-list` | MIME types and/or extensions |
316
317
  | `maxSize` | `number?` | `media`, `media-list` | Maximum upload size in bytes |
318
+ | `fields` | `FieldDef[]?` | `object-list` | Subfields of each stored object |
317
319
 
318
320
  ### Field types
319
321
 
@@ -322,6 +324,7 @@ Available icons: `archive`, `box`, `fileText`, `folder`, `grid`, `image`,
322
324
  | `text` | string | yes | Single-line text |
323
325
  | `email` | string | yes | Validated e-mail |
324
326
  | `textarea` | string | yes | Multi-line text |
327
+ | `richtext` | string (Markdown) | yes | Markdown editor with toolbar and sanitized preview |
325
328
  | `number` | number | no | Uses `min`/`max` |
326
329
  | `boolean` | boolean | no | Stored as INTEGER `0`/`1` |
327
330
  | `select` | string | no | Requires `options` |
@@ -330,6 +333,12 @@ Available icons: `archive`, `box`, `fileText`, `folder`, `grid`, `image`,
330
333
  | `media` | string URL | no | One upload (`/files/...` or `/images/...`) |
331
334
  | `media-list` | `{ url, alt?, primary? }[]` | no | Ordered list; at most one `primary` |
332
335
  | `list` | string[] | yes | Ordered list of short strings |
336
+ | `object-list` | `Record<string, FieldValue>[]` | no | Ordered list of objects built from `fields` |
337
+
338
+ `object-list` subfields accept `text`, `email`, `textarea`, `number`,
339
+ `boolean`, `select`, `date` and `list`. Relations, media and nested
340
+ `object-list` fields are rejected inside an item. The stored value is JSON in a
341
+ TEXT column, so API clients send and receive a plain array of objects.
333
342
 
334
343
  Set `localized: false` on a `text` field to keep it language-independent (for
335
344
  example a slug).
@@ -349,9 +358,11 @@ example a slug).
349
358
 
350
359
  ### Content localization
351
360
 
352
- - Localized by default: `text`, `textarea`, `email`, `list`.
361
+ - Localized by default: `text`, `textarea`, `richtext`, `email`, `list`.
353
362
  - Never localized: `number`, `boolean`, `date`, `select`, `relation`, `media`,
354
363
  `media-list`.
364
+ - `object-list` is not localized by default; set `localized: true` to store one
365
+ array per locale. Its subfields are structural and never localized.
355
366
  - Storage uses one column per locale: `title_pt`, `title_en`, etc.
356
367
  - API and form values are nested:
357
368
 
@@ -613,13 +624,17 @@ curl -b cookies.txt -X PUT "http://localhost:3000/backup" --data-binary @backup.
613
624
  | `@eutobias/serenojs/config` | `defineCmsConfig`, `CollectionDef`, `FieldDef` and related types |
614
625
  | `@eutobias/serenojs/runtime` | `configureCms`, `getCmsConfig`, `getCollections` (server) |
615
626
  | `@eutobias/serenojs/server` | `createCmsMiddleware` |
616
- | `@eutobias/serenojs/ui` | Base UI components (`Box`, `Text`, `Button`, ...) |
627
+ | `@eutobias/serenojs/ui` | Base UI components (`Box`, `Text`, `Button`, ...) and client-only `MarkdownPreview` |
617
628
 
618
629
  ## Notes
619
630
 
620
631
  - The admin UI ships an English/Portuguese (BR) language selector. English is
621
632
  the default; the choice is stored in `localStorage`. Schema labels are not
622
633
  translated.
634
+ - `MarkdownPreview` from `@eutobias/serenojs/ui` renders a `richtext` value as
635
+ sanitized HTML (`marked` + `dompurify`, client-only). Style the
636
+ `.serenojs-markdown` container in the host; the starter CSS has a ready-made
637
+ block to copy.
623
638
  - The admin SPA is prebuilt (`admin-dist/`); host Tailwind does not need to scan
624
639
  the package.
625
640
  - The package is server-first: `dist/core/*.server.js` imports `node:sqlite`