Add Python/Ruby code pieces and fix template loading performance
- Add Python code execution piece with subprocess-based runner - Add Ruby code execution piece with subprocess-based runner - Fix template loading: fetch individual templates from cloud for community edition - Add piece name aliasing for renamed pieces (piece-text-ai → piece-ai, etc.) - Add dev pieces caching to avoid disk reads on every request (60s TTL) - Add Python and Ruby logos to Django static files 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -25,6 +25,29 @@ export const communityTemplates = {
|
||||
const templates = await response.json()
|
||||
return templates
|
||||
},
|
||||
getById: async (id: string): Promise<Template | null> => {
|
||||
const templateSource = system.get(AppSystemProp.TEMPLATES_SOURCE_URL)
|
||||
if (isNil(templateSource)) {
|
||||
return null
|
||||
}
|
||||
// Fetch the template by ID from the cloud templates endpoint
|
||||
const url = `${templateSource}/${id}`
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
})
|
||||
if (!response.ok) {
|
||||
return null
|
||||
}
|
||||
return await response.json()
|
||||
}
|
||||
catch {
|
||||
return null
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -27,6 +27,14 @@ const edition = system.getEdition()
|
||||
|
||||
export const templateController: FastifyPluginAsyncTypebox = async (app) => {
|
||||
app.get('/:id', GetParams, async (request) => {
|
||||
// For community edition, try to fetch from cloud templates first
|
||||
if (edition !== ApEdition.CLOUD) {
|
||||
const cloudTemplate = await communityTemplates.getById(request.params.id)
|
||||
if (!isNil(cloudTemplate)) {
|
||||
return cloudTemplate
|
||||
}
|
||||
}
|
||||
// Fall back to local database
|
||||
return templateService().getOneOrThrow({ id: request.params.id })
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user