@eventcatalog/cli 0.2.1 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../node_modules/.pnpm/tsup@8.5.0_jiti@1.21.7_postcss@8.5.6_typescript@5.9.3_yaml@2.8.1/node_modules/tsup/assets/esm_shims.js","../../src/cli/index.ts","../../src/cli/executor.ts","../../src/cli/parser.ts","../../src/cli/list.ts"],"sourcesContent":["// Shim globals in esm bundle\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n","#!/usr/bin/env node\n\nimport { program } from 'commander';\nimport { readFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { executeFunction } from './executor';\nimport { listFunctions, formatListOutput } from './list';\n\n// Read package.json to get version\nlet version = '1.0.0';\ntry {\n const packageJsonPath = resolve(__dirname, '../../package.json');\n const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));\n version = packageJson.version;\n} catch {\n // Fall back to default version if package.json not found\n}\n\nprogram\n .name('eventcatalog')\n .description('EventCatalog Command-Line Interface')\n .version(version)\n .option('-d, --dir <path>', 'Path to the EventCatalog directory (default: current directory)', '.');\n\n// List command - show all available functions\nprogram\n .command('list')\n .description('List all available SDK functions')\n .action(() => {\n try {\n const functions = listFunctions('.');\n const output = formatListOutput(functions);\n console.log(output);\n } catch (error) {\n console.error('Error listing functions:', error instanceof Error ? error.message : String(error));\n process.exit(1);\n }\n });\n\n// Catch-all for any other command - execute as SDK function\nprogram.arguments('<function> [args...]').action(async (functionName: string, args: string[]) => {\n try {\n const options = program.opts() as any;\n const dir = options.dir || '.';\n const result = await executeFunction(dir, functionName, args);\n console.log(JSON.stringify(result, null, 0));\n } catch (error) {\n console.error(error instanceof Error ? error.message : String(error));\n process.exit(1);\n }\n});\n\nprogram.parse(process.argv);\n\n// Show help if no command provided\nif (process.argv.length < 3) {\n program.outputHelp();\n}\n","import { existsSync } from 'node:fs';\nimport { parseArguments } from './parser';\nimport createSDK from '@eventcatalog/sdk';\n\n/**\n * Execute a SDK function with the given arguments\n */\nexport async function executeFunction(catalogDir: string, functionName: string, rawArgs: string[]): Promise<any> {\n // Validate catalog directory exists\n if (!existsSync(catalogDir)) {\n throw new Error(`Catalog directory not found: ${catalogDir}`);\n }\n\n // Initialize the SDK\n const sdk = createSDK(catalogDir);\n\n // Validate function exists\n if (!(functionName in sdk)) {\n throw new Error(`Function '${functionName}' not found. Use 'eventcatalog list' to see available functions.`);\n }\n\n const fn = (sdk as any)[functionName];\n\n // Validate it's callable\n if (typeof fn !== 'function') {\n throw new Error(`'${functionName}' is not a callable function.`);\n }\n\n // Parse arguments\n const parsedArgs = parseArguments(rawArgs);\n\n // Execute function\n try {\n return await fn(...parsedArgs);\n } catch (error) {\n throw new Error(`Error executing '${functionName}': ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n","/**\n * Parse command-line arguments into typed values\n * Supports JSON objects/arrays, booleans, numbers, and strings\n */\nexport function parseArguments(rawArgs: string[]): any[] {\n return rawArgs.map((arg, index) => {\n // Try to parse as JSON object or array if it looks like JSON\n if ((arg.startsWith('{') && arg.endsWith('}')) || (arg.startsWith('[') && arg.endsWith(']'))) {\n try {\n return JSON.parse(arg);\n } catch (error) {\n // If it fails to parse as JSON, treat it as a string\n // Only throw error if it looks like valid JSON syntax was intended\n if (arg.includes(':') || arg.includes(',')) {\n throw new Error(`Invalid JSON in argument ${index + 1}: ${error instanceof Error ? error.message : String(error)}`);\n }\n // Otherwise, return as string\n return arg;\n }\n }\n\n // Parse booleans\n if (arg === 'true') return true;\n if (arg === 'false') return false;\n\n // Parse numbers\n if (/^-?\\d+(\\.\\d+)?$/.test(arg)) {\n return Number(arg);\n }\n\n // Return as string\n return arg;\n });\n}\n","import createSDK from '@eventcatalog/sdk';\n\ninterface CategorizedFunctions {\n [category: string]: string[];\n}\n\n/**\n * Get all available SDK functions organized by category\n */\nexport function listFunctions(catalogDir: string = '.'): CategorizedFunctions {\n // Initialize SDK to get all functions\n const sdk = createSDK(catalogDir);\n\n // Get all function names from SDK\n const functionNames = Object.keys(sdk).filter((key) => typeof (sdk as any)[key] === 'function');\n\n // Categorize functions based on naming patterns\n const categories: CategorizedFunctions = {\n Events: [],\n Commands: [],\n Queries: [],\n Channels: [],\n Services: [],\n Domains: [],\n Entities: [],\n DataStores: [],\n DataProducts: [],\n Teams: [],\n Users: [],\n 'Custom Docs': [],\n Messages: [],\n Utilities: [],\n };\n\n functionNames.forEach((name) => {\n if (name.includes('Event')) categories['Events'].push(name);\n else if (name.includes('Command')) categories['Commands'].push(name);\n else if (name.includes('Query')) categories['Queries'].push(name);\n else if (name.includes('Channel')) categories['Channels'].push(name);\n else if (name.includes('Service')) categories['Services'].push(name);\n else if (name.includes('Domain')) categories['Domains'].push(name);\n else if (name.includes('Entity')) categories['Entities'].push(name);\n else if (name.includes('DataStore')) categories['DataStores'].push(name);\n else if (name.includes('DataProduct')) categories['DataProducts'].push(name);\n else if (name.includes('Team')) categories['Teams'].push(name);\n else if (name.includes('User')) categories['Users'].push(name);\n else if (name.includes('CustomDoc')) categories['Custom Docs'].push(name);\n else if (name.includes('Message') || name.includes('Producers') || name.includes('Consumers'))\n categories['Messages'].push(name);\n else categories['Utilities'].push(name);\n });\n\n // Remove empty categories\n Object.keys(categories).forEach((key) => {\n if (categories[key].length === 0) {\n delete categories[key];\n }\n });\n\n return categories;\n}\n\n/**\n * Format and print categorized functions\n */\nexport function formatListOutput(functions: CategorizedFunctions): string {\n let output = 'Available EventCatalog SDK Functions:\\n\\n';\n\n Object.entries(functions).forEach(([category, names]) => {\n output += `${category}:\\n`;\n names.sort().forEach((name) => {\n output += ` - ${name}\\n`;\n });\n output += '\\n';\n });\n\n return output;\n}\n"],"mappings":";;;AACA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CAAqC,EACjD,QAAQ,OAAO,EACf,OAAO,oBAAoB,mEAAmE,GAAG;AAGpG,QACG,QAAQ,MAAM,EACd,YAAY,kCAAkC,EAC9C,OAAO,MAAM;AACZ,MAAI;AACF,UAAM,YAAY,cAAc,GAAG;AACnC,UAAM,SAAS,iBAAiB,SAAS;AACzC,YAAQ,IAAI,MAAM;AAAA,EACpB,SAAS,OAAO;AACd,YAAQ,MAAM,4BAA4B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAChG,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF,CAAC;AAGH,QAAQ,UAAU,sBAAsB,EAAE,OAAO,OAAO,cAAsB,SAAmB;AAC/F,MAAI;AACF,UAAM,UAAU,QAAQ,KAAK;AAC7B,UAAM,MAAM,QAAQ,OAAO;AAC3B,UAAM,SAAS,MAAM,gBAAgB,KAAK,cAAc,IAAI;AAC5D,YAAQ,IAAI,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC;AAAA,EAC7C,SAAS,OAAO;AACd,YAAQ,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AACpE,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF,CAAC;AAED,QAAQ,MAAM,QAAQ,IAAI;AAG1B,IAAI,QAAQ,KAAK,SAAS,GAAG;AAC3B,UAAQ,WAAW;AACrB;","names":["createSDK"]}
1
+ {"version":3,"sources":["../../../../node_modules/.pnpm/tsup@8.5.0_jiti@2.6.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3_yaml@2.8.1/node_modules/tsup/assets/esm_shims.js","../../src/cli/index.ts","../../src/cli/executor.ts","../../src/cli/parser.ts","../../src/cli/list.ts","../../src/cli/export.ts"],"sourcesContent":["// Shim globals in esm bundle\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n","#!/usr/bin/env node\n\nimport { program } from 'commander';\nimport { readFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { executeFunction } from './executor';\nimport { listFunctions, formatListOutput } from './list';\nimport { exportResource, exportCatalog } from './export';\n\n// Read package.json to get version\nlet version = '1.0.0';\ntry {\n const packageJsonPath = resolve(__dirname, '../../package.json');\n const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));\n version = packageJson.version;\n} catch {\n // Fall back to default version if package.json not found\n}\n\nprogram\n .name('eventcatalog')\n .description('EventCatalog Command-Line Interface')\n .version(version)\n .option('-d, --dir <path>', 'Path to the EventCatalog directory (default: current directory)', '.');\n\n// List command - show all available functions\nprogram\n .command('list')\n .description('List all available SDK functions')\n .action(() => {\n try {\n const functions = listFunctions('.');\n const output = formatListOutput(functions);\n console.log(output);\n } catch (error) {\n console.error('Error listing functions:', error instanceof Error ? error.message : String(error));\n process.exit(1);\n }\n });\n\n// Export command - export a resource to .ec DSL format\nprogram\n .command('export')\n .description('Export a catalog resource to EventCatalog DSL (.ec) format')\n .option('-a, --all', 'Export the entire catalog (all resource types)', false)\n .option('-r, --resource <type>', 'Resource type (event, command, query, service, domain)')\n .option('--id <id>', 'Resource ID (omit to export all resources of the given type)')\n .option('-v, --version <version>', 'Resource version (defaults to latest)')\n .option('--hydrate', 'Include referenced resources (messages, channels, owners)', false)\n .option('--stdout', 'Print to stdout instead of writing a file', false)\n .option('--playground', 'Open the exported DSL in the playground', false)\n .option('-o, --output <path>', 'Output file path (defaults to <id>.ec or catalog.ec)')\n .action(async (opts) => {\n try {\n const globalOpts = program.opts() as any;\n const dir = globalOpts.dir || '.';\n\n if (opts.all) {\n const result = await exportCatalog({\n hydrate: opts.hydrate,\n stdout: opts.stdout,\n playground: opts.playground,\n output: opts.output,\n dir,\n });\n console.log(result);\n return;\n }\n\n if (!opts.resource) {\n console.error('Either --all or --resource is required');\n process.exit(1);\n }\n\n const result = await exportResource({\n resource: opts.resource,\n id: opts.id,\n version: opts.version,\n hydrate: opts.hydrate,\n stdout: opts.stdout,\n playground: opts.playground,\n output: opts.output,\n dir,\n });\n console.log(result);\n } catch (error) {\n console.error(error instanceof Error ? error.message : String(error));\n process.exit(1);\n }\n });\n\n// Catch-all for any other command - execute as SDK function\nprogram.arguments('<function> [args...]').action(async (functionName: string, args: string[]) => {\n try {\n const options = program.opts() as any;\n const dir = options.dir || '.';\n const result = await executeFunction(dir, functionName, args);\n console.log(JSON.stringify(result, null, 0));\n } catch (error) {\n console.error(error instanceof Error ? error.message : String(error));\n process.exit(1);\n }\n});\n\nprogram.parse(process.argv);\n\n// Show help if no command provided\nif (process.argv.length < 3) {\n program.outputHelp();\n}\n","import { existsSync } from 'node:fs';\nimport { parseArguments } from './parser';\nimport createSDK from '@eventcatalog/sdk';\n\n/**\n * Execute a SDK function with the given arguments\n */\nexport async function executeFunction(catalogDir: string, functionName: string, rawArgs: string[]): Promise<any> {\n // Validate catalog directory exists\n if (!existsSync(catalogDir)) {\n throw new Error(`Catalog directory not found: ${catalogDir}`);\n }\n\n // Initialize the SDK\n const sdk = createSDK(catalogDir);\n\n // Validate function exists\n if (!(functionName in sdk)) {\n throw new Error(`Function '${functionName}' not found. Use 'eventcatalog list' to see available functions.`);\n }\n\n const fn = (sdk as any)[functionName];\n\n // Validate it's callable\n if (typeof fn !== 'function') {\n throw new Error(`'${functionName}' is not a callable function.`);\n }\n\n // Parse arguments\n const parsedArgs = parseArguments(rawArgs);\n\n // Execute function\n try {\n return await fn(...parsedArgs);\n } catch (error) {\n throw new Error(`Error executing '${functionName}': ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n","/**\n * Parse command-line arguments into typed values\n * Supports JSON objects/arrays, booleans, numbers, and strings\n */\nexport function parseArguments(rawArgs: string[]): any[] {\n return rawArgs.map((arg, index) => {\n // Try to parse as JSON object or array if it looks like JSON\n if ((arg.startsWith('{') && arg.endsWith('}')) || (arg.startsWith('[') && arg.endsWith(']'))) {\n try {\n return JSON.parse(arg);\n } catch (error) {\n // If it fails to parse as JSON, treat it as a string\n // Only throw error if it looks like valid JSON syntax was intended\n if (arg.includes(':') || arg.includes(',')) {\n throw new Error(`Invalid JSON in argument ${index + 1}: ${error instanceof Error ? error.message : String(error)}`);\n }\n // Otherwise, return as string\n return arg;\n }\n }\n\n // Parse booleans\n if (arg === 'true') return true;\n if (arg === 'false') return false;\n\n // Parse numbers\n if (/^-?\\d+(\\.\\d+)?$/.test(arg)) {\n return Number(arg);\n }\n\n // Return as string\n return arg;\n });\n}\n","import createSDK from '@eventcatalog/sdk';\n\ninterface CategorizedFunctions {\n [category: string]: string[];\n}\n\n/**\n * Get all available SDK functions organized by category\n */\nexport function listFunctions(catalogDir: string = '.'): CategorizedFunctions {\n // Initialize SDK to get all functions\n const sdk = createSDK(catalogDir);\n\n // Get all function names from SDK\n const functionNames = Object.keys(sdk).filter((key) => typeof (sdk as any)[key] === 'function');\n\n // Categorize functions based on naming patterns\n const categories: CategorizedFunctions = {\n Events: [],\n Commands: [],\n Queries: [],\n Channels: [],\n Services: [],\n Domains: [],\n Entities: [],\n DataStores: [],\n DataProducts: [],\n Teams: [],\n Users: [],\n 'Custom Docs': [],\n Messages: [],\n Utilities: [],\n };\n\n functionNames.forEach((name) => {\n if (name.includes('Event')) categories['Events'].push(name);\n else if (name.includes('Command')) categories['Commands'].push(name);\n else if (name.includes('Query')) categories['Queries'].push(name);\n else if (name.includes('Channel')) categories['Channels'].push(name);\n else if (name.includes('Service')) categories['Services'].push(name);\n else if (name.includes('Domain')) categories['Domains'].push(name);\n else if (name.includes('Entity')) categories['Entities'].push(name);\n else if (name.includes('DataStore')) categories['DataStores'].push(name);\n else if (name.includes('DataProduct')) categories['DataProducts'].push(name);\n else if (name.includes('Team')) categories['Teams'].push(name);\n else if (name.includes('User')) categories['Users'].push(name);\n else if (name.includes('CustomDoc')) categories['Custom Docs'].push(name);\n else if (name.includes('Message') || name.includes('Producers') || name.includes('Consumers'))\n categories['Messages'].push(name);\n else categories['Utilities'].push(name);\n });\n\n // Remove empty categories\n Object.keys(categories).forEach((key) => {\n if (categories[key].length === 0) {\n delete categories[key];\n }\n });\n\n return categories;\n}\n\n/**\n * Format and print categorized functions\n */\nexport function formatListOutput(functions: CategorizedFunctions): string {\n let output = 'Available EventCatalog SDK Functions:\\n\\n';\n\n Object.entries(functions).forEach(([category, names]) => {\n output += `${category}:\\n`;\n names.sort().forEach((name) => {\n output += ` - ${name}\\n`;\n });\n output += '\\n';\n });\n\n return output;\n}\n","import { writeFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport open from 'open';\nimport createSDK from '@eventcatalog/sdk';\n\nconst RESOURCE_TYPES = ['event', 'command', 'query', 'service', 'domain'] as const;\ntype ResourceType = (typeof RESOURCE_TYPES)[number];\n\nconst PLURAL_MAP: Record<string, ResourceType> = {\n events: 'event',\n commands: 'command',\n queries: 'query',\n services: 'service',\n domains: 'domain',\n};\n\ninterface ExportOptions {\n resource: string;\n id?: string;\n version?: string;\n hydrate?: boolean;\n stdout?: boolean;\n playground?: boolean;\n output?: string;\n dir: string;\n}\n\nfunction normalizeResourceType(resource: string): ResourceType {\n const lower = resource.toLowerCase();\n if (PLURAL_MAP[lower]) return PLURAL_MAP[lower];\n return lower as ResourceType;\n}\n\nfunction getResourceFetcher(sdk: ReturnType<typeof createSDK>, type: ResourceType) {\n switch (type) {\n case 'event':\n return sdk.getEvent;\n case 'command':\n return sdk.getCommand;\n case 'query':\n return sdk.getQuery;\n case 'service':\n return sdk.getService;\n case 'domain':\n return sdk.getDomain;\n }\n}\n\nfunction getCollectionFetcher(sdk: ReturnType<typeof createSDK>, type: ResourceType) {\n switch (type) {\n case 'event':\n return sdk.getEvents;\n case 'command':\n return sdk.getCommands;\n case 'query':\n return sdk.getQueries;\n case 'service':\n return sdk.getServices;\n case 'domain':\n return sdk.getDomains;\n }\n}\n\nfunction pluralize(type: ResourceType): string {\n if (type === 'query') return 'queries';\n return `${type}s`;\n}\n\nconst SECTION_ORDER = ['team', 'user', 'channel', 'event', 'command', 'query', 'service', 'domain'] as const;\n\nconst SECTION_LABELS: Record<string, string> = {\n team: 'TEAMS',\n user: 'USERS',\n channel: 'CHANNELS',\n event: 'EVENTS',\n command: 'COMMANDS',\n query: 'QUERIES',\n service: 'SERVICES',\n domain: 'DOMAINS',\n};\n\nfunction groupDSLBlocks(dsl: string): string {\n const blocks = dsl.split(/\\n\\n/).filter((b) => b.trim());\n const buckets: Record<string, string[]> = {};\n\n for (const block of blocks) {\n const firstWord = block.trimStart().split(/\\s/)[0];\n const key = firstWord === 'subdomain' ? 'domain' : firstWord;\n if (!buckets[key]) buckets[key] = [];\n buckets[key].push(block);\n }\n\n const sections: string[] = [];\n for (const type of SECTION_ORDER) {\n if (!buckets[type] || buckets[type].length === 0) continue;\n const label = SECTION_LABELS[type] || type.toUpperCase();\n sections.push(`// ${label}\\n${buckets[type].join('\\n\\n')}`);\n delete buckets[type];\n }\n\n // Any remaining types not in SECTION_ORDER\n for (const [type, items] of Object.entries(buckets)) {\n if (items.length === 0) continue;\n const label = type.toUpperCase();\n sections.push(`// ${label}\\n${items.join('\\n\\n')}`);\n }\n\n return sections.join('\\n\\n');\n}\n\nconst VISUALIZER_TYPES = ['event', 'command', 'query', 'service', 'domain'] as const;\n\nfunction buildVisualizerBlock(dsl: string, name: string, filterTypes: ResourceType | ResourceType[]): string {\n const types = Array.isArray(filterTypes) ? filterTypes : [filterTypes];\n const entries: string[] = [];\n\n for (const line of dsl.split('\\n')) {\n const trimmed = line.trimStart();\n const parts = trimmed.split(/\\s/);\n const keyword = parts[0];\n const id = parts[1];\n if (!types.includes(keyword as ResourceType)) continue;\n if (!id || !trimmed.endsWith('{')) continue;\n entries.push(` ${keyword} ${id}`);\n }\n\n if (entries.length === 0) return '';\n return `\\nvisualizer main {\\n name \"${name}\"\\n${entries.join('\\n')}\\n}`;\n}\n\nexport async function exportCatalog(options: Omit<ExportOptions, 'resource'>): Promise<string> {\n const { hydrate = false, stdout = false, playground = false, output, dir } = options;\n\n const sdk = createSDK(dir);\n const dslParts: string[] = [];\n\n for (const type of RESOURCE_TYPES) {\n const fetcher = getCollectionFetcher(sdk, type);\n const resources = await fetcher({ latestOnly: true });\n if (!resources || resources.length === 0) continue;\n const rawDsl = await sdk.toDSL(resources, { type, hydrate });\n dslParts.push(rawDsl);\n }\n\n if (dslParts.length === 0) {\n throw new Error(`No resources found in catalog at '${dir}'`);\n }\n\n const combined = dslParts.join('\\n\\n');\n const grouped = groupDSLBlocks(combined);\n const vizBlock = buildVisualizerBlock(grouped, 'Full Catalog', [...RESOURCE_TYPES]);\n const dsl = vizBlock ? `${grouped}\\n${vizBlock}` : grouped;\n\n if (stdout) {\n return dsl;\n }\n\n const filename = output || 'catalog.ec';\n const filepath = resolve(filename);\n writeFileSync(filepath, dsl + '\\n', 'utf-8');\n\n const lines = ['', ` Exported full catalog to ${filepath}`];\n\n if (playground) {\n const encoded = Buffer.from(dsl).toString('base64');\n const playgroundUrl = `https://playground.eventcatalog.dev/?code=${encoded}`;\n await open(playgroundUrl);\n lines.push('', ` Opening in playground...`);\n } else {\n lines.push('', ` Tip: Use --playground to open in the playground`);\n }\n\n lines.push('');\n return lines.join('\\n');\n}\n\nexport async function exportAll(options: ExportOptions): Promise<string> {\n const { resource, hydrate = false, stdout = false, playground = false, output, dir } = options;\n\n const type = normalizeResourceType(resource);\n if (!RESOURCE_TYPES.includes(type)) {\n throw new Error(`Invalid resource type '${resource}'. Must be one of: ${RESOURCE_TYPES.join(', ')}`);\n }\n\n const plural = pluralize(type);\n const sdk = createSDK(dir);\n\n const fetcher = getCollectionFetcher(sdk, type);\n const allResources = (await fetcher({ latestOnly: true })) || [];\n\n if (allResources.length === 0) {\n throw new Error(`No ${plural} found in catalog at '${dir}'`);\n }\n\n const rawDsl = await sdk.toDSL(allResources, { type, hydrate });\n const grouped = groupDSLBlocks(rawDsl);\n const vizBlock = buildVisualizerBlock(grouped, `All ${plural}`, type);\n const dsl = vizBlock ? `${grouped}\\n${vizBlock}` : grouped;\n\n if (stdout) {\n return dsl;\n }\n\n const filename = output || `${plural}.ec`;\n const filepath = resolve(filename);\n writeFileSync(filepath, dsl + '\\n', 'utf-8');\n\n const lines = ['', ` Exported ${allResources.length} ${plural} to ${filepath}`];\n\n if (playground) {\n const encoded = Buffer.from(dsl).toString('base64');\n const playgroundUrl = `https://playground.eventcatalog.dev/?code=${encoded}`;\n await open(playgroundUrl);\n lines.push('', ` Opening in playground...`);\n } else {\n lines.push('', ` Tip: Use --playground to open in the playground`);\n }\n\n lines.push('');\n return lines.join('\\n');\n}\n\nexport async function exportResource(options: ExportOptions): Promise<string> {\n const { resource, id, version, hydrate = false, stdout = false, playground = false, output, dir } = options;\n\n if (!id) {\n return exportAll(options);\n }\n\n const type = normalizeResourceType(resource);\n if (!RESOURCE_TYPES.includes(type)) {\n throw new Error(`Invalid resource type '${resource}'. Must be one of: ${RESOURCE_TYPES.join(', ')}`);\n }\n\n const sdk = createSDK(dir);\n\n const fetcher = getResourceFetcher(sdk, type);\n const data = await fetcher(id, version);\n\n if (!data) {\n const versionStr = version ? `@${version}` : ' (latest)';\n throw new Error(`${resource} '${id}${versionStr}' not found in catalog at '${dir}'`);\n }\n\n const rawDsl = await sdk.toDSL(data, { type, hydrate });\n const grouped = hydrate ? groupDSLBlocks(rawDsl) : rawDsl;\n const vizBlock = buildVisualizerBlock(grouped, `View of ${id}`, type);\n const dsl = vizBlock ? `${grouped}\\n${vizBlock}` : grouped;\n\n if (stdout) {\n return dsl;\n }\n\n const filename = output || `${id}.ec`;\n const filepath = resolve(filename);\n writeFileSync(filepath, dsl + '\\n', 'utf-8');\n\n const lines = ['', ` Exported ${type} '${id}' to ${filepath}`];\n\n if (playground) {\n const encoded = Buffer.from(dsl).toString('base64');\n const playgroundUrl = `https://playground.eventcatalog.dev/?code=${encoded}`;\n await open(playgroundUrl);\n lines.push('', ` Opening in playground...`);\n } else {\n lines.push('', ` Tip: Use --playground to open in the playground`);\n }\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
  category: "Utilities",
1594
1594
  args: [],
1595
1595
  examples: [{ description: "Get config file", command: "npx @eventcatalog/cli getEventCatalogConfigurationFile" }]
1596
+ },
1597
+ // ================================
1598
+ // Export (DSL)
1599
+ // ================================
1600
+ {
1601
+ name: "export",
1602
+ description: "Export catalog resources to EventCatalog DSL (.ec) format",
1603
+ category: "Export",
1604
+ args: [
1605
+ { name: "all", type: "boolean", required: false, description: "Export the entire catalog (all resource types)" },
1606
+ {
1607
+ name: "resource",
1608
+ type: "string",
1609
+ required: false,
1610
+ description: "Resource type: event, command, query, service, domain (or plural forms)"
1611
+ },
1612
+ { name: "id", type: "string", required: false, description: "Resource ID (omit to export all of the given type)" },
1613
+ { name: "version", type: "string", required: false, description: "Resource version (defaults to latest)" },
1614
+ {
1615
+ name: "hydrate",
1616
+ type: "boolean",
1617
+ required: false,
1618
+ description: "Include referenced resources (messages, channels, owners)"
1619
+ },
1620
+ { name: "stdout", type: "boolean", required: false, description: "Print to stdout instead of writing a file" },
1621
+ { name: "playground", type: "boolean", required: false, description: "Open the exported DSL in the playground" },
1622
+ { name: "output", type: "string", required: false, description: "Output file path (defaults to <id>.ec or catalog.ec)" }
1623
+ ],
1624
+ examples: [
1625
+ {
1626
+ description: "Export a single service",
1627
+ command: "npx @eventcatalog/cli export --resource service --id OrderService"
1628
+ },
1629
+ {
1630
+ description: "Export a service with all dependencies",
1631
+ command: "npx @eventcatalog/cli export --resource service --id OrderService --hydrate"
1632
+ },
1633
+ {
1634
+ description: "Export all services",
1635
+ command: "npx @eventcatalog/cli export --resource services"
1636
+ },
1637
+ {
1638
+ description: "Export all services with hydration to stdout",
1639
+ command: "npx @eventcatalog/cli export --resource services --hydrate --stdout"
1640
+ },
1641
+ {
1642
+ description: "Export the entire catalog",
1643
+ command: "npx @eventcatalog/cli export --all --hydrate"
1644
+ },
1645
+ {
1646
+ description: "Export entire catalog to a custom file",
1647
+ command: "npx @eventcatalog/cli export --all --hydrate -o my-catalog.ec"
1648
+ },
1649
+ {
1650
+ description: "Export and open in playground",
1651
+ command: "npx @eventcatalog/cli export --resource services --hydrate --playground"
1652
+ }
1653
+ ]
1596
1654
  }
1597
1655
  ];
1598
1656
  function getCategories() {