mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-28 03:00:29 -04:00
feat(integrations): add integrationType and tags classification to all blocks (#3702)
* feat(integrations): add integrationType and tags classification to all blocks * improvement(integrations): replace generic api/oauth tags with use-case-oriented tags * lint * upgrade turbo
This commit is contained in:
@@ -79,6 +79,8 @@ interface IntegrationEntry {
|
||||
triggerCount: number
|
||||
authType: 'oauth' | 'api-key' | 'none'
|
||||
category: string
|
||||
integrationType?: string
|
||||
tags?: string[]
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -592,6 +594,8 @@ async function writeIntegrationsJson(iconMapping: Record<string, string>): Promi
|
||||
triggerCount: triggers.length,
|
||||
authType,
|
||||
category: config.category,
|
||||
...(config.integrationType ? { integrationType: config.integrationType } : {}),
|
||||
...(config.tags ? { tags: config.tags } : {}),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -759,9 +763,18 @@ function extractBlockConfigFromContent(
|
||||
const triggerIds = extractTriggersAvailable(blockContent)
|
||||
const docsLink =
|
||||
extractStringPropertyFromContent(blockContent, 'docsLink', true) ||
|
||||
(baseConfig as any)?.docsLink ||
|
||||
baseConfig?.docsLink ||
|
||||
`https://docs.sim.ai/tools/${stripVersionSuffix(blockType)}`
|
||||
|
||||
const integrationType =
|
||||
extractEnumPropertyFromContent(blockContent, 'integrationType') ||
|
||||
baseConfig?.integrationType ||
|
||||
null
|
||||
const tags =
|
||||
extractArrayPropertyFromContent(blockContent, 'tags') ||
|
||||
baseConfig?.tags ||
|
||||
null
|
||||
|
||||
return {
|
||||
type: blockType,
|
||||
name,
|
||||
@@ -777,6 +790,8 @@ function extractBlockConfigFromContent(
|
||||
operations: operations.length > 0 ? operations : (baseConfig as any)?.operations || [],
|
||||
triggerIds: triggerIds.length > 0 ? triggerIds : (baseConfig as any)?.triggerIds || [],
|
||||
docsLink,
|
||||
...(integrationType ? { integrationType } : {}),
|
||||
...(tags ? { tags } : {}),
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error extracting block configuration for ${blockName}:`, error)
|
||||
@@ -841,6 +856,54 @@ function extractStringPropertyFromContent(
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract an enum property value from block content.
|
||||
* Matches patterns like `integrationType: IntegrationType.DeveloperTools`
|
||||
* and returns the string value (e.g., 'developer-tools').
|
||||
*/
|
||||
function extractEnumPropertyFromContent(content: string, propName: string): string | null {
|
||||
const match = content.match(new RegExp(`${propName}\\s*:\\s*IntegrationType\\.(\\w+)`))
|
||||
if (!match) return null
|
||||
const enumKey = match[1]
|
||||
// Convert enum key to kebab-case value (e.g., DeveloperTools -> developer-tools)
|
||||
const ENUM_MAP: Record<string, string> = {
|
||||
AI: 'ai',
|
||||
Analytics: 'analytics',
|
||||
Automation: 'automation',
|
||||
Communication: 'communication',
|
||||
CRM: 'crm',
|
||||
CustomerSupport: 'customer-support',
|
||||
Databases: 'databases',
|
||||
Design: 'design',
|
||||
DeveloperTools: 'developer-tools',
|
||||
Documents: 'documents',
|
||||
Ecommerce: 'ecommerce',
|
||||
Email: 'email',
|
||||
FileStorage: 'file-storage',
|
||||
HR: 'hr',
|
||||
Media: 'media',
|
||||
Other: 'other',
|
||||
Productivity: 'productivity',
|
||||
SalesIntelligence: 'sales-intelligence',
|
||||
Search: 'search',
|
||||
Security: 'security',
|
||||
Social: 'social',
|
||||
}
|
||||
return ENUM_MAP[enumKey] || enumKey.toLowerCase()
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract a string array property from block content.
|
||||
* Matches patterns like `tags: ['api', 'oauth', 'webhooks']`
|
||||
*/
|
||||
function extractArrayPropertyFromContent(content: string, propName: string): string[] | null {
|
||||
const match = content.match(new RegExp(`${propName}\\s*:\\s*\\[([^\\]]+)\\]`))
|
||||
if (!match) return null
|
||||
const items = match[1].match(/'([^']+)'|"([^"]+)"/g)
|
||||
if (!items) return null
|
||||
return items.map((item) => item.replace(/['"]/g, ''))
|
||||
}
|
||||
|
||||
function extractIconNameFromContent(content: string): string | null {
|
||||
const iconMatch = content.match(/icon\s*:\s*(\w+Icon)/)
|
||||
return iconMatch ? iconMatch[1] : null
|
||||
|
||||
Reference in New Issue
Block a user