Skip to content

Commit de4ee2c

Browse files
davsclausclaude
andcommitted
CAMEL-23788: include Camel Catalog and YAML DSL schema in offline bundle
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1a67435 commit de4ee2c

3 files changed

Lines changed: 77 additions & 4 deletions

File tree

.github/workflows/offline-bundle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
TITLE="Apache Camel ${{ inputs.camel_version }} — Offline Documentation"
5555
NOTES="Offline documentation bundle for Apache Camel ${{ inputs.camel_version }}.
5656
57-
Contains all Markdown files for all connectors/components (350+) and the user manual.
57+
Contains all Markdown documentation for connectors/components (350+) and the user manual, plus the Camel Catalog (JSON metadata for all components, data formats, languages) and the YAML DSL canonical JSON Schema.
5858
5959
Download and unzip locally for AI coding agents or environments with restricted internet access."
6060

llms-txt-template.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ For agents or environments with no or restricted internet access, versioned offl
1313
- [Camel 4.18](https://github.com/apache/camel-website/releases/download/docs-4.18/camel-docs-4.18.zip)
1414
- [Camel 4.14](https://github.com/apache/camel-website/releases/download/docs-4.14/camel-docs-4.14.zip)
1515

16-
Download the zip matching your Camel version, unzip it locally, and read the `.md` files from there. Each bundle preserves the site directory structure and includes all connectors/components (350+) and the user manual.
16+
Download the zip matching your Camel version, unzip it locally, and read the files from there. Each bundle includes:
17+
- All connectors/components documentation (350+ as Markdown)
18+
- The user manual (Markdown)
19+
- The Camel Catalog — machine-readable JSON metadata for every component, data format, language, and EIP (parameters, types, defaults, descriptions)
20+
- The YAML DSL canonical JSON Schema — the definitive spec for validating and generating Camel YAML routes (`catalog/schema/camelYamlDsl-canonical.json`)
1721

1822
## Key facts
1923

scripts/generate-offline-bundle.js

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ const path = require('path');
33
const { execFileSync } = require('child_process');
44

55
const PUBLIC_DIR = 'public';
6+
const CAMEL_REPO = 'apache/camel';
7+
const CATALOG_BASE = 'catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog';
8+
const YAML_SCHEMA_PATH = 'dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl-canonical.json';
9+
10+
const CATALOG_DIRS = ['components', 'dataformats', 'languages', 'models', 'others'];
611

712
const VERSION_DIRS = [
813
'components'
@@ -12,6 +17,63 @@ const SHARED_DIRS = [
1217
'manual'
1318
];
1419

20+
function fetchCatalogAndSchema(version) {
21+
const branch = `camel-${version}.x`;
22+
const catalogDir = path.join(PUBLIC_DIR, 'catalog');
23+
24+
console.log(`\nFetching catalog and YAML DSL schema from ${CAMEL_REPO}@${branch}...`);
25+
26+
// fetch YAML DSL canonical schema
27+
const schemaDir = path.join(catalogDir, 'schema');
28+
fs.mkdirSync(schemaDir, { recursive: true });
29+
try {
30+
const schema = execFileSync('gh', [
31+
'api', `repos/${CAMEL_REPO}/contents/${YAML_SCHEMA_PATH}?ref=${branch}`,
32+
'--jq', '.content'
33+
], { encoding: 'utf8' });
34+
fs.writeFileSync(
35+
path.join(schemaDir, 'camelYamlDsl-canonical.json'),
36+
Buffer.from(schema.trim(), 'base64').toString('utf8')
37+
);
38+
console.log(' Fetched schema/camelYamlDsl-canonical.json');
39+
} catch (error) {
40+
console.warn(` Could not fetch YAML DSL schema: ${error.message}`);
41+
}
42+
43+
// fetch catalog JSON files for each category
44+
for (const dir of CATALOG_DIRS) {
45+
const targetDir = path.join(catalogDir, dir);
46+
fs.mkdirSync(targetDir, { recursive: true });
47+
try {
48+
const files = execFileSync('gh', [
49+
'api', `repos/${CAMEL_REPO}/contents/${CATALOG_BASE}/${dir}?ref=${branch}`,
50+
'--jq', '.[].name'
51+
], { encoding: 'utf8' }).trim().split('\n').filter(f => f.endsWith('.json'));
52+
53+
console.log(` Fetching catalog/${dir}/ (${files.length} files)...`);
54+
55+
for (const file of files) {
56+
try {
57+
const content = execFileSync('gh', [
58+
'api', `repos/${CAMEL_REPO}/contents/${CATALOG_BASE}/${dir}/${file}?ref=${branch}`,
59+
'--jq', '.content'
60+
], { encoding: 'utf8' });
61+
fs.writeFileSync(
62+
path.join(targetDir, file),
63+
Buffer.from(content.trim(), 'base64').toString('utf8')
64+
);
65+
} catch {
66+
// skip individual file failures silently
67+
}
68+
}
69+
} catch (error) {
70+
console.warn(` Could not fetch catalog/${dir}: ${error.message}`);
71+
}
72+
}
73+
74+
return fs.existsSync(catalogDir);
75+
}
76+
1577
function main() {
1678
const version = process.argv[2];
1779
if (!version) {
@@ -60,16 +122,23 @@ function main() {
60122
includePaths.push('llms.txt');
61123
}
62124

125+
// fetch catalog and YAML DSL schema from the camel repo
126+
if (fetchCatalogAndSchema(version)) {
127+
includePaths.push('catalog/*');
128+
}
129+
63130
// remove stale bundle
64131
if (fs.existsSync(bundlePath)) {
65132
fs.unlinkSync(bundlePath);
66133
}
67134

68-
// build zip: include only .md files from the selected directories, plus llms.txt
135+
// build zip: include .md files from doc dirs, plus .json from catalog, plus llms.txt
69136
const zipArgs = ['-r', '-q', bundleName, '.'];
70137
for (const p of includePaths) {
71138
if (p === 'llms.txt') {
72139
zipArgs.push('-i', 'llms.txt');
140+
} else if (p.startsWith('catalog/')) {
141+
zipArgs.push('-i', `${p}.json`);
73142
} else {
74143
zipArgs.push('-i', `${p}.md`);
75144
}
@@ -79,7 +148,7 @@ function main() {
79148
execFileSync('zip', zipArgs, { cwd: PUBLIC_DIR, stdio: 'inherit' });
80149

81150
const sizeMb = (fs.statSync(bundlePath).size / (1024 * 1024)).toFixed(1);
82-
console.log(`Generated ${bundleName} (${sizeMb} MB)`);
151+
console.log(`\nGenerated ${bundleName} (${sizeMb} MB)`);
83152
} catch (error) {
84153
console.error(`Failed to generate ${bundleName}:`, error.message);
85154
process.exit(1);

0 commit comments

Comments
 (0)