@brightsideoy/kama 1.0.0-alpha.3 → 1.0.0-alpha.31

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 (111) hide show
  1. package/README.md +25 -7
  2. package/bin/cli.js +539 -359
  3. package/content/definitions/blocks/button.yaml +15 -5
  4. package/content/definitions/blocks/form.yaml +20 -0
  5. package/content/definitions/blocks/image-gallery.yaml +34 -0
  6. package/content/definitions/blocks/node-list.yaml +75 -0
  7. package/content/definitions/blocks/youtube.yaml +8 -0
  8. package/content/definitions/field-sets/access.yaml +14 -0
  9. package/content/definitions/field-sets/page-base.yaml +19 -1
  10. package/content/definitions/forms/.gitkeep +0 -0
  11. package/content/definitions/forms/contact.yaml +38 -0
  12. package/content/definitions/forms/subscription.yaml +26 -0
  13. package/content/definitions/nodes/article.yaml +19 -1
  14. package/content/definitions/taxonomies/categories.yaml +5 -2
  15. package/content/definitions/taxonomies/media-tag.yaml +15 -0
  16. package/content/definitions/taxonomies/tags.yaml +5 -2
  17. package/definitions/editor/default.ts +19 -2
  18. package/dist/assets/AssetEditor-CAvQEsBT.js +1 -0
  19. package/dist/assets/AssetEditor-CQtKSOjX.css +1 -0
  20. package/dist/assets/CmsAccordion-91I5Rx5D.css +1 -0
  21. package/dist/assets/CmsAccordion-BgdaB8QZ.js +1 -0
  22. package/dist/assets/CmsBadge-BT2jTJUu.js +1 -0
  23. package/dist/assets/CmsBadge-Ip5hXw8G.css +1 -0
  24. package/dist/assets/CmsButton-DATGQeoC.css +1 -0
  25. package/dist/assets/CmsButton-DnhPsHXA.js +1 -0
  26. package/dist/assets/CmsFieldTaxonomy-CNY3-MbD.js +1 -0
  27. package/dist/assets/CmsFieldTaxonomy-CVlKL-l2.css +1 -0
  28. package/dist/assets/CmsHelp-BO_vWABq.css +1 -0
  29. package/dist/assets/CmsHelp-DtPeURCv.js +1 -0
  30. package/dist/assets/CmsImagePreview-BhM7S_v8.js +1 -0
  31. package/dist/assets/CmsImagePreview-CujwG8r_.css +1 -0
  32. package/dist/assets/CmsPublisher-BcrQAr1m.css +1 -0
  33. package/dist/assets/CmsPublisher-DiQhfPID.js +3 -0
  34. package/dist/assets/CmsUserCenter-CAaiCweN.js +1 -0
  35. package/dist/assets/CmsUserCenter-D3OZYHD0.css +1 -0
  36. package/dist/assets/EditorSplitPreview-BfGni85I.js +1 -0
  37. package/dist/assets/EditorSplitPreview-CMoTjLW5.css +1 -0
  38. package/dist/assets/FormsWorkspace-CGs6eUjz.css +1 -0
  39. package/dist/assets/FormsWorkspace-CUK-y2dR.js +2 -0
  40. package/dist/assets/NodeContextMenu-C5RTK0sr.js +1 -0
  41. package/dist/assets/NodeContextMenu-Cj-2TvQC.css +1 -0
  42. package/dist/assets/NodeEditor-C2meZIvc.css +1 -0
  43. package/dist/assets/NodeEditor-C5VQu52a.js +161 -0
  44. package/dist/assets/SettingsDashboard-XBOgYUn3.css +1 -0
  45. package/dist/assets/SettingsDashboard-gzHzxsIc.js +1 -0
  46. package/dist/assets/StatusPill-Dlm6uvGe.css +1 -0
  47. package/dist/assets/StatusPill-HY1gCP9c.js +1 -0
  48. package/dist/assets/TrashWorkspace-DtMgxg13.css +1 -0
  49. package/dist/assets/TrashWorkspace-t0lOrFRK.js +1 -0
  50. package/dist/assets/_plugin-vue_export-helper-BK_c4R_m.js +5 -0
  51. package/dist/assets/circle-check-CksZGUB7.js +1 -0
  52. package/dist/assets/database--QlkzG9u.js +1 -0
  53. package/dist/assets/file-U7h4eOhG.js +1 -0
  54. package/dist/assets/globe-TuZP0v6A.js +1 -0
  55. package/dist/assets/history-CIbqkRx3.js +1 -0
  56. package/dist/assets/index-C171UGo4.css +1 -0
  57. package/dist/assets/index-_Tc6Vb8T.js +14 -0
  58. package/dist/assets/layers-BwACvD_U.js +1 -0
  59. package/dist/assets/loader-circle-DYEFqbD4.js +1 -0
  60. package/dist/assets/panel-left-close-Cpq52HZy.js +1 -0
  61. package/dist/assets/plus-7rv1C56N.js +1 -0
  62. package/dist/assets/preload-helper-BB8Wl1va.js +1 -0
  63. package/dist/assets/preload-helper-BxFQpwa9.css +1 -0
  64. package/dist/assets/rotate-ccw-DvjWccJd.js +1 -0
  65. package/dist/assets/save-Dwhm8QNL.js +1 -0
  66. package/dist/assets/schema-helpers-uuDCw8Rb.js +1 -0
  67. package/dist/assets/send-Bs4eROle.js +1 -0
  68. package/dist/assets/smartphone-i429gh5p.js +1 -0
  69. package/dist/assets/trash-2-BbKTm8cC.js +1 -0
  70. package/dist/assets/useCmsState-CDENPbKL.js +1 -0
  71. package/dist/assets/useNodes-D-Vuwq5_.js +1 -0
  72. package/dist/assets/user-DKryA1QU.js +1 -0
  73. package/dist/assets/x-DOWbsdzd.js +1 -0
  74. package/dist/build-seed.js +495 -0
  75. package/dist/{dist-cK3xGnBZ.js → dist-DKRU6nhX.js} +9254 -5762
  76. package/dist/index.html +32 -2
  77. package/dist/index.js +9179 -5689
  78. package/dist/nodemailer-Ccic7tRm-Dw2jwzbm.js +7877 -0
  79. package/dist/nodemailer-Ccic7tRm.js +7908 -0
  80. package/dist/rolldown-runtime-B0aSnxlc.js +20 -0
  81. package/dist/schema-compiler.js +1 -1
  82. package/documentation/FORMS.md +261 -0
  83. package/documentation/SCHEMAS.md +450 -119
  84. package/package.json +14 -6
  85. package/schema.sql +46 -1
  86. package/templates/astro-starter/astro-preview-dev-integration.mjs +83 -0
  87. package/templates/astro-starter/astro.config.mjs +11 -0
  88. package/templates/astro-starter/src/components/blocks/BlockRenderer.astro +17 -0
  89. package/templates/astro-starter/src/components/blocks/Form.astro +313 -0
  90. package/templates/astro-starter/src/components/blocks/HeaderImage.astro +6 -12
  91. package/templates/astro-starter/src/components/blocks/ImageBlock.astro +5 -6
  92. package/templates/astro-starter/src/components/blocks/NodeList.astro +274 -0
  93. package/templates/astro-starter/src/components/global/NavigationMenu.astro +17 -8
  94. package/templates/astro-starter/src/components/ui/KamaImage.astro +13 -5
  95. package/templates/astro-starter/src/layouts/StandardLayout.astro +4 -3
  96. package/templates/astro-starter/src/lib/cms-fetch.ts +22 -0
  97. package/templates/astro-starter/src/lib/cms.ts +18 -9
  98. package/templates/astro-starter/src/lib/media/kama-image-service.ts +15 -4
  99. package/templates/astro-starter/src/lib/media/media-proxy.ts +22 -3
  100. package/templates/astro-starter/src/lib/media/media-url.ts +17 -3
  101. package/templates/astro-starter/src/middleware.ts +199 -71
  102. package/templates/astro-starter/src/pages/[...slug].astro +122 -45
  103. package/templates/astro-starter/src/pages/api/forms/[...path].ts +57 -0
  104. package/templates/astro-starter/src/pages/api/load-nodes.ts +68 -0
  105. package/templates/astro-starter/src/pages/api/partials/node-cards.astro +98 -0
  106. package/templates/astro-starter/src/pages/partials/nav.astro +6 -5
  107. package/templates/kama-worker/index.js +22 -12
  108. package/templates/kama-worker/setup-local-db.mjs +17 -0
  109. package/wrangler.json +19 -0
  110. package/dist/assets/index-C3LzwJjY.css +0 -1
  111. package/dist/assets/index-DhguVxzs.js +0 -164
@@ -1,182 +1,513 @@
1
- # Kama CMS Schema Documentation
1
+ # Kama Schema Reference
2
+
3
+ Kama schemas are YAML files compiled into the CMS definitions bundle. The bundle
4
+ drives the editor, page canvas, database synchronization, and public field
5
+ filtering. This document describes the options the current compiler and UI
6
+ recognize, including fields, crop presets, layouts, and reusable field sets.
7
+
8
+ The compiler is intentionally permissive: it does not reject every unknown
9
+ property. Custom properties can survive compilation, but they have no built-in
10
+ effect unless Kama code or an extension reads them. The options below are the
11
+ ones with current built-in behavior.
12
+
13
+ ## 1. Schema locations and build
14
+
15
+ Use `content/definitions/` in a workspace. The compiler also supports
16
+ `definitions/` as a fallback. A scaffolded project includes copies of Kama's
17
+ starter definitions; edit those project files to customize them.
18
+
19
+ | Directory | Definition |
20
+ | --- | --- |
21
+ | `nodes/` | Content types such as pages, articles, and products |
22
+ | `blocks/` | Canvas blocks such as text, image, and hero components |
23
+ | `node-layouts/` | Page canvas grid templates and their regions |
24
+ | `block-layouts/` | Nested layouts used as blocks inside regions |
25
+ | `trees/` | Navigation tree types and their fields |
26
+ | `channels/` | Channel types and their fields |
27
+ | `taxonomies/` | Taxonomy types and term fields |
28
+ | `field-sets/` | Reusable field definitions |
29
+ | `forms/` | Public form definitions; see [FORMS.md](./FORMS.md) |
30
+
31
+ The filename (without `.yaml` or `.yml`) is the default schema ID. An explicit
32
+ `id` overrides it. Use stable IDs because other schemas refer to IDs for layouts,
33
+ blocks, trees, channels, and taxonomies.
34
+
35
+ After changing definitions, compile them before running or deploying the worker:
36
+
37
+ ```sh
38
+ # In a Kama workspace
39
+ npx kama bundle
40
+
41
+ # When building the Kama package itself
42
+ npm run bundle:definitions
43
+ npm run build:schema
44
+ ```
45
+
46
+ In a workspace, `npx kama bundle` writes
47
+ `kama-worker/bundled-definitions.js`; it is generated and should not be edited
48
+ by hand. `npm run build` in the Kama package runs the package bundling and
49
+ build steps.
50
+
51
+ ### YAML reuse and merge behavior
2
52
 
3
- Kama CMS uses a highly dynamic, YAML-driven schema system. Instead of hardcoding database tables and React/Vue forms, you define your content models, layouts, and components using simple YAML files. The Kama build pipeline automatically generates the admin UI, database indexes, and API endpoints based on these definitions.
53
+ - `!include relative/path.yaml` includes a YAML file relative to the including
54
+ file. It is commonly used to create tabs from field sets.
55
+ - `fieldSet: name` imports a field set's fields. A field set can be listed in
56
+ a schema's `fieldSets` array or used in a `fields` / tab `fields` list.
57
+ - Inline field definitions are merged over imported field definitions; inline
58
+ values override matching values from a field set.
59
+ - The compiler resolves YAML merge keys (`<<`) as well.
4
60
 
5
- Here is the complete guide to understanding, overriding, and creating custom schemas in your Kama project.
61
+ ## 2. Definition types and root options
6
62
 
7
- ## 1. Directory Structure: What Goes Where?
63
+ All definitions accept `id` and `label`. `description` is used as explanatory
64
+ text in relevant block pickers and editor views. The compiler also preserves
65
+ other root properties, but they only do something if a consumer supports them.
8
66
 
9
- Your project’s schemas live in the `content/definitions/` (or `schemas/`) directory. The folder structure dictates how the CMS interprets the YAML file:
67
+ ### Nodes
10
68
 
11
- | Directory | Purpose | Example Use Case |
12
- | :---------------- | :---------------------------------------------------------------- | :----------------------------------------------------------- |
13
- | `/nodes/` | Standalone content entities (Pages, Articles, Products, Persons). | A blog post, a product page, or an office location. |
14
- | `/blocks/` | Reusable content components placed on a page canvas. | A hero banner, a text block, a call-to-action button. |
15
- | `/node-layouts/` | Page-level CSS Grid templates that define regions (drop zones). | A standard landing page, a 3-column layout with a sidebar. |
16
- | `/block-layouts/` | Component-level layout wrappers for grouping blocks. | A 50/50 split column block. |
17
- | `/channels/` | Top-level endpoints (websites, apps, stores). | A primary marketing website or a secondary e-commerce store. |
18
- | `/trees/` | Hierarchical structures for navigation and routing. | Main menu, footer links, social links. |
19
- | `/field-sets/` | Reusable groupings of fields to keep your YAML DRY. | Standard SEO fields, Access/Visibility settings. |
69
+ ```yaml
70
+ id: article
71
+ label: Article
72
+ inTree: false
73
+ inVault: true
74
+ hasCanvas: true
75
+ directLinking: true
76
+ titleTemplate: "{title}"
77
+ defaultLayout: content
78
+ allowedBlocks: "*"
79
+ tabs: {}
80
+ ```
20
81
 
21
- ## 2. Overriding and Adding Custom Schemas
82
+ | Option | Meaning |
83
+ | --- | --- |
84
+ | `inTree` | Allows this node type to be placed in a tree. Defaults to `false` in the compiled schema. |
85
+ | `inVault` | Shows this node type in the content vault. Defaults to `true`. |
86
+ | `hasCanvas` | Enables the visual canvas. Defaults to `false`. |
87
+ | `directLinking` | Makes nodes of this type available as direct node links. |
88
+ | `titleTemplate` | Fallback display-title template; `{fieldName}` placeholders refer to node fields. An explicit non-empty `title` field takes precedence. |
89
+ | `defaultLayout` | Layout ID used when a node has no selected layout. |
90
+ | `allowedBlocks` | Block and nested-layout IDs allowed on the canvas. Use `"*"` or an array of IDs. Defaults to `"*"`. |
91
+ | `disallowedBlocks` | IDs excluded from the canvas. Accepts `"*"` or an array. |
92
+ | `fields`, `tabs`, `fieldSets` | Define the editor fields; see [Fields and tabs](#4-fields-and-tabs). |
22
93
 
23
- The Kama schema pipeline merges core package defaults with your local project files.
94
+ ### Blocks
24
95
 
25
- ### How to Override a Core Schema
96
+ Blocks use `id`, `label`, `description`, `fields`, and optionally `fieldSets`.
97
+ `group` labels the block group in the insert palette. Blocks can be used as
98
+ canvas components; a block's `fields` define its editor controls.
26
99
 
27
- To modify a default Kama schema (e.g., `page.yaml` or `address.yaml`), create a file with the **exact same name** in your local workspace:
28
- `your-project/content/definitions/nodes/page.yaml`
100
+ ### Node layouts and block layouts
29
101
 
30
- During the build process (`npm run bundle:schemas`), the local file completely overwrites the core package file.
102
+ Layouts use `layout` and `regions`; see [Canvas layouts and regions](#8-canvas-layouts-and-regions).
103
+ They may also have `id`, `label`, `description`, `group`, `fields`, and `tabs`.
104
+ Block layouts are nested, reusable canvas components.
31
105
 
32
- ### How to Add a Custom Schema
106
+ ### Trees, channels, and taxonomies
33
107
 
34
- To create a completely new content type (e.g., a Job Posting), simply add a new file:
35
- `your-project/content/definitions/nodes/job-posting.yaml`
108
+ These entity types accept `id`, `label`, `fields`, `tabs`, and `fieldSets`.
36
109
 
37
- Run `npm run deploy:cms` to deploy the worker. The CMS will automatically register the new schema, create database indexes, and generate the UI.
110
+ - A channel schema may specify `tableName`; the default is `channels`.
111
+ - A taxonomy schema may include `hierarchical`; the compiler preserves this
112
+ property. The current taxonomy editor does not use it to change term editing
113
+ behavior.
114
+ - A tree schema's fields configure tree-level settings. Node fields shown in
115
+ tree output are controlled separately by field-level `inTree` and `public`.
38
116
 
39
- ## 3. Schema Anatomy (Top-Level Parameters)
117
+ ### Forms
40
118
 
41
- Every YAML file represents a Schema object. Below are the top-level parameters you can define at the root of your YAML file.
119
+ Forms are definitions in `forms/`, not node schemas. Their fields, settings,
120
+ and finishers are documented in [FORMS.md](./FORMS.md).
42
121
 
43
- ### Base Parameters
122
+ ## 3. Fields and tabs
44
123
 
45
- - `id` _(string)_: Unique identifier. Should match the filename (e.g., `image_card`).
46
- - `label` _(string)_: Human-readable name displayed in the CMS Admin UI.
47
- - `description` _(string)_: Optional subtext shown in block pickers or menus.
124
+ Fields can be declared as a map or as a list of field entries. Tabs are a map
125
+ whose keys are stable tab IDs and whose `label` is the editor label.
48
126
 
49
- ### Node/Content Behaviors
127
+ ```yaml
128
+ tabs:
129
+ settings:
130
+ label: Settings
131
+ fields:
132
+ title:
133
+ label: Page title
134
+ type: text
135
+ required: true
136
+ fieldSet: page-seo
137
+ access: !include ../field-sets/access.yaml
138
+ ```
50
139
 
51
- - `inTree` _(boolean)_: If `true`, this node can be created in the "Site Tree" (usually for pages/routes).
52
- - `inVault` _(boolean)_: If `true`, this node appears in the "Vault" (usually for structured data like Products, Addresses, Persons).
53
- - `hasCanvas` _(boolean)_: If `true`, enables the visual drag-and-drop page builder for this node.
54
- - `directLinking` _(boolean)_: If `true`, the node is resolvable to a frontend URL/slug (e.g., an Article or Page).
140
+ The list form is also supported:
55
141
 
56
- ### Layout & Canvas Restrictions
142
+ ```yaml
143
+ tabs:
144
+ settings:
145
+ label: Page
146
+ fields:
147
+ - fieldSet: page-base
148
+ - subtitle:
149
+ label: Subtitle
150
+ type: textarea
151
+ public: true
152
+ ```
57
153
 
58
- - `defaultLayout` _(string)_: The fallback layout ID if none is selected (e.g., `"single-column"`).
59
- - `allowedLayouts` _(array)_: List of layout IDs this node is permitted to use.
60
- - `allowedBlocks` _(array)_: Restricts which blocks can be dropped onto this node's canvas (e.g., `[header, hero, text, image_card]`).
154
+ A field set can be a plain map of fields or an object with `label`, `fields`,
155
+ and optional `tab` metadata. A field set can also carry node defaults such as
156
+ `inTree`, `inVault`, or `hasCanvas`.
157
+
158
+ ## 4. Field types
159
+
160
+ `type` selects the editor control. If omitted, the field is treated as text.
161
+ The aliases below are the current controls in the dynamic editor.
162
+
163
+ | `type` | Editor behavior and related options |
164
+ | --- | --- |
165
+ | `text`, `string` | Single-line text. |
166
+ | `textarea` | Multiline text. |
167
+ | `richtext`, `editor`, `wysiwyg`, `html` | TipTap rich-text editor. Set `editor` or `rteType` to a registered editor profile. |
168
+ | `password` | Password input. |
169
+ | `email` | Email input. |
170
+ | `phone`, `tel` | Telephone input. |
171
+ | `url` | URL input. |
172
+ | `number`, `integer`, `float` | Numeric input. `integer` defaults to step `1`; `step`, `min`, and `max` can customize the control. |
173
+ | `boolean` | Toggle. `variant` or `switchType` selects the visual style (`primary`, `success`, or `danger`). |
174
+ | `date`, `datetime` | Date or local date-time input. Defaults also accept `now`, `today`, and relative values such as `+2 days` or `-1 month`. |
175
+ | `slug` | Slug input with auto-generation from `linkedTo` fields until an editor unlinks it. |
176
+ | `select`, `pills` | Single or multiple choice; see [Choices](#5-field-options-and-validation). |
177
+ | `layout-select` | Selects a node layout; supports `allowedLayouts`, `options`, and `inheritsFromParent`. |
178
+ | `language-select` | Searchable locale selector; supports `multiple`. |
179
+ | `link` | Link picker; filter kinds with `allowedLinkTypes` or `linkTypes`. |
180
+ | `node`, `relation` | Node relation picker; filter types with `allowedNodeTypes` or `nodeTypes`; supports `multiple`. |
181
+ | `taxonomy` | Term picker; set `taxonomy` (or `taxonomyKey`) and optionally `multiple`. |
182
+ | `node-sort` | Sort field and direction control. Values are strings such as `updatedAt_desc`. |
183
+ | `icon` | Iconify icon picker; `packages` can limit installed icon collections. |
184
+ | `asset`, `media`, `image` | Media picker; supports upload limits and crop presets. See [Images, cropping, and media](#7-images-cropping-and-media). |
185
+ | `hidden` | Excluded from the standard dynamic form. Use for system data, not an editor-visible field. |
186
+
187
+ Unsupported `type` values are preserved as schema data but do not automatically
188
+ create a new control. Use a custom component or extend the editor for new field
189
+ types.
190
+
191
+ ## 5. Field options and validation
192
+
193
+ ### Common field properties
194
+
195
+ | Property | Behavior |
196
+ | --- | --- |
197
+ | `label` | Editor label; defaults to the field key. |
198
+ | `type` | Editor control; see the table above. |
199
+ | `default` | Initial value for the field. Date fields also accept relative defaults. |
200
+ | `placeholder` | Input placeholder where the control supports one. |
201
+ | `required` | Required flag. It can also be set at `rules.required`. |
202
+ | `rules` | Validation rules; see below. |
203
+ | `public` | Mark `true` to expose the value through public APIs. Keep private values false or omit them. |
204
+ | `inTree` | Expose the field in tree node data; public tree output also requires `public: true`. |
205
+ | `dbType` | Storage type for schema/database synchronization: `text`, `integer`, `real`, or `json`. This is separate from the editor `type`. |
206
+ | `index` | Requests a generated index for eligible node JSON fields. Core columns such as `slug` are indexed separately. |
207
+ | `primaryKey` | Marks a database field as a primary key where dynamic table generation applies. |
208
+ | `unique` | Top-level shortcut for the uniqueness rule. |
209
+ | `position: sidebar` | Places block fields in the block settings sidebar instead of the main field list. |
210
+ | `liveSync` | For supported node fields, saves the change immediately instead of waiting for the normal publish/save flow. |
211
+ | `linkedTo` | Comma-separated source field keys for slug generation, e.g. `"menuTitle,title"`. |
212
+ | `inherits` | Copies a sibling/related field value while the editor's inheritance link is enabled. |
213
+ | `inheritsFromParent` | Enables parent-node inheritance behavior, used by layout fields. |
214
+ | `cacheInvalidation` | Cache scope on publish: `page`, `tree`, `channel`, or `global`. Omitted means `page`; details below. |
215
+ | `multiple` | Enables multiple selections or assets for controls that support it. |
216
+ | `description` | Preserved as schema metadata. The generic dynamic field form does not currently render a field helper-text line. |
217
+
218
+ ### Choice fields
219
+
220
+ `select` and `pills` accept `options` as scalar values or `{label, value}`
221
+ objects. Grouped select options use `{label, choices: [...]}`:
61
222
 
62
- ### Grid & Regions (For Layouts)
223
+ ```yaml
224
+ status:
225
+ type: select
226
+ default: draft
227
+ options:
228
+ - label: Draft
229
+ value: draft
230
+ - label: Published
231
+ value: published
232
+ ```
63
233
 
64
- Used primarily in `/node-layouts/` and `/block-layouts/`.
234
+ To load options from a JSON endpoint, use `optionsEndpoint`, with optional
235
+ `optionsValueKey` and `optionsLabelKey` (defaults: `value` and `label`). For
236
+ multiple choices, set `multiple: true`; the stored value is an array.
65
237
 
66
- - `layout`: Defines the CSS Grid structure.
67
- - `columns` _(string)_: CSS grid-template-columns (e.g., `"10fr 4fr"`).
68
- - `areas` _(array of arrays)_: Maps regions to the grid layout.
69
- - `regions`: Configuration for the specific drop zones defined in the `areas`.
70
- - `label` _(string)_: UI label for the drop zone.
71
- - `showLabel` _(boolean)_: Shows/hides the header in the editor.
72
- - `inherit` _(string)_: Can inherit content from `"parent"`.
238
+ For `link`, supported kinds are `tree`, `node`, `url`, `file`, `email`, and
239
+ `telephone`. For `node` / `relation`, use `nodeTypes` or `allowedNodeTypes` to
240
+ restrict the picker.
73
241
 
74
- ## 4. Tabs & Fields Architecture
242
+ ### Validation rules
75
243
 
76
- Content input in Kama is organized into **Tabs**, which contain **Fields**.
244
+ Place rules under `rules`; `required` may also be top-level:
77
245
 
78
246
  ```yaml
79
- tabs:
80
- settings: # Tab ID
81
- label: "Settings" # Tab UI Name
82
- fields:
83
- # Key-Value map of fields
84
- title:
85
- label: "Title"
86
- type: "text"
87
- required: true
247
+ slug:
248
+ type: slug
249
+ linkedTo: title
250
+ required: true
251
+ rules:
252
+ pattern: "^[a-z0-9_-]+$"
253
+ uniqueSibling: true
254
+ customMessage: "Use lowercase letters, numbers, hyphens, or underscores."
88
255
  ```
89
256
 
90
- ## 5. Field Types (`type`)
257
+ Built-in rules are:
258
+
259
+ - `required`: rejects empty values.
260
+ - `min` / `max`: numeric bounds for numbers and length bounds for strings.
261
+ - `pattern`: JavaScript regular expression.
262
+ - `email`: enables email-format validation for a value.
263
+ - `unique` / `uniqueSibling`: uniqueness checks handled by the save/conflict
264
+ flow. `uniqueMessage` can customize the conflict message.
265
+ - `customMessage`: shared message used for rule failures.
91
266
 
92
- The `type` parameter determines the UI component used in the CMS and how data is handled.
267
+ For numeric controls, top-level `min`, `max`, and `step` also set HTML input
268
+ attributes. Use `rules.min` and `rules.max` when validation is required.
93
269
 
94
- - `text`: Standard single-line text input.
95
- - `textarea`: Multi-line text input.
96
- - `richtext`: WYSIWYG editor. (Use `editor: "minimal"`, `"default"`, or `"button"` to configure toolbars).
97
- - `number`: Numeric input.
98
- - `boolean`: Toggle switch.
99
- - `date` / `datetime`: Date/Time picker.
100
- - `slug`: URL-friendly string generator. Often paired with `linkedTo: "title"`.
101
- - `select`: Dropdown menu. (Requires an `options` array).
102
- - `layout-select`: Specialized dropdown that queries available layout schemas.
103
- - `language-select`: Specialized dropdown for locales.
104
- - `link`: A unified link picker (internal nodes, trees, URLs, files, emails, tel).
105
- - `icon`: Icon picker. (Configure with `packages: ["heroicons", "lucide"]`).
106
- - `asset` / `image`: Cloudflare R2 media uploader.
107
- - `hidden`: Hidden from the UI, used for programmatic data.
270
+ Custom validators can be registered in `definitions/validators/*.ts`. Export a
271
+ validator function named after the rule, or use a default export named after
272
+ the file. It receives the value, rule value, field definition, and validation
273
+ context; return an error string or an empty string, synchronously or
274
+ asynchronously.
108
275
 
109
- ## 6. Field Configuration Parameters
276
+ ### Cache invalidation
110
277
 
111
- Inside a specific field, you can define how it looks, validates, and behaves in the database.
278
+ `cacheInvalidation` controls how far a publish purges cache entries for a
279
+ changed field. The broadest configured scope among changed fields wins.
112
280
 
113
- ### UI & Display
281
+ | Value | Effect |
282
+ | --- | --- |
283
+ | `page` (default) | Purges the changed node's page/API output and relevant dependent output. |
284
+ | `tree` | Also invalidates the affected tree output and its routed pages. |
285
+ | `channel` | Invalidates the channel's route and API caches. Structural route changes such as slug changes use this broad path. |
286
+ | `global` | Clears the package cache and globally invalidates the configured frontend/CDN caches. |
114
287
 
115
- - `label` _(string)_: Field label.
116
- - `description` _(string)_: Helper text below the input.
117
- - `default` _(any)_: Default value when a new entry is created.
118
- - `position` _(string)_: Set to `"sidebar"` to move the field out of the main content column.
119
- - `showAsEditorTitle` _(boolean)_: Uses this field's value as the display title in Vault/Tree lists.
120
- - `public` _(boolean)_: **CRITICAL.** If `true`, this field is exposed in the public frontend API. If omitted or `false`, the data remains private to the admin backend.
288
+ For large channel purges (more than 25 routes or 300 targeted URLs), Kama
289
+ purges the affected hostnames instead of enumerating every route. This
290
+ invalidates other cached paths on those same hosts, but does not purge
291
+ unrelated hostnames in the zone.
121
292
 
122
- ### Database & Indexing
293
+ Example:
123
294
 
124
- - `dbType` _(string)_: The SQLite data type (e.g., `text`, `integer`, `json`). Most custom fields live inside a JSON blob, but native columns require this.
125
- - `index` _(boolean)_: Instructs the build pipeline to generate a SQLite index for this field for fast querying.
126
- - `primaryKey` _(boolean)_: Defines the ID column.
295
+ ```yaml
296
+ fields:
297
+ title:
298
+ type: text
299
+ cacheInvalidation: tree
300
+ slug:
301
+ type: slug
302
+ linkedTo: title
303
+ cacheInvalidation: channel
304
+ metaDescription:
305
+ type: textarea
306
+ cacheInvalidation: page
307
+ ```
127
308
 
128
- ### Validation (`rules`)
309
+ ## 6. Rich-text profiles and icons
129
310
 
130
- - `required` _(boolean)_: Makes the field mandatory. (Can also be set outside of `rules`).
131
- - `unique` / `uniqueSibling` _(boolean)_: Enforces uniqueness across the DB or tree branch.
132
- - `pattern` _(string)_: Regex validation (e.g., `"^[a-z0-9_-]+$"`).
133
- - `customMessage` _(string)_: Error message when validation fails.
311
+ Rich-text fields use `editor` or `rteType` to select a profile. Profiles are
312
+ loaded from `definitions/editor/*.ts`; the package currently includes
313
+ `default`, `minimal`, `button`, and `header`. If the name is not registered,
314
+ the editor falls back to `default`.
134
315
 
135
- ### Linking & Inheritance
316
+ A profile exports a `profile` containing TipTap `extensions` and toolbar
317
+ controls. Current controls include bold, italic, strike, heading levels 1-4,
318
+ subscript, superscript, bullet/ordered lists, blockquote, link, tooltip,
319
+ horizontal rule, table, and split. In the default profile, select text and
320
+ choose the tooltip control to add an explanation with bold, italic, and links.
321
+ Place the cursor inside an existing tooltip to edit or remove it. Tooltips are
322
+ saved as `span` elements with plain text in `data-tooltip` and formatted HTML
323
+ in `data-tooltip-html`; the consuming site is responsible for safely displaying
324
+ them. Older tooltips containing only plain text remain editable.
136
325
 
137
- - `linkedTo` _(string)_: Automatically populates this field based on another (e.g., auto-generating a slug from the title).
138
- - `inherits` / `inheritsFromParent` _(string/boolean)_: Pulls a fallback value from a parent node if left blank.
326
+ For `type: icon`, `packages` filters the installed Iconify collections, for
327
+ example:
139
328
 
140
- ## 7. Media & Asset Specifics (`asset` / `image`)
329
+ ```yaml
330
+ iconName:
331
+ type: icon
332
+ packages: ["heroicons", "lucide", "mdi"]
333
+ ```
141
334
 
142
- Kama features a powerful R2-backed media engine with automated image cropping.
335
+ The collections must be installed as `@iconify-json/*` dependencies for local
336
+ icons to be bundled.
337
+
338
+ ## 7. Images, cropping, and media
339
+
340
+ Use `asset`, `media`, or `image` for asset fields. `image`/`asset` are treated
341
+ as image-oriented controls; `allowedTypes` can further limit upload MIME types.
342
+ The legacy singular `crop` key is also read, but prefer `crops`.
143
343
 
144
344
  ```yaml
145
345
  featuredImage:
146
- label: Main Image
147
- type: asset
346
+ label: Featured image
347
+ type: image
148
348
  multiple: false
349
+ maxItems: 1
149
350
  maxSizeMB: 15
150
- maxPreviewWidth: 300px
351
+ maxPreviewWidth: 800
151
352
  allowedTypes: ["image/jpeg", "image/png", "image/webp"]
152
353
  crops:
153
- list_thumb:
154
- label: "List View (4:3)"
155
- aspectRatio: 1.333
156
- catalog_card:
157
- label: "Portrait Card (3:4)"
158
- aspectRatio: 0.75
354
+ card:
355
+ label: Card (16:9)
356
+ aspectRatio: 1.7778
357
+ avatar:
358
+ label: Avatar
359
+ aspectRatio: 1
360
+ shape: circle
361
+ public: true
362
+ ```
363
+
364
+ | Property | Behavior |
365
+ | --- | --- |
366
+ | `multiple` | Allows multiple assets. |
367
+ | `maxItems` | Maximum selected assets; defaults to `1` for single fields and `99` for multiple fields. |
368
+ | `maxSizeMB` | Client upload size limit in megabytes; defaults to `10`. |
369
+ | `allowedTypes` | MIME types, including wildcards such as `image/*`. `accept` is a compatibility alias. |
370
+ | `maxPreviewWidth` / `maxWidth` | Preview width; also used as a client-side resize limit for image uploads. |
371
+ | `showLabel: false` | Hides the asset field label. |
372
+ | `crops` | Map of stable variant key to crop settings. |
373
+ | `crops.<key>.label` | Name shown for the crop preset. |
374
+ | `crops.<key>.aspectRatio` | Fixed crop ratio as a positive number (e.g. `16 / 9` = `1.7778`). |
375
+ | `crops.<key>.shape` | `circle` or `round` uses a circular crop stencil; other values use a rectangle. |
376
+ | `previewPresetKey: null` | Disables automatic selection of the first crop preset for the field preview. |
377
+
378
+ `ratio` is also read by some upload and preview paths, but `aspectRatio` is the
379
+ recommended property and is used by the manual cropper.
380
+
381
+ On upload, Kama creates crop variants for configured presets; editors can open
382
+ the crop tool to adjust each variant. Keep preset keys stable because stored
383
+ assets and variants are keyed by them. Crop configuration is independent of
384
+ delivery-time resizing and format conversion.
385
+
386
+ The public media route also accepts optimization query parameters:
387
+
388
+ | Parameter | Meaning |
389
+ | --- | --- |
390
+ | `w` | Requested width in pixels, up to 3840; snapped to a standard CDN breakpoint. |
391
+ | `h` | Requested height in pixels, up to 3840. |
392
+ | `q` | Quality from 1 to 100. |
393
+ | `f` | Format: `auto`, `avif`, `webp`, `jpeg`, `jpg`, `png`, `gif`, or `svg`. |
394
+
395
+ For example, `/media/<asset-key>?w=640&q=80&f=webp`. These URL options are
396
+ media API behavior, not field-schema properties.
397
+
398
+ ## 8. Canvas layouts and regions
399
+
400
+ Both node layouts and block layouts use CSS Grid. Each string in `areas` names a
401
+ region; every name must have a matching entry in `regions`.
402
+
403
+ ```yaml
404
+ id: two-column
405
+ label: Two columns
406
+ layout:
407
+ columns: "2fr 1fr"
408
+ areas:
409
+ - ["header", "header"]
410
+ - ["content", "sidebar"]
411
+ - ["footer", "footer"]
412
+ regions:
413
+ header:
414
+ label: Header
415
+ inherit: parent
416
+ showLabel: true
417
+ content:
418
+ label: Main content
419
+ allowedBlocks: "*"
420
+ sidebar:
421
+ label: Sidebar
422
+ disallowedBlocks: [hero, image_card]
423
+ footer:
424
+ label: Footer
425
+ purgeTargets: ["/partials/footer"]
159
426
  ```
160
427
 
161
- - `multiple` _(boolean)_: Enables multi-file upload (Gallery).
162
- - `allowedTypes` _(array)_: MIME type restrictions.
163
- - `crops`: A map of required crop aspect ratios. The CMS will prompt the editor to crop the image to these exact ratios upon upload. The frontend API returns optimized URLs for each crop key.
428
+ ### Layout options
429
+
430
+ - `layout.columns`: CSS `grid-template-columns` value.
431
+ - `layout.areas`: rows of CSS grid-area names.
432
+ - `regions`: map keyed by those names.
433
+ - `regions.<name>.label`: editor label.
434
+ - `showLabel`: hides the layout or region label when `false`.
435
+ - `inherit: parent`: marks region content as inherited from the parent node.
436
+ - `allowedBlocks` / `disallowedBlocks`: block/layout ID allow or deny lists;
437
+ `"*"` means all blocks.
438
+ - `dropType: image`: makes the region accept image drops through the image
439
+ editor. Asset options such as `multiple`, `maxItems`, `maxSizeMB`,
440
+ `maxPreviewWidth`, `allowedTypes`, and `crops` can also be set on the region.
441
+ - `purgeTargets`: frontend paths to purge when the associated region changes.
442
+
443
+ Node definitions can restrict their whole canvas with root-level
444
+ `allowedBlocks` / `disallowedBlocks`. If the node has no selected layout, its
445
+ `defaultLayout` is used. A `layout-select` field can restrict choices with
446
+ `allowedLayouts`; `inheritsFromParent: true` enables parent/subpage layout
447
+ inheritance.
164
448
 
165
- ## 8. Field Sets (Inclusions)
449
+ ## 9. Database and public API behavior
166
450
 
167
- To keep your schemas DRY, Kama allows you to group common fields in `/field-sets/` and import them into other schemas.
451
+ `type` chooses the editor control; `dbType` controls database storage. Supported
452
+ `dbType` values are `text`, `integer`, `real`, and `json`. Do not use a UI type
453
+ as a database type. Unknown `dbType` values fall back to `TEXT`; for example,
454
+ `boolean` is not a distinct SQL type. `required`, `default`, and `primaryKey`
455
+ affect generated table definitions where dynamic table generation applies.
168
456
 
169
- For example, `content/definitions/field-sets/page-meta.yaml` defines SEO fields.
457
+ For node fields, `index: true` can request a JSON-field index. Some core fields
458
+ already have dedicated columns/indexes and are handled separately.
170
459
 
171
- **How to include a Field Set in a Schema:**
172
- Use the `fieldSet` keyword inside your fields list.
460
+ Set `public: true` to intentionally expose a field through public APIs. Set
461
+ `inTree: true` for a node field that should be available in tree node output;
462
+ tree output only includes schema-approved public fields. Treat `public` as an
463
+ API/data-exposure decision, not just an editor display setting.
464
+
465
+ ## 10. Examples
466
+
467
+ ### A page type with shared fields and scoped cache invalidation
173
468
 
174
469
  ```yaml
470
+ id: page
471
+ label: Page
472
+ inTree: true
473
+ inVault: true
474
+ hasCanvas: true
475
+ directLinking: true
476
+ defaultLayout: single-column
477
+ allowedBlocks: "*"
175
478
  tabs:
176
479
  settings:
480
+ label: Page
177
481
  fields:
178
- title:
179
- label: "Title"
180
- # Imports the entire page-base YAML here
181
- fieldSet: page-base
482
+ - fieldSet: page-base
483
+ menuTitle:
484
+ label: Menu title
485
+ type: text
486
+ public: true
487
+ inTree: true
488
+ cacheInvalidation: tree
489
+ meta: !include ../field-sets/page-seo.yaml
182
490
  ```
491
+
492
+ ### A reusable field set
493
+
494
+ ```yaml
495
+ label: Page base
496
+ fields:
497
+ title:
498
+ label: Page title
499
+ type: text
500
+ required: true
501
+ public: true
502
+ inTree: true
503
+ cacheInvalidation: tree
504
+ slug:
505
+ label: URL slug
506
+ type: slug
507
+ linkedTo: title
508
+ required: true
509
+ public: true
510
+ inTree: true
511
+ cacheInvalidation: channel
512
+ ```
513
+