Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function defaultInitialValueTemplateItems(
schema: Schema = getDefaultSchema()
): InitialValueTemplateItemBuilder[] {
const templates = getTemplates()
// Don't list templates that require parameters
.filter(tpl => !tpl.parameters || tpl.parameters.length === 0)
// Don't list templates that we can't create
.filter(tpl => isActionEnabled(schema.get(tpl.schemaType), 'create'))
// Sort templates by their schema type, in order or definition
const typeNames = schema.getTypeNames()
const ordered = templates.sort(
(a, b) => typeNames.indexOf(a.schemaType) - typeNames.indexOf(b.schemaType)
)
// Create actual template items out of the templates
return ordered.map(tpl => StructureBuilder.initialValueTemplateItem(tpl.id))
}