@brightsideoy/kama 0.1.0-alpha.17 → 0.1.0-alpha.170

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 (89) hide show
  1. package/README.md +169 -0
  2. package/bin/cli.js +686 -155
  3. package/content/definitions/block-layouts/three-column.yaml +20 -0
  4. package/content/definitions/block-layouts/two-column.yaml +29 -0
  5. package/content/definitions/blocks/button.yaml +24 -0
  6. package/content/definitions/blocks/header.yaml +13 -0
  7. package/content/definitions/blocks/header_image.yaml +21 -0
  8. package/content/definitions/blocks/hero.yaml +28 -0
  9. package/content/definitions/blocks/html.yaml +13 -0
  10. package/content/definitions/blocks/image_card.yaml +56 -0
  11. package/content/definitions/blocks/single_image.yaml +27 -0
  12. package/content/definitions/blocks/text.yaml +15 -0
  13. package/content/definitions/channels/ecommerce.yaml +28 -0
  14. package/content/definitions/channels/website.yaml +41 -0
  15. package/content/definitions/field-sets/access.yaml +27 -0
  16. package/content/definitions/field-sets/channel-base.yaml +50 -0
  17. package/content/definitions/field-sets/channel-seo.yaml +21 -0
  18. package/content/definitions/field-sets/comments.yaml +11 -0
  19. package/content/definitions/field-sets/content-block.yaml +41 -0
  20. package/content/definitions/field-sets/page-base.yaml +44 -0
  21. package/content/definitions/field-sets/page-seo.yaml +34 -0
  22. package/content/definitions/field-sets/page-social.yaml +78 -0
  23. package/content/definitions/field-sets/schema-type.yaml +43 -0
  24. package/content/definitions/field-sets/tree-base.yaml +31 -0
  25. package/content/definitions/field-sets/visibility.yaml +8 -0
  26. package/content/definitions/node-layouts/content.yml +12 -0
  27. package/content/definitions/node-layouts/landing-page.yml +27 -0
  28. package/content/definitions/node-layouts/single-column.yml +43 -0
  29. package/content/definitions/node-layouts/two-column.yml +48 -0
  30. package/content/definitions/nodes/address.yaml +40 -0
  31. package/content/definitions/nodes/article.yaml +37 -0
  32. package/content/definitions/nodes/event.yaml +55 -0
  33. package/content/definitions/nodes/external-link.yaml +29 -0
  34. package/content/definitions/nodes/page-skeleton.yaml +48 -0
  35. package/content/definitions/nodes/page.yaml +54 -0
  36. package/content/definitions/nodes/person.yaml +41 -0
  37. package/content/definitions/nodes/product.yaml +89 -0
  38. package/content/definitions/trees/navigation.yaml +24 -0
  39. package/definitions/editor/button.ts +11 -0
  40. package/definitions/editor/default.ts +22 -0
  41. package/definitions/editor/header.ts +36 -0
  42. package/definitions/editor/minimal.ts +15 -0
  43. package/definitions/validators/iban.ts +12 -0
  44. package/definitions/validators/magic-word.ts +7 -0
  45. package/dist/assets/index-CDo1UNaK.js +164 -0
  46. package/dist/assets/index-D5W5U152.css +1 -0
  47. package/dist/dist-DkBY_SfG.js +8974 -0
  48. package/dist/index.html +15 -0
  49. package/dist/index.js +8030 -1884
  50. package/dist/schema-compiler.js +48 -0
  51. package/documentation/SCHEMAS.md +182 -0
  52. package/package.json +19 -17
  53. package/schema.sql +206 -0
  54. package/templates/astro-starter/astro.config.mjs +27 -0
  55. package/templates/astro-starter/package.json.template +20 -0
  56. package/templates/astro-starter/public/robots.txt +23 -0
  57. package/templates/astro-starter/src/components/blocks/BlockRenderer.astro +134 -0
  58. package/templates/astro-starter/src/components/blocks/ColumnLayout.astro +67 -0
  59. package/templates/astro-starter/src/components/blocks/HeaderImage.astro +132 -0
  60. package/templates/astro-starter/src/components/blocks/Hero.astro +218 -0
  61. package/templates/astro-starter/src/components/blocks/HtmlBlock.astro +25 -0
  62. package/templates/astro-starter/src/components/blocks/ImageBlock.astro +92 -0
  63. package/templates/astro-starter/src/components/blocks/TextBlock.astro +15 -0
  64. package/templates/astro-starter/src/components/global/Breadcrumb.astro +67 -0
  65. package/templates/astro-starter/src/components/global/Footer.astro +50 -0
  66. package/templates/astro-starter/src/components/global/Header.astro +177 -0
  67. package/templates/astro-starter/src/components/global/MetaHead.astro +266 -0
  68. package/templates/astro-starter/src/components/global/NavigationMenu.astro +318 -0
  69. package/templates/astro-starter/src/components/ui/KamaImage.astro +172 -0
  70. package/templates/astro-starter/src/layouts/SkeletonLayout.astro +56 -0
  71. package/templates/astro-starter/src/layouts/StandardLayout.astro +62 -0
  72. package/templates/astro-starter/src/lib/cms.ts +197 -0
  73. package/templates/astro-starter/src/lib/media/kama-image-service.ts +56 -0
  74. package/templates/astro-starter/src/lib/media/media-proxy.ts +129 -0
  75. package/templates/astro-starter/src/lib/media/media-url.ts +98 -0
  76. package/templates/astro-starter/src/middleware.ts +478 -0
  77. package/templates/astro-starter/src/pages/404.astro +46 -0
  78. package/templates/astro-starter/src/pages/[...slug].astro +242 -0
  79. package/templates/astro-starter/src/pages/llms-full.txt.ts +171 -0
  80. package/templates/astro-starter/src/pages/llms.txt.ts +113 -0
  81. package/templates/astro-starter/src/pages/media/[...path].ts +14 -0
  82. package/templates/astro-starter/src/pages/partials/footer.astro +69 -0
  83. package/templates/astro-starter/src/pages/partials/nav.astro +141 -0
  84. package/templates/astro-starter/src/styles/standard-theme.css +157 -0
  85. package/templates/astro-starter/src/utils/tiptap.ts +113 -0
  86. package/templates/astro-starter/tsconfig.json +0 -0
  87. package/templates/kama-worker/index.js +19 -0
  88. package/templates/kama-worker/server.js +98 -0
  89. package/wrangler.json +22 -0
package/README.md CHANGED
@@ -0,0 +1,169 @@
1
+ # KAMA – Global Content Delivery at the Edge
2
+
3
+ **[KAMA](https://kamaengine.com) 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
+ > &nbsp;
15
+ > <br>
16
+ > <br>
17
+
18
+ <br>
19
+
20
+ ## Usage & Licensing
21
+
22
+ **KAMA is free to use for all kinds of projects. For commercial support get in touch with [Brightside OÜ](https://t3brightside.com).**
23
+
24
+ The software is delivered in its current state without promises about performance, quality, or fitness for a specific purpose.
25
+ <br>
26
+
27
+ ## The Concept: Edge-Native, Deployment-Agnostic
28
+
29
+ 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.
30
+
31
+ 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.
32
+
33
+ 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.
34
+ 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.
35
+
36
+ <br>
37
+
38
+ ## Core Features
39
+
40
+ - **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.
41
+ - **Vault vs. Tree Architecture:**
42
+ - **The Tree:** Hierarchical drag-and-drop routing for pages, navigation, and nested URLs.
43
+ - **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.
44
+ - **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.
45
+ - **Multi-Channel Native:** Manage multiple websites, apps, or regions from a single KAMA instance. Content can be shared across channels or isolated.
46
+ - **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.
47
+ - **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.
48
+ - **Astro First (But Framework Agnostic):** Comes with a built-in CLI to scaffold highly optimized Astro frontends that natively consume the KAMA API.
49
+
50
+ <br>
51
+
52
+ ## Architecture & Tech Stack
53
+
54
+ KAMA is built to leverage modern edge platforms while maintaining local portability:
55
+
56
+ | Component | Cloudflare Edge | Local / Virtual Server |
57
+ | :------------ | :-------------------- | :--------------------------------- |
58
+ | **Compute** | Cloudflare Workers | Node.js / `workerd` runtime |
59
+ | **Database** | Cloudflare D1 | Local SQLite |
60
+ | **Storage** | Cloudflare R2 | S3-Compatible Storage / Local Disk |
61
+ | **Caching** | Cloudflare Edge Cache | In-memory / CDN pass-through |
62
+ | **CLI / Gen** | Node.js | Node.js |
63
+
64
+ <br>
65
+
66
+ ## Smart Edge Caching & Prewarming
67
+
68
+ 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.
69
+
70
+ - **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.
71
+ - **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.
72
+ - **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.
73
+ - **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.
74
+
75
+ <br>
76
+
77
+ ## The Schema Engine
78
+
79
+ 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.
80
+
81
+ <br>
82
+
83
+ ## Getting Started
84
+
85
+ KAMA comes with a scaffolding CLI to instantly spin up a full monorepo (Backend + Astro Frontend).
86
+
87
+ ## 1. Initialize a Workspace
88
+
89
+ ```bash
90
+ npx @brightsideoy/kama@latest
91
+ ```
92
+
93
+ Select **"Kickstart new KAMA Monorepo"**. The CLI will automatically:
94
+
95
+ - Authenticate with Cloudflare (if deploying to the Edge).
96
+ - Create a new D1 database (or local SQLite equivalent).
97
+ - Bind your R2 media buckets.
98
+ - Setup the Worker backend and Astro frontend.
99
+
100
+ ## 2. Local Development
101
+
102
+ Start the backend and frontend simultaneously on your local machine:
103
+
104
+ ```bash
105
+ npm run dev:cms
106
+ ```
107
+
108
+ This bundles your local YAML schemas, syncs the local SQLite/D1 database, and starts the Wrangler dev server on your localhost.
109
+
110
+ ## 3. Deploy
111
+
112
+ Push your API, schemas, and database migrations to Cloudflare's global network, or package it for your virtual server:
113
+
114
+ ```bash
115
+ npm run deploy:cms
116
+ ```
117
+
118
+ <br>
119
+
120
+ ## Directory Structure Overview
121
+
122
+ A standard KAMA workspace looks like this:
123
+
124
+ ```text
125
+ my-kama-workspace/
126
+ ├── package.json
127
+ ├── content/ # 👉 YOUR SCHEMA DEFINITIONS
128
+ │ └── definitions/
129
+ │ ├── nodes/ # e.g., page.yaml, product.yaml
130
+ │ ├── blocks/ # e.g., hero.yaml, image_card.yaml
131
+ │ └── node-layouts/ # e.g., two-column.yaml
132
+ ├── cms-worker/ # 👉 BACKEND PIPELINE
133
+ │ ├── index.js # Worker entrypoint (ES Module)
134
+ │ ├── wrangler.json # Bindings (D1, R2, Vars)
135
+ │ └── package.json
136
+ └── sites/ # 👉 YOUR FRONTENDS
137
+ └── brand-website/ # (e.g., Astro project)
138
+ ├── src/
139
+ ├── astro.config.mjs
140
+ └── wrangler.json
141
+ ```
142
+
143
+ <br>
144
+
145
+ ## API Usage (Frontend)
146
+
147
+ Because KAMA is a headless Content Delivery Platform, fetching data from the edge (or your local server) is incredibly fast.
148
+
149
+ ```javascript
150
+ // Fetch a navigation tree
151
+ const response = await fetch(
152
+ "[https://admin.yourdomain.com/api/v1/tree/main-nav?channelId=website](https://admin.yourdomain.com/api/v1/tree/main-nav?channelId=website)",
153
+ );
154
+ const menu = await response.json();
155
+
156
+ // Fetch a specific node/page by slug
157
+ const pageResponse = await fetch(
158
+ "[https://admin.yourdomain.com/api/v1/node/about-us?channelId=website](https://admin.yourdomain.com/api/v1/node/about-us?channelId=website)",
159
+ );
160
+ const pageData = await pageResponse.json();
161
+ ```
162
+
163
+ _(When deployed to Cloudflare, all responses are heavily cached at the Edge, ensuring near-instantaneous TTFB)._
164
+
165
+ <br>
166
+
167
+ ## Development & maintenance
168
+
169
+ [Brightside OÜ – Web development and hosting specialised web agency](https://t3brightside.com/)