@eventcatalog/cli 0.2.0 → 0.3.0

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.
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
@@ -0,0 +1,424 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
+ // If the importer is in node compatibility mode or this is not an ESM
19
+ // file that has been converted to a CommonJS file using a Babel-
20
+ // compatible transform (i.e. "__esModule" has not been set), then set
21
+ // "default" to the CommonJS "module.exports" for node compatibility.
22
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
+ mod
24
+ ));
25
+
26
+ // src/cli/index.ts
27
+ var import_commander = require("commander");
28
+ var import_node_fs3 = require("fs");
29
+ var import_node_path2 = require("path");
30
+
31
+ // src/cli/executor.ts
32
+ var import_node_fs = require("fs");
33
+
34
+ // src/cli/parser.ts
35
+ function parseArguments(rawArgs) {
36
+ return rawArgs.map((arg, index) => {
37
+ if (arg.startsWith("{") && arg.endsWith("}") || arg.startsWith("[") && arg.endsWith("]")) {
38
+ try {
39
+ return JSON.parse(arg);
40
+ } catch (error) {
41
+ if (arg.includes(":") || arg.includes(",")) {
42
+ throw new Error(`Invalid JSON in argument ${index + 1}: ${error instanceof Error ? error.message : String(error)}`);
43
+ }
44
+ return arg;
45
+ }
46
+ }
47
+ if (arg === "true") return true;
48
+ if (arg === "false") return false;
49
+ if (/^-?\d+(\.\d+)?$/.test(arg)) {
50
+ return Number(arg);
51
+ }
52
+ return arg;
53
+ });
54
+ }
55
+
56
+ // src/cli/executor.ts
57
+ var import_sdk = __toESM(require("@eventcatalog/sdk"));
58
+ async function executeFunction(catalogDir, functionName, rawArgs) {
59
+ if (!(0, import_node_fs.existsSync)(catalogDir)) {
60
+ throw new Error(`Catalog directory not found: ${catalogDir}`);
61
+ }
62
+ const sdk = (0, import_sdk.default)(catalogDir);
63
+ if (!(functionName in sdk)) {
64
+ throw new Error(`Function '${functionName}' not found. Use 'eventcatalog list' to see available functions.`);
65
+ }
66
+ const fn = sdk[functionName];
67
+ if (typeof fn !== "function") {
68
+ throw new Error(`'${functionName}' is not a callable function.`);
69
+ }
70
+ const parsedArgs = parseArguments(rawArgs);
71
+ try {
72
+ return await fn(...parsedArgs);
73
+ } catch (error) {
74
+ throw new Error(`Error executing '${functionName}': ${error instanceof Error ? error.message : String(error)}`);
75
+ }
76
+ }
77
+
78
+ // src/cli/list.ts
79
+ var import_sdk2 = __toESM(require("@eventcatalog/sdk"));
80
+ function listFunctions(catalogDir = ".") {
81
+ const sdk = (0, import_sdk2.default)(catalogDir);
82
+ const functionNames = Object.keys(sdk).filter((key) => typeof sdk[key] === "function");
83
+ const categories = {
84
+ Events: [],
85
+ Commands: [],
86
+ Queries: [],
87
+ Channels: [],
88
+ Services: [],
89
+ Domains: [],
90
+ Entities: [],
91
+ DataStores: [],
92
+ DataProducts: [],
93
+ Teams: [],
94
+ Users: [],
95
+ "Custom Docs": [],
96
+ Messages: [],
97
+ Utilities: []
98
+ };
99
+ functionNames.forEach((name) => {
100
+ if (name.includes("Event")) categories["Events"].push(name);
101
+ else if (name.includes("Command")) categories["Commands"].push(name);
102
+ else if (name.includes("Query")) categories["Queries"].push(name);
103
+ else if (name.includes("Channel")) categories["Channels"].push(name);
104
+ else if (name.includes("Service")) categories["Services"].push(name);
105
+ else if (name.includes("Domain")) categories["Domains"].push(name);
106
+ else if (name.includes("Entity")) categories["Entities"].push(name);
107
+ else if (name.includes("DataStore")) categories["DataStores"].push(name);
108
+ else if (name.includes("DataProduct")) categories["DataProducts"].push(name);
109
+ else if (name.includes("Team")) categories["Teams"].push(name);
110
+ else if (name.includes("User")) categories["Users"].push(name);
111
+ else if (name.includes("CustomDoc")) categories["Custom Docs"].push(name);
112
+ else if (name.includes("Message") || name.includes("Producers") || name.includes("Consumers"))
113
+ categories["Messages"].push(name);
114
+ else categories["Utilities"].push(name);
115
+ });
116
+ Object.keys(categories).forEach((key) => {
117
+ if (categories[key].length === 0) {
118
+ delete categories[key];
119
+ }
120
+ });
121
+ return categories;
122
+ }
123
+ function formatListOutput(functions) {
124
+ let output = "Available EventCatalog SDK Functions:\n\n";
125
+ Object.entries(functions).forEach(([category, names]) => {
126
+ output += `${category}:
127
+ `;
128
+ names.sort().forEach((name) => {
129
+ output += ` - ${name}
130
+ `;
131
+ });
132
+ output += "\n";
133
+ });
134
+ return output;
135
+ }
136
+
137
+ // src/cli/export.ts
138
+ var import_node_fs2 = require("fs");
139
+ var import_node_path = require("path");
140
+ var import_open = __toESM(require("open"));
141
+ var import_sdk3 = __toESM(require("@eventcatalog/sdk"));
142
+ var RESOURCE_TYPES = ["event", "command", "query", "service", "domain"];
143
+ var PLURAL_MAP = {
144
+ events: "event",
145
+ commands: "command",
146
+ queries: "query",
147
+ services: "service",
148
+ domains: "domain"
149
+ };
150
+ function normalizeResourceType(resource) {
151
+ const lower = resource.toLowerCase();
152
+ if (PLURAL_MAP[lower]) return PLURAL_MAP[lower];
153
+ return lower;
154
+ }
155
+ function getResourceFetcher(sdk, type) {
156
+ switch (type) {
157
+ case "event":
158
+ return sdk.getEvent;
159
+ case "command":
160
+ return sdk.getCommand;
161
+ case "query":
162
+ return sdk.getQuery;
163
+ case "service":
164
+ return sdk.getService;
165
+ case "domain":
166
+ return sdk.getDomain;
167
+ }
168
+ }
169
+ function getCollectionFetcher(sdk, type) {
170
+ switch (type) {
171
+ case "event":
172
+ return sdk.getEvents;
173
+ case "command":
174
+ return sdk.getCommands;
175
+ case "query":
176
+ return sdk.getQueries;
177
+ case "service":
178
+ return sdk.getServices;
179
+ case "domain":
180
+ return sdk.getDomains;
181
+ }
182
+ }
183
+ function pluralize(type) {
184
+ if (type === "query") return "queries";
185
+ return `${type}s`;
186
+ }
187
+ var SECTION_ORDER = ["team", "user", "channel", "event", "command", "query", "service", "domain"];
188
+ var SECTION_LABELS = {
189
+ team: "TEAMS",
190
+ user: "USERS",
191
+ channel: "CHANNELS",
192
+ event: "EVENTS",
193
+ command: "COMMANDS",
194
+ query: "QUERIES",
195
+ service: "SERVICES",
196
+ domain: "DOMAINS"
197
+ };
198
+ function groupDSLBlocks(dsl) {
199
+ const blocks = dsl.split(/\n\n/).filter((b) => b.trim());
200
+ const buckets = {};
201
+ for (const block of blocks) {
202
+ const firstWord = block.trimStart().split(/\s/)[0];
203
+ const key = firstWord === "subdomain" ? "domain" : firstWord;
204
+ if (!buckets[key]) buckets[key] = [];
205
+ buckets[key].push(block);
206
+ }
207
+ const sections = [];
208
+ for (const type of SECTION_ORDER) {
209
+ if (!buckets[type] || buckets[type].length === 0) continue;
210
+ const label = SECTION_LABELS[type] || type.toUpperCase();
211
+ sections.push(`// ${label}
212
+ ${buckets[type].join("\n\n")}`);
213
+ delete buckets[type];
214
+ }
215
+ for (const [type, items] of Object.entries(buckets)) {
216
+ if (items.length === 0) continue;
217
+ const label = type.toUpperCase();
218
+ sections.push(`// ${label}
219
+ ${items.join("\n\n")}`);
220
+ }
221
+ return sections.join("\n\n");
222
+ }
223
+ function buildVisualizerBlock(dsl, name, filterTypes) {
224
+ const types = Array.isArray(filterTypes) ? filterTypes : [filterTypes];
225
+ const entries = [];
226
+ for (const line of dsl.split("\n")) {
227
+ const trimmed = line.trimStart();
228
+ const parts = trimmed.split(/\s/);
229
+ const keyword = parts[0];
230
+ const id = parts[1];
231
+ if (!types.includes(keyword)) continue;
232
+ if (!id || !trimmed.endsWith("{")) continue;
233
+ entries.push(` ${keyword} ${id}`);
234
+ }
235
+ if (entries.length === 0) return "";
236
+ return `
237
+ visualizer main {
238
+ name "${name}"
239
+ ${entries.join("\n")}
240
+ }`;
241
+ }
242
+ async function exportCatalog(options) {
243
+ const { hydrate = false, stdout = false, playground = false, output, dir } = options;
244
+ const sdk = (0, import_sdk3.default)(dir);
245
+ const dslParts = [];
246
+ for (const type of RESOURCE_TYPES) {
247
+ const fetcher = getCollectionFetcher(sdk, type);
248
+ const resources = await fetcher({ latestOnly: true });
249
+ if (!resources || resources.length === 0) continue;
250
+ const rawDsl = await sdk.toDSL(resources, { type, hydrate });
251
+ dslParts.push(rawDsl);
252
+ }
253
+ if (dslParts.length === 0) {
254
+ throw new Error(`No resources found in catalog at '${dir}'`);
255
+ }
256
+ const combined = dslParts.join("\n\n");
257
+ const grouped = groupDSLBlocks(combined);
258
+ const vizBlock = buildVisualizerBlock(grouped, "Full Catalog", [...RESOURCE_TYPES]);
259
+ const dsl = vizBlock ? `${grouped}
260
+ ${vizBlock}` : grouped;
261
+ if (stdout) {
262
+ return dsl;
263
+ }
264
+ const filename = output || "catalog.ec";
265
+ const filepath = (0, import_node_path.resolve)(filename);
266
+ (0, import_node_fs2.writeFileSync)(filepath, dsl + "\n", "utf-8");
267
+ const lines = ["", ` Exported full catalog to ${filepath}`];
268
+ if (playground) {
269
+ const encoded = Buffer.from(dsl).toString("base64");
270
+ const playgroundUrl = `http://localhost:5173/?code=${encoded}`;
271
+ await (0, import_open.default)(playgroundUrl);
272
+ lines.push("", ` Opening in playground...`);
273
+ } else {
274
+ lines.push("", ` Tip: Use --playground to open in the playground`);
275
+ }
276
+ lines.push("");
277
+ return lines.join("\n");
278
+ }
279
+ async function exportAll(options) {
280
+ const { resource, hydrate = false, stdout = false, playground = false, output, dir } = options;
281
+ const type = normalizeResourceType(resource);
282
+ if (!RESOURCE_TYPES.includes(type)) {
283
+ throw new Error(`Invalid resource type '${resource}'. Must be one of: ${RESOURCE_TYPES.join(", ")}`);
284
+ }
285
+ const plural = pluralize(type);
286
+ const sdk = (0, import_sdk3.default)(dir);
287
+ const fetcher = getCollectionFetcher(sdk, type);
288
+ const allResources = await fetcher({ latestOnly: true });
289
+ if (!allResources || allResources.length === 0) {
290
+ throw new Error(`No ${plural} found in catalog at '${dir}'`);
291
+ }
292
+ const rawDsl = await sdk.toDSL(allResources, { type, hydrate });
293
+ const grouped = groupDSLBlocks(rawDsl);
294
+ const vizBlock = buildVisualizerBlock(grouped, `All ${plural}`, type);
295
+ const dsl = vizBlock ? `${grouped}
296
+ ${vizBlock}` : grouped;
297
+ if (stdout) {
298
+ return dsl;
299
+ }
300
+ const filename = output || `${plural}.ec`;
301
+ const filepath = (0, import_node_path.resolve)(filename);
302
+ (0, import_node_fs2.writeFileSync)(filepath, dsl + "\n", "utf-8");
303
+ const lines = ["", ` Exported ${allResources.length} ${plural} to ${filepath}`];
304
+ if (playground) {
305
+ const encoded = Buffer.from(dsl).toString("base64");
306
+ const playgroundUrl = `http://localhost:5173/?code=${encoded}`;
307
+ await (0, import_open.default)(playgroundUrl);
308
+ lines.push("", ` Opening in playground...`);
309
+ } else {
310
+ lines.push("", ` Tip: Use --playground to open in the playground`);
311
+ }
312
+ lines.push("");
313
+ return lines.join("\n");
314
+ }
315
+ async function exportResource(options) {
316
+ const { resource, id, version: version2, hydrate = false, stdout = false, playground = false, output, dir } = options;
317
+ if (!id) {
318
+ return exportAll(options);
319
+ }
320
+ const type = normalizeResourceType(resource);
321
+ if (!RESOURCE_TYPES.includes(type)) {
322
+ throw new Error(`Invalid resource type '${resource}'. Must be one of: ${RESOURCE_TYPES.join(", ")}`);
323
+ }
324
+ const sdk = (0, import_sdk3.default)(dir);
325
+ const fetcher = getResourceFetcher(sdk, type);
326
+ const data = await fetcher(id, version2);
327
+ if (!data) {
328
+ const versionStr = version2 ? `@${version2}` : " (latest)";
329
+ throw new Error(`${resource} '${id}${versionStr}' not found in catalog at '${dir}'`);
330
+ }
331
+ const rawDsl = await sdk.toDSL(data, { type, hydrate });
332
+ const grouped = hydrate ? groupDSLBlocks(rawDsl) : rawDsl;
333
+ const vizBlock = buildVisualizerBlock(grouped, `View of ${id}`, type);
334
+ const dsl = vizBlock ? `${grouped}
335
+ ${vizBlock}` : grouped;
336
+ if (stdout) {
337
+ return dsl;
338
+ }
339
+ const filename = output || `${id}.ec`;
340
+ const filepath = (0, import_node_path.resolve)(filename);
341
+ (0, import_node_fs2.writeFileSync)(filepath, dsl + "\n", "utf-8");
342
+ const lines = ["", ` Exported ${type} '${id}' to ${filepath}`];
343
+ if (playground) {
344
+ const encoded = Buffer.from(dsl).toString("base64");
345
+ const playgroundUrl = `http://localhost:5173/?code=${encoded}`;
346
+ await (0, import_open.default)(playgroundUrl);
347
+ lines.push("", ` Opening in playground...`);
348
+ } else {
349
+ lines.push("", ` Tip: Use --playground to open in the playground`);
350
+ }
351
+ lines.push("");
352
+ return lines.join("\n");
353
+ }
354
+
355
+ // src/cli/index.ts
356
+ var version = "1.0.0";
357
+ try {
358
+ const packageJsonPath = (0, import_node_path2.resolve)(__dirname, "../../package.json");
359
+ const packageJson = JSON.parse((0, import_node_fs3.readFileSync)(packageJsonPath, "utf-8"));
360
+ version = packageJson.version;
361
+ } catch {
362
+ }
363
+ import_commander.program.name("eventcatalog").description("EventCatalog Command-Line Interface").version(version).option("-d, --dir <path>", "Path to the EventCatalog directory (default: current directory)", ".");
364
+ import_commander.program.command("list").description("List all available SDK functions").action(() => {
365
+ try {
366
+ const functions = listFunctions(".");
367
+ const output = formatListOutput(functions);
368
+ console.log(output);
369
+ } catch (error) {
370
+ console.error("Error listing functions:", error instanceof Error ? error.message : String(error));
371
+ process.exit(1);
372
+ }
373
+ });
374
+ import_commander.program.command("export").description("Export a catalog resource to EventCatalog DSL (.ec) format").option("-a, --all", "Export the entire catalog (all resource types)", false).option("-r, --resource <type>", "Resource type (event, command, query, service, domain)").option("--id <id>", "Resource ID (omit to export all resources of the given type)").option("-v, --version <version>", "Resource version (defaults to latest)").option("--hydrate", "Include referenced resources (messages, channels, owners)", false).option("--stdout", "Print to stdout instead of writing a file", false).option("--playground", "Open the exported DSL in the playground", false).option("-o, --output <path>", "Output file path (defaults to <id>.ec or catalog.ec)").action(async (opts) => {
375
+ try {
376
+ const globalOpts = import_commander.program.opts();
377
+ const dir = globalOpts.dir || ".";
378
+ if (opts.all) {
379
+ const result2 = await exportCatalog({
380
+ hydrate: opts.hydrate,
381
+ stdout: opts.stdout,
382
+ playground: opts.playground,
383
+ output: opts.output,
384
+ dir
385
+ });
386
+ console.log(result2);
387
+ return;
388
+ }
389
+ if (!opts.resource) {
390
+ console.error("Either --all or --resource is required");
391
+ process.exit(1);
392
+ }
393
+ const result = await exportResource({
394
+ resource: opts.resource,
395
+ id: opts.id,
396
+ version: opts.version,
397
+ hydrate: opts.hydrate,
398
+ stdout: opts.stdout,
399
+ playground: opts.playground,
400
+ output: opts.output,
401
+ dir
402
+ });
403
+ console.log(result);
404
+ } catch (error) {
405
+ console.error(error instanceof Error ? error.message : String(error));
406
+ process.exit(1);
407
+ }
408
+ });
409
+ import_commander.program.arguments("<function> [args...]").action(async (functionName, args) => {
410
+ try {
411
+ const options = import_commander.program.opts();
412
+ const dir = options.dir || ".";
413
+ const result = await executeFunction(dir, functionName, args);
414
+ console.log(JSON.stringify(result, null, 0));
415
+ } catch (error) {
416
+ console.error(error instanceof Error ? error.message : String(error));
417
+ process.exit(1);
418
+ }
419
+ });
420
+ import_commander.program.parse(process.argv);
421
+ if (process.argv.length < 3) {
422
+ import_commander.program.outputHelp();
423
+ }
424
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/cli/index.ts","../../src/cli/executor.ts","../../src/cli/parser.ts","../../src/cli/list.ts","../../src/cli/export.ts"],"sourcesContent":["#!/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 = `http://localhost:5173/?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 const fetcher = getCollectionFetcher(sdk, type);\n const allResources = await fetcher({ latestOnly: true });\n\n if (!allResources || 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 = `http://localhost:5173/?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 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 = `http://localhost:5173/?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 l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AK;AAAA,QACb;AAAA,MACF,CAAC;AACD,cAAQ,IAAIA,OAAM;AAClB;AAAA,IACF;AAEA,QAAI,CAAC,KAAK,UAAU;AAClB,cAAQ,MAAM,wCAAwC;AACtD,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,UAAM,SAAS,MAAM,eAAe;AAAA,MAClC,UAAU,KAAK;AAAA,MACf,IAAI,KAAK;AAAA,MACT,SAAS,KAAK;AAAA,MACd,SAAS,KAAK;AAAA,MACd,QAAQ,KAAK;AAAA,MACb,YAAY,KAAK;AAAA,MACjB,QAAQ,KAAK;AAAA,MACb;AAAA,IACF,CAAC;AACD,YAAQ,IAAI,MAAM;AAAA,EACpB,SAAS,OAAO;AACd,YAAQ,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AACpE,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF,CAAC;AAGH,yBAAQ,UAAU,sBAAsB,EAAE,OAAO,OAAO,cAAsB,SAAmB;AAC/F,MAAI;AACF,UAAM,UAAU,yBAAQ,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,yBAAQ,MAAM,QAAQ,IAAI;AAG1B,IAAI,QAAQ,KAAK,SAAS,GAAG;AAC3B,2BAAQ,WAAW;AACrB;","names":["import_node_fs","import_node_path","createSDK","import_sdk","createSDK","import_node_fs","import_sdk","createSDK","open","version","result"]}