@eutobias/serenojs 0.1.1 → 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.
- package/README.md +30 -11
- package/admin-dist/assets/index-CEMJnHOP.js +22 -0
- package/admin-dist/assets/index-Di8sAvwO.css +2 -0
- package/admin-dist/assets/marked.esm-BBttRptN.js +77 -0
- package/admin-dist/assets/purify.es-Bz-uQoIK.js +3 -0
- package/admin-dist/index.html +2 -2
- package/dist/config.d.ts +9 -2
- package/dist/config.js +1 -0
- package/dist/core/backup.server.d.ts +5 -2
- package/dist/core/backup.server.js +346 -12
- package/dist/core/db.server.js +29 -1
- package/dist/core/schema-codegen.server.d.ts +17 -0
- package/dist/core/schema-codegen.server.js +155 -0
- package/dist/core/schema.js +8 -1
- package/dist/core/types.d.ts +15 -4
- package/dist/core/validation.js +61 -0
- package/dist/ui/admin/collection-manager.js +1 -1
- package/dist/ui/admin/display.js +7 -0
- package/dist/ui/admin/field-control.d.ts +3 -1
- package/dist/ui/admin/field-control.js +10 -2
- package/dist/ui/admin/i18n.js +30 -4
- package/dist/ui/admin/object-list-control.d.ts +15 -0
- package/dist/ui/admin/object-list-control.js +42 -0
- package/dist/ui/admin/rich-text-control.d.ts +15 -0
- package/dist/ui/admin/rich-text-control.js +62 -0
- package/dist/ui/admin/rich-text-icons.d.ts +8 -0
- package/dist/ui/admin/rich-text-icons.js +18 -0
- package/dist/ui/index.d.ts +1 -0
- package/dist/ui/index.js +1 -0
- package/dist/ui/markdown-preview.d.ts +10 -0
- package/dist/ui/markdown-preview.js +34 -0
- package/package.json +4 -1
- package/src/admin/styles.css +152 -0
- package/src/config.ts +6 -1
- package/src/core/backup.server.ts +435 -17
- package/src/core/db.server.ts +34 -1
- package/src/core/schema-codegen.server.ts +187 -0
- package/src/core/schema.ts +8 -1
- package/src/core/types.ts +18 -3
- package/src/core/validation.ts +71 -0
- package/src/ui/admin/collection-manager.tsx +1 -0
- package/src/ui/admin/display.tsx +13 -1
- package/src/ui/admin/field-control.tsx +43 -2
- package/src/ui/admin/i18n.tsx +32 -4
- package/src/ui/admin/object-list-control.tsx +154 -0
- package/src/ui/admin/rich-text-control.tsx +173 -0
- package/src/ui/admin/rich-text-icons.tsx +125 -0
- package/src/ui/index.ts +1 -0
- package/src/ui/markdown-preview.tsx +42 -0
- package/admin-dist/assets/index-B3EgqtT6.js +0 -9
- package/admin-dist/assets/index-D2m0Eb4k.css +0 -2
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,
|
|
35
|
-
relation, media, media-list and
|
|
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
|
|
@@ -40,8 +41,8 @@ consumed by any frontend.
|
|
|
40
41
|
- **Authentication** — opaque cookie sessions (no JWT), rotating refresh tokens,
|
|
41
42
|
user management and CSRF protection for unsafe requests.
|
|
42
43
|
- **Media uploads** — type/size validation, safe file serving and media lists.
|
|
43
|
-
- **Backups** — consistent SQLite snapshot
|
|
44
|
-
restore and an optional periodic scheduler.
|
|
44
|
+
- **Backups** — collection schemas, a consistent SQLite snapshot and assets in
|
|
45
|
+
a single archive, with restore and an optional periodic scheduler.
|
|
45
46
|
|
|
46
47
|
## Stack / requirements
|
|
47
48
|
|
|
@@ -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
|
|
65
|
-
|
|
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
|
|
@@ -121,6 +122,7 @@ export default defineCmsConfig({
|
|
|
121
122
|
media: { path: "/media" },
|
|
122
123
|
files: { path: "/files" },
|
|
123
124
|
backup: { path: "/backup", enabled: true, intervalHours: 24, keep: 10 },
|
|
125
|
+
schemas: { path: "src/schemas" },
|
|
124
126
|
db: { path: ".data/admin.db" },
|
|
125
127
|
});
|
|
126
128
|
```
|
|
@@ -221,6 +223,7 @@ can render them directly. For localized content, parse the nested values:
|
|
|
221
223
|
| `backup.enabled` | `true` | Enable the periodic backup scheduler |
|
|
222
224
|
| `backup.intervalHours` | `24` | Scheduler interval |
|
|
223
225
|
| `backup.keep` | `10` | Number of stored backups to keep |
|
|
226
|
+
| `schemas.path` | `"src/schemas"` | Host directory where restore writes the schema modules |
|
|
224
227
|
| `db.path` | `".data/admin.db"` | SQLite file path |
|
|
225
228
|
|
|
226
229
|
The package also reads these environment variables:
|
|
@@ -312,6 +315,7 @@ Available icons: `archive`, `box`, `fileText`, `folder`, `grid`, `image`,
|
|
|
312
315
|
| `relation` | `{ to, type }?` | `relation` | Target collection and relation type |
|
|
313
316
|
| `accept` | `string[]?` | `media`, `media-list` | MIME types and/or extensions |
|
|
314
317
|
| `maxSize` | `number?` | `media`, `media-list` | Maximum upload size in bytes |
|
|
318
|
+
| `fields` | `FieldDef[]?` | `object-list` | Subfields of each stored object |
|
|
315
319
|
|
|
316
320
|
### Field types
|
|
317
321
|
|
|
@@ -320,6 +324,7 @@ Available icons: `archive`, `box`, `fileText`, `folder`, `grid`, `image`,
|
|
|
320
324
|
| `text` | string | yes | Single-line text |
|
|
321
325
|
| `email` | string | yes | Validated e-mail |
|
|
322
326
|
| `textarea` | string | yes | Multi-line text |
|
|
327
|
+
| `richtext` | string (Markdown) | yes | Markdown editor with toolbar and sanitized preview |
|
|
323
328
|
| `number` | number | no | Uses `min`/`max` |
|
|
324
329
|
| `boolean` | boolean | no | Stored as INTEGER `0`/`1` |
|
|
325
330
|
| `select` | string | no | Requires `options` |
|
|
@@ -328,6 +333,12 @@ Available icons: `archive`, `box`, `fileText`, `folder`, `grid`, `image`,
|
|
|
328
333
|
| `media` | string URL | no | One upload (`/files/...` or `/images/...`) |
|
|
329
334
|
| `media-list` | `{ url, alt?, primary? }[]` | no | Ordered list; at most one `primary` |
|
|
330
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.
|
|
331
342
|
|
|
332
343
|
Set `localized: false` on a `text` field to keep it language-independent (for
|
|
333
344
|
example a slug).
|
|
@@ -347,9 +358,11 @@ example a slug).
|
|
|
347
358
|
|
|
348
359
|
### Content localization
|
|
349
360
|
|
|
350
|
-
- Localized by default: `text`, `textarea`, `email`, `list`.
|
|
361
|
+
- Localized by default: `text`, `textarea`, `richtext`, `email`, `list`.
|
|
351
362
|
- Never localized: `number`, `boolean`, `date`, `select`, `relation`, `media`,
|
|
352
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.
|
|
353
366
|
- Storage uses one column per locale: `title_pt`, `title_en`, etc.
|
|
354
367
|
- API and form values are nested:
|
|
355
368
|
|
|
@@ -485,10 +498,12 @@ extensions are always blocked. The default maximum size is 10 MB unless
|
|
|
485
498
|
| `PUT` | `/backup` | Restore a raw `.serenojs` archive body |
|
|
486
499
|
| `DELETE` | `/backup?name=<file>` | Delete a stored backup |
|
|
487
500
|
|
|
488
|
-
All backup endpoints require authentication. A backup contains
|
|
489
|
-
SQLite snapshot plus files under
|
|
501
|
+
All backup endpoints require authentication. A backup contains the collection
|
|
502
|
+
schemas (`src/schemas`), a consistent SQLite snapshot plus files under
|
|
503
|
+
`public/images` and `public/files`. Restoring rewrites the schema modules,
|
|
490
504
|
replaces the live tables in a transaction and rewrites assets; it may invalidate
|
|
491
|
-
the current session.
|
|
505
|
+
the current session. Backups created by older versions without embedded schemas
|
|
506
|
+
have their descriptors reconstructed from the database tables.
|
|
492
507
|
|
|
493
508
|
## API examples
|
|
494
509
|
|
|
@@ -609,13 +624,17 @@ curl -b cookies.txt -X PUT "http://localhost:3000/backup" --data-binary @backup.
|
|
|
609
624
|
| `@eutobias/serenojs/config` | `defineCmsConfig`, `CollectionDef`, `FieldDef` and related types |
|
|
610
625
|
| `@eutobias/serenojs/runtime` | `configureCms`, `getCmsConfig`, `getCollections` (server) |
|
|
611
626
|
| `@eutobias/serenojs/server` | `createCmsMiddleware` |
|
|
612
|
-
| `@eutobias/serenojs/ui` | Base UI components (`Box`, `Text`, `Button`, ...) |
|
|
627
|
+
| `@eutobias/serenojs/ui` | Base UI components (`Box`, `Text`, `Button`, ...) and client-only `MarkdownPreview` |
|
|
613
628
|
|
|
614
629
|
## Notes
|
|
615
630
|
|
|
616
631
|
- The admin UI ships an English/Portuguese (BR) language selector. English is
|
|
617
632
|
the default; the choice is stored in `localStorage`. Schema labels are not
|
|
618
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.
|
|
619
638
|
- The admin SPA is prebuilt (`admin-dist/`); host Tailwind does not need to scan
|
|
620
639
|
the package.
|
|
621
640
|
- The package is server-first: `dist/core/*.server.js` imports `node:sqlite`
|