Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

711 B
Raw Blame
const CONNECTION_TEMPLATE = /^\{\{connections\['([^']+)'\]\}\}$/

function unwrapExternalId(auth: unknown): string | null {
    if (typeof auth !== 'string' || auth.length === 0) {
        return null
    }
    return auth.match(CONNECTION_TEMPLATE)?.[1] ?? auth
}

function isTemplate(auth: unknown): auth is string {
    return typeof auth === 'string' && CONNECTION_TEMPLATE.test(auth)
}

function wrapExternalId(auth: unknown): string | null {
    if (isTemplate(auth)) {
        return auth
    }
    if (typeof auth !== 'string' || auth.length === 0) {
        return null
    }
    return `{{connections['${auth}']}}`
}

export const connectionTemplate = { unwrapExternalId, isTemplate, wrapExternalId }