@brightsideoy/kama 0.1.0-alpha.39 → 0.1.0-alpha.41
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/defaults/definitions/block-layouts/three-column.yaml +20 -0
- package/defaults/definitions/block-layouts/two-column.yaml +29 -0
- package/defaults/definitions/blocks/header.yaml +15 -0
- package/defaults/definitions/blocks/header_image.yaml +22 -0
- package/defaults/definitions/blocks/hero.yaml +27 -0
- package/defaults/definitions/blocks/image_card.yaml +53 -0
- package/defaults/definitions/blocks/text.yaml +16 -0
- package/defaults/definitions/channels/ecommerce.yaml +24 -0
- package/defaults/definitions/channels/website.yaml +32 -0
- package/defaults/definitions/field-sets/access.yaml +29 -0
- package/defaults/definitions/field-sets/channel-base.yaml +31 -0
- package/defaults/definitions/field-sets/comments.yaml +11 -0
- package/defaults/definitions/field-sets/content-block.yaml +46 -0
- package/defaults/definitions/field-sets/page-base.yaml +49 -0
- package/defaults/definitions/field-sets/page-meta.yaml +15 -0
- package/defaults/definitions/field-sets/page-social.yaml +80 -0
- package/defaults/definitions/field-sets/tree-base.yaml +31 -0
- package/defaults/definitions/field-sets/visibility.yaml +8 -0
- package/defaults/definitions/node-layouts/landing-page.yml +22 -0
- package/defaults/definitions/node-layouts/single-column.yml +38 -0
- package/defaults/definitions/node-layouts/three-column.yml +41 -0
- package/defaults/definitions/node-layouts/two-column.yml +40 -0
- package/defaults/definitions/nodes/address.yaml +32 -0
- package/defaults/definitions/nodes/article.yaml +41 -0
- package/defaults/definitions/nodes/event.yaml +40 -0
- package/defaults/definitions/nodes/external-link.yaml +26 -0
- package/defaults/definitions/nodes/page.yaml +63 -0
- package/defaults/definitions/nodes/person.yaml +35 -0
- package/defaults/definitions/nodes/product.yaml +79 -0
- package/defaults/definitions/trees/navigation.yaml +29 -0
- package/defaults/definitions/trees/social-links.yaml +9 -0
- package/definitions/_page.yaml +52 -0
- package/definitions/editor/default.ts +17 -0
- package/definitions/editor/header.ts +33 -0
- package/definitions/editor/minimal.ts +13 -0
- package/definitions/validators/iban.ts +12 -0
- package/definitions/validators/magic-word.ts +7 -0
- package/dist/index.js +10 -10
- package/package.json +3 -1
- package/scripts/bundle-definitions.js +40 -16
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
// scripts/bundle-definitions.js
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
4
5
|
import YAML from 'yaml';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
|
|
10
|
+
// 🎯 Package root is one directory up from scripts/
|
|
11
|
+
const packageRootDir = path.resolve(__dirname, '..');
|
|
12
|
+
|
|
13
|
+
// Look for definitions across package core AND consumer project overrides
|
|
7
14
|
function getDefinitionFiles(subDir) {
|
|
8
15
|
const fileMap = new Map();
|
|
16
|
+
|
|
9
17
|
const possibleDirs = [
|
|
18
|
+
// 1. Core package defaults (from inside node_modules or package source)
|
|
19
|
+
path.resolve(packageRootDir, "defaults/definitions", subDir),
|
|
20
|
+
path.resolve(packageRootDir, "definitions", subDir),
|
|
21
|
+
|
|
22
|
+
// 2. Fallbacks relative to node_modules if running from workspace root
|
|
23
|
+
path.resolve(process.cwd(), "node_modules/@brightsideoy/kama/defaults/definitions", subDir),
|
|
24
|
+
path.resolve(process.cwd(), "node_modules/@brightsideoy/kama/definitions", subDir),
|
|
25
|
+
|
|
26
|
+
// 3. Consumer project local overrides (highest priority — overwrites defaults)
|
|
10
27
|
path.resolve(process.cwd(), "defaults/definitions", subDir),
|
|
11
28
|
path.resolve(process.cwd(), "definitions", subDir),
|
|
12
29
|
path.resolve(process.cwd(), "schemas", subDir),
|
|
@@ -29,6 +46,7 @@ function getDefinitionFiles(subDir) {
|
|
|
29
46
|
entry.name.endsWith(".yml") ||
|
|
30
47
|
entry.name.endsWith(".json")
|
|
31
48
|
) {
|
|
49
|
+
// Overwrite earlier entries so local consumer files override package defaults
|
|
32
50
|
fileMap.set(entryRelPath, fullPath);
|
|
33
51
|
}
|
|
34
52
|
}
|
|
@@ -103,23 +121,31 @@ const outputContent = `// Auto-generated pre-bundled definitions for Kama Core E
|
|
|
103
121
|
export const BUNDLED_DEFINITIONS = ${JSON.stringify(bundled, null, 2)};
|
|
104
122
|
`;
|
|
105
123
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
124
|
+
// 🎯 Write to BOTH package dist/server locations so imports resolve cleanly
|
|
125
|
+
const targetDirs = [
|
|
126
|
+
path.resolve(packageRootDir, 'server/db'),
|
|
127
|
+
path.resolve(process.cwd(), 'node_modules/@brightsideoy/kama/server/db'),
|
|
128
|
+
path.resolve(process.cwd(), 'node_modules/@brightsideoy/kama/dist'),
|
|
129
|
+
path.resolve(process.cwd(), 'server/db'),
|
|
130
|
+
];
|
|
131
|
+
|
|
132
|
+
for (const dir of targetDirs) {
|
|
133
|
+
if (fs.existsSync(dir)) {
|
|
134
|
+
const outputPath = path.resolve(dir, 'bundled-definitions.ts');
|
|
135
|
+
fs.writeFileSync(outputPath, outputContent, 'utf-8');
|
|
136
|
+
// Also write .js version for built packages
|
|
137
|
+
const jsOutputPath = path.resolve(dir, 'bundled-definitions.js');
|
|
138
|
+
fs.writeFileSync(jsOutputPath, `export const BUNDLED_DEFINITIONS = ${JSON.stringify(bundled, null, 2)};\n`, 'utf-8');
|
|
139
|
+
}
|
|
109
140
|
}
|
|
110
141
|
|
|
111
|
-
|
|
112
|
-
fs.writeFileSync(outputPath, outputContent, 'utf-8');
|
|
113
|
-
|
|
114
|
-
console.log(`✅ Definitions bundled successfully into Kama Core:
|
|
142
|
+
console.log(`✅ Definitions bundled successfully:
|
|
115
143
|
• Nodes: ${Object.keys(bundled.rawNodes).length} (${Object.keys(bundled.rawNodes).join(', ')})
|
|
116
|
-
• Blocks: ${Object.keys(bundled.rawBlocks).length}
|
|
117
|
-
• Channels: ${Object.keys(bundled.rawChannels).length}
|
|
118
|
-
|
|
144
|
+
• Blocks: ${Object.keys(bundled.rawBlocks).length} (${Object.keys(bundled.rawBlocks).join(', ')})
|
|
145
|
+
• Channels: ${Object.keys(bundled.rawChannels).length} (${Object.keys(bundled.rawChannels).join(', ')})
|
|
146
|
+
• Trees: ${Object.keys(bundled.rawTrees).length} (${Object.keys(bundled.rawTrees).join(', ')})`);
|
|
119
147
|
|
|
120
|
-
//
|
|
121
|
-
// AUTO-GENERATE SQL INDEXES FROM SCHEMA
|
|
122
|
-
// ==========================================
|
|
148
|
+
// Auto-generate SQL Indexes
|
|
123
149
|
const indexQueries = new Set([
|
|
124
150
|
"-- Native Columns",
|
|
125
151
|
"CREATE INDEX IF NOT EXISTS idx_content_nodes_slug ON content_nodes (slug);",
|
|
@@ -130,7 +156,6 @@ const indexQueries = new Set([
|
|
|
130
156
|
|
|
131
157
|
function extractIndexes(obj) {
|
|
132
158
|
if (typeof obj !== 'object' || obj === null) return;
|
|
133
|
-
|
|
134
159
|
for (const [key, value] of Object.entries(obj)) {
|
|
135
160
|
if (typeof value === 'object' && value !== null) {
|
|
136
161
|
if (value.index === true && key !== "id" && key !== "slug" && key !== "contentType") {
|
|
@@ -148,5 +173,4 @@ const schemaSqlPath = path.resolve(process.cwd(), 'schema.sql');
|
|
|
148
173
|
|
|
149
174
|
if (fs.existsSync(schemaSqlPath)) {
|
|
150
175
|
fs.appendFileSync(schemaSqlPath, '\n\n' + sqlContent + '\n', 'utf-8');
|
|
151
|
-
console.log(`✅ Appended JSON auto-indexes directly to schema.sql`);
|
|
152
176
|
}
|