@brightsideoy/kama 0.1.0-alpha.14 → 0.1.0-alpha.141
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 +195 -0
- package/bin/cli.js +628 -180
- package/content/definitions/block-layouts/three-column.yaml +20 -0
- package/content/definitions/block-layouts/two-column.yaml +29 -0
- package/content/definitions/blocks/button.yaml +24 -0
- package/content/definitions/blocks/header.yaml +13 -0
- package/content/definitions/blocks/header_image.yaml +21 -0
- package/content/definitions/blocks/hero.yaml +28 -0
- package/content/definitions/blocks/html.yaml +12 -0
- package/content/definitions/blocks/image_card.yaml +56 -0
- package/content/definitions/blocks/single_image.yaml +27 -0
- package/content/definitions/blocks/text.yaml +15 -0
- package/content/definitions/channels/ecommerce.yaml +28 -0
- package/content/definitions/channels/website.yaml +41 -0
- package/content/definitions/field-sets/access.yaml +27 -0
- package/content/definitions/field-sets/channel-base.yaml +50 -0
- package/content/definitions/field-sets/channel-seo.yaml +21 -0
- package/content/definitions/field-sets/comments.yaml +11 -0
- package/content/definitions/field-sets/content-block.yaml +41 -0
- package/content/definitions/field-sets/page-base.yaml +44 -0
- package/content/definitions/field-sets/page-seo.yaml +34 -0
- package/content/definitions/field-sets/page-social.yaml +78 -0
- package/content/definitions/field-sets/schema-type.yaml +43 -0
- package/content/definitions/field-sets/tree-base.yaml +31 -0
- package/content/definitions/field-sets/visibility.yaml +8 -0
- package/content/definitions/node-layouts/content.yml +12 -0
- package/content/definitions/node-layouts/landing-page.yml +25 -0
- package/content/definitions/node-layouts/single-column.yml +41 -0
- package/content/definitions/node-layouts/two-column.yml +46 -0
- package/content/definitions/nodes/address.yaml +40 -0
- package/content/definitions/nodes/article.yaml +37 -0
- package/content/definitions/nodes/event.yaml +55 -0
- package/content/definitions/nodes/external-link.yaml +29 -0
- package/content/definitions/nodes/page-skeleton.yaml +48 -0
- package/content/definitions/nodes/page.yaml +70 -0
- package/content/definitions/nodes/person.yaml +41 -0
- package/content/definitions/nodes/product.yaml +89 -0
- package/content/definitions/trees/navigation.yaml +24 -0
- package/definitions/editor/button.ts +11 -0
- package/definitions/editor/default.ts +21 -0
- package/definitions/editor/header.ts +36 -0
- package/definitions/editor/minimal.ts +15 -0
- package/definitions/validators/iban.ts +12 -0
- package/definitions/validators/magic-word.ts +7 -0
- package/dist/assets/index-Bv7fPRX7.css +1 -0
- package/dist/assets/index-DttddV1f.js +162 -0
- package/dist/index.html +13 -0
- package/dist/index.js +12327 -2110
- package/documentation/SCHEMAS.md +182 -0
- package/package.json +12 -14
- package/schema.sql +204 -0
- package/templates/astro-starter/astro.config.mjs +40 -0
- package/templates/astro-starter/middleware/api-purge.ts +130 -0
- package/templates/astro-starter/middleware/index.ts +10 -0
- package/templates/astro-starter/middleware/kv-cache.ts +76 -0
- package/templates/astro-starter/middleware/response-headers.ts +43 -0
- package/templates/astro-starter/package.json.template +20 -0
- package/templates/astro-starter/public/css/standard-theme.css +157 -0
- package/templates/astro-starter/public/robots.txt +23 -0
- package/templates/astro-starter/src/components/blocks/BlockRenderer.astro +133 -0
- package/templates/astro-starter/src/components/blocks/ColumnLayout.astro +66 -0
- package/templates/astro-starter/src/components/blocks/HeaderImage.astro +131 -0
- package/templates/astro-starter/src/components/blocks/Hero.astro +218 -0
- package/templates/astro-starter/src/components/blocks/HtmlBlock.astro +24 -0
- package/templates/astro-starter/src/components/blocks/ImageBlock.astro +160 -0
- package/templates/astro-starter/src/components/blocks/TextBlock.astro +13 -0
- package/templates/astro-starter/src/components/global/Breadcrumb.astro +65 -0
- package/templates/astro-starter/src/components/global/Footer.astro +48 -0
- package/templates/astro-starter/src/components/global/Header.astro +101 -0
- package/templates/astro-starter/src/components/global/NavigationMenu.astro +466 -0
- package/templates/astro-starter/src/components/seo/SeoHead.astro +150 -0
- package/templates/astro-starter/src/components/ui/KamaImage.astro +149 -0
- package/templates/astro-starter/src/layouts/SkeletonLayout.astro +45 -0
- package/templates/astro-starter/src/layouts/StandardLayout.astro +52 -0
- package/templates/astro-starter/src/lib/cms.ts +149 -0
- package/templates/astro-starter/src/lib/media/kama-image-service.ts +41 -0
- package/templates/astro-starter/src/lib/media/media-proxy.ts +127 -0
- package/templates/astro-starter/src/lib/media/media-url.ts +34 -0
- package/templates/astro-starter/src/pages/404.astro +46 -0
- package/templates/astro-starter/src/pages/[...slug].astro +224 -0
- package/templates/astro-starter/src/pages/llms-full.txt.ts +171 -0
- package/templates/astro-starter/src/pages/llms.txt.ts +113 -0
- package/templates/astro-starter/src/pages/media/[...path].ts +7 -0
- package/templates/astro-starter/src/utils/tiptap.ts +113 -0
- package/templates/astro-starter/tsconfig.json +0 -0
package/README.md
CHANGED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# KAMA – Global Content Delivery at the Edge
|
|
2
|
+
|
|
3
|
+
**KAMA is a schema-driven, headless Content Delivery Platform built to give you infinite edge scalability and total deployment flexibility.**
|
|
4
|
+
|
|
5
|
+
Engineered natively for the Cloudflare ecosystem (Workers, D1, R2), KAMA eliminates the need for traditional origin servers for unmatched global performance—yet remains fully capable of running locally on your own virtual servers or VPS for complete control.
|
|
6
|
+
|
|
7
|
+
<br>
|
|
8
|
+
|
|
9
|
+
> <br>
|
|
10
|
+
>
|
|
11
|
+
> **ALPHA STATUS**
|
|
12
|
+
>
|
|
13
|
+
> KAMA is currently in early **Alpha**. This is a conceptual implementation of edge-native content delivery. While functional, the core architecture, schemas, and APIs are under rapid development and subject to breaking changes.
|
|
14
|
+
>
|
|
15
|
+
> <br>
|
|
16
|
+
> <br>
|
|
17
|
+
|
|
18
|
+
<br>
|
|
19
|
+
|
|
20
|
+
## Usage & Licensing
|
|
21
|
+
|
|
22
|
+
**KAMA is strictly free for non-commercial, non-profit, educational, and government use.**
|
|
23
|
+
|
|
24
|
+
You are completely free to use KAMA for personal projects, educational institutions, registered non-profits, government agencies, hobby blogs, and conceptual experimentation.
|
|
25
|
+
|
|
26
|
+
**Commercial Use Prohibited:** You may not use KAMA for for-profit commercial purposes (including paid client projects, monetized websites, SaaS products, or internal corporate business operations) without an explicit commercial license. If you are interested in using KAMA commercially, please **[contact us](https://t3brightside.com)** for licensing details.
|
|
27
|
+
|
|
28
|
+
<br>
|
|
29
|
+
|
|
30
|
+
## The Concept: Edge-Native, Deployment-Agnostic
|
|
31
|
+
|
|
32
|
+
1. **Compute Anywhere:** Deploy the backend to Cloudflare Workers to execute milliseconds away from users, or self-host it on a local virtual server/VPS using standard Node.js or edge-runtime containers.
|
|
33
|
+
|
|
34
|
+
2. **Database Flexibility:** By default, data is stored in Cloudflare D1 (distributed SQLite) for edge-local queries. On a local server, this translates perfectly to standard SQLite, making it highly portable.
|
|
35
|
+
|
|
36
|
+
3. **Storage at the Edge:** Media and assets are stored in Cloudflare R2 and served directly from the edge cache, but can easily be adapted for local storage solutions.
|
|
37
|
+
4. **Single Source of Truth:** Your entire content model, UI forms, layouts, and database indexes are generated from simple YAML files stored alongside your frontend code.
|
|
38
|
+
|
|
39
|
+
<br>
|
|
40
|
+
|
|
41
|
+
## Core Features
|
|
42
|
+
|
|
43
|
+
- **Zero-Config Admin UI:** No need to write React or Vue forms. Define your content model in a YAML file, and KAMA automatically generates the rich editing interface, validation rules, and layout logic.
|
|
44
|
+
- **Vault vs. Tree Architecture:**
|
|
45
|
+
- **The Tree:** Hierarchical drag-and-drop routing for pages, navigation, and nested URLs.
|
|
46
|
+
- **The Vault:** A headless repository for structured, reusable data (e.g., Products, Office Locations, People) that can be queried via API or linked to Pages.
|
|
47
|
+
- **Visual Canvas Builder:** An intuitive, block-based editor. Define your content regions, image drop zones and blocks (components) in YAML, and let editors compose pages safely without breaking the design system.
|
|
48
|
+
- **Multi-Channel Native:** Manage multiple websites, apps, or regions from a single KAMA instance. Content can be shared across channels or isolated.
|
|
49
|
+
- **Smart Media Engine:** Direct-to-R2 uploads with automated, schema-defined image cropping. Define aspect ratios in YAML, and the UI forces editors to crop images perfectly.
|
|
50
|
+
- **Hybrid Deployment:** Deploy seamlessly to Cloudflare's global network, or run it on a local Linux/Windows virtual server for internal enterprise networks, staging environments, or self-hosted production.
|
|
51
|
+
- **Astro First (But Framework Agnostic):** Comes with a built-in CLI to scaffold highly optimized Astro frontends that natively consume the KAMA API.
|
|
52
|
+
|
|
53
|
+
<br>
|
|
54
|
+
|
|
55
|
+
## Architecture & Tech Stack
|
|
56
|
+
|
|
57
|
+
KAMA is built to leverage modern edge platforms while maintaining local portability:
|
|
58
|
+
|
|
59
|
+
| Component | Cloudflare Edge | Local / Virtual Server |
|
|
60
|
+
| :------------ | :-------------------- | :--------------------------------- |
|
|
61
|
+
| **Compute** | Cloudflare Workers | Node.js / `workerd` runtime |
|
|
62
|
+
| **Database** | Cloudflare D1 | Local SQLite |
|
|
63
|
+
| **Storage** | Cloudflare R2 | S3-Compatible Storage / Local Disk |
|
|
64
|
+
| **Caching** | Cloudflare Edge Cache | In-memory / CDN pass-through |
|
|
65
|
+
| **CLI / Gen** | Node.js | Node.js |
|
|
66
|
+
|
|
67
|
+
<br>
|
|
68
|
+
|
|
69
|
+
## Smart Edge Caching & Prewarming
|
|
70
|
+
|
|
71
|
+
KAMA doesn't just serve content; it actively manages its lifecycle across the global edge network to guarantee absolute maximum cache hit ratios for your end users.
|
|
72
|
+
|
|
73
|
+
- **Aggressive Edge Caching:** By default, all API responses and media assets are heavily cached directly at the edge layer. Database queries (D1) are bypassed entirely for cached requests.
|
|
74
|
+
- **Targeted Invalidation (Purging):** When you publish a change in the KAMA Admin UI, the platform triggers a targeted Cloudflare Zone API purge. It invalidates only the modified content routes from the edge cache, leaving the rest of your site lightning fast.
|
|
75
|
+
- **Automated Prewarming:** The moment a cache is purged, KAMA automatically sends background requests to "prewarm" the edge nodes with the fresh content. This means the very first organic visitor after a content update will still experience a rapid cache hit, completely hiding database latency.
|
|
76
|
+
- **Zero-Config Management:** No Redis, Varnish, or complex CDN tagging rules to maintain. KAMA handles the edge invalidation and prewarming lifecycle out of the box.
|
|
77
|
+
|
|
78
|
+
<br>
|
|
79
|
+
|
|
80
|
+
## The Schema Engine
|
|
81
|
+
|
|
82
|
+
At the heart of KAMA is the Schema Engine. Instead of complex database migrations, you define your content models, layouts, and reusable blocks in simple YAML files. KAMA dynamically bundles these definitions at build-time to auto-generate your entire Admin UI, database indexes, and API endpoints.
|
|
83
|
+
|
|
84
|
+
**[Read the full Schema Documentation here](/@brightsideoy/kama/documentation/SCHEMAS.md)**
|
|
85
|
+
|
|
86
|
+
<br>
|
|
87
|
+
|
|
88
|
+
## Getting Started
|
|
89
|
+
|
|
90
|
+
KAMA comes with an interactive executable CLI to instantly spin up a full monorepo (Backend Worker + optional Astro Frontend), add new sites to existing workspaces, or promote local setups to Cloudflare Edge.
|
|
91
|
+
|
|
92
|
+
### 1. Initialize a Workspace\*\*
|
|
93
|
+
|
|
94
|
+
Run the KAMA CLI to start the workspace wizard:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
npx kama init
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The CLI will prompt you for your setup preferences and automatically:
|
|
101
|
+
|
|
102
|
+
- Scaffold the `kama-worker` engine and content definition directories (`content/definitions/`).
|
|
103
|
+
- Authenticate with Cloudflare and auto-provision a remote D1 database + R2 bucket bindings (if deploying to Edge).
|
|
104
|
+
- Scaffold a fully configured Astro frontend site inside `sites/` with built-in edge-caching middleware.
|
|
105
|
+
- Configure local SQLite fallback environments for completely offline development.
|
|
106
|
+
|
|
107
|
+
### 2. Local Development
|
|
108
|
+
|
|
109
|
+
Start the local CMS dev server from your workspace root:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
npm run dev:cms
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
This command automatically compiles your YAML/JSON schemas into runtime JavaScript definitions, syncs your local SQLite database, and launches the Miniflare worker environment on `http://localhost:8787`.
|
|
116
|
+
|
|
117
|
+
### 3. Management Commands\*\*
|
|
118
|
+
|
|
119
|
+
You can run CLI commands anytime inside your workspace.
|
|
120
|
+
|
|
121
|
+
#### Add a New Astro Frontend Site
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
npx kama add site
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
#### Promote a Local Workspace to Cloudflare Edge
|
|
128
|
+
|
|
129
|
+
Convert a local offline workspace to Cloudflare Edge (auto-links domains & D1 databases):
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
npx kama promote
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### 4. Deploy
|
|
136
|
+
|
|
137
|
+
Deploy your CMS engine, content definitions, and database migrations to Cloudflare Edge:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
npm run deploy:cms
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
> **Note:** For self-hosted virtual servers (VPS) or Docker environments, you can run `npm run dev:cms` under PM2/Docker as a standalone `workerd` server.
|
|
144
|
+
> <br>
|
|
145
|
+
|
|
146
|
+
## Directory Structure Overview
|
|
147
|
+
|
|
148
|
+
A standard KAMA workspace looks like this:
|
|
149
|
+
|
|
150
|
+
```text
|
|
151
|
+
my-kama-workspace/
|
|
152
|
+
├── package.json
|
|
153
|
+
├── content/ # 👉 YOUR SCHEMA DEFINITIONS
|
|
154
|
+
│ └── definitions/
|
|
155
|
+
│ ├── nodes/ # e.g., page.yaml, product.yaml
|
|
156
|
+
│ ├── blocks/ # e.g., hero.yaml, image_card.yaml
|
|
157
|
+
│ └── node-layouts/ # e.g., two-column.yaml
|
|
158
|
+
├── kama-worker/ # 👉 BACKEND PIPELINE
|
|
159
|
+
│ ├── index.js # Worker entrypoint (ES Module)
|
|
160
|
+
│ ├── wrangler.json # Bindings (D1, R2, Vars)
|
|
161
|
+
│ └── package.json
|
|
162
|
+
└── sites/ # 👉 YOUR FRONTENDS
|
|
163
|
+
└── brand-website/ # (e.g., Astro project)
|
|
164
|
+
├── src/
|
|
165
|
+
├── astro.config.mjs
|
|
166
|
+
└── wrangler.json
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
<br>
|
|
170
|
+
|
|
171
|
+
## API Usage (Frontend)
|
|
172
|
+
|
|
173
|
+
Because KAMA is a headless Content Delivery Platform, fetching data from the edge (or your local server) is incredibly fast.
|
|
174
|
+
|
|
175
|
+
```javascript
|
|
176
|
+
// Fetch a navigation tree
|
|
177
|
+
const response = await fetch(
|
|
178
|
+
"[https://admin.yourdomain.com/api/v1/tree/main-nav?channelId=website](https://admin.yourdomain.com/api/v1/tree/main-nav?channelId=website)",
|
|
179
|
+
);
|
|
180
|
+
const menu = await response.json();
|
|
181
|
+
|
|
182
|
+
// Fetch a specific node/page by slug
|
|
183
|
+
const pageResponse = await fetch(
|
|
184
|
+
"[https://admin.yourdomain.com/api/v1/node/about-us?channelId=website](https://admin.yourdomain.com/api/v1/node/about-us?channelId=website)",
|
|
185
|
+
);
|
|
186
|
+
const pageData = await pageResponse.json();
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
_(When deployed to Cloudflare, all responses are heavily cached at the Edge, ensuring near-instantaneous TTFB)._
|
|
190
|
+
|
|
191
|
+
<br>
|
|
192
|
+
|
|
193
|
+
## Development & maintenance
|
|
194
|
+
|
|
195
|
+
[Brightside OÜ – Web development and hosting specialised web agency](https://t3brightside.com/)
|