@eventcatalog/sdk 2.11.0 → 2.12.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.
Files changed (110) hide show
  1. package/README.md +86 -1
  2. package/dist/cli/index.d.mts +1 -0
  3. package/dist/cli/index.d.ts +1 -0
  4. package/dist/{eventcatalog.js → cli/index.js} +505 -378
  5. package/dist/cli/index.js.map +1 -0
  6. package/dist/{eventcatalog.mjs → cli/index.mjs} +583 -436
  7. package/dist/cli/index.mjs.map +1 -0
  8. package/dist/cli-docs.d.mts +43 -0
  9. package/dist/cli-docs.d.ts +43 -0
  10. package/dist/cli-docs.js +1513 -0
  11. package/dist/cli-docs.js.map +1 -0
  12. package/dist/cli-docs.mjs +1485 -0
  13. package/dist/cli-docs.mjs.map +1 -0
  14. package/dist/index.d.mts +330 -3
  15. package/dist/index.d.ts +330 -3
  16. package/package.json +13 -4
  17. package/dist/channels.d.mts +0 -214
  18. package/dist/channels.d.ts +0 -214
  19. package/dist/channels.js +0 -432
  20. package/dist/channels.js.map +0 -1
  21. package/dist/channels.mjs +0 -384
  22. package/dist/channels.mjs.map +0 -1
  23. package/dist/commands.d.mts +0 -274
  24. package/dist/commands.d.ts +0 -274
  25. package/dist/commands.js +0 -394
  26. package/dist/commands.js.map +0 -1
  27. package/dist/commands.mjs +0 -350
  28. package/dist/commands.mjs.map +0 -1
  29. package/dist/containers.d.mts +0 -179
  30. package/dist/containers.d.ts +0 -179
  31. package/dist/containers.js +0 -388
  32. package/dist/containers.js.map +0 -1
  33. package/dist/containers.mjs +0 -345
  34. package/dist/containers.mjs.map +0 -1
  35. package/dist/custom-docs.d.mts +0 -89
  36. package/dist/custom-docs.d.ts +0 -89
  37. package/dist/custom-docs.js +0 -164
  38. package/dist/custom-docs.js.map +0 -1
  39. package/dist/custom-docs.mjs +0 -122
  40. package/dist/custom-docs.mjs.map +0 -1
  41. package/dist/data-products.d.mts +0 -225
  42. package/dist/data-products.d.ts +0 -225
  43. package/dist/data-products.js +0 -375
  44. package/dist/data-products.js.map +0 -1
  45. package/dist/data-products.mjs +0 -332
  46. package/dist/data-products.mjs.map +0 -1
  47. package/dist/data-stores.d.mts +0 -179
  48. package/dist/data-stores.d.ts +0 -179
  49. package/dist/data-stores.js +0 -401
  50. package/dist/data-stores.js.map +0 -1
  51. package/dist/data-stores.mjs +0 -356
  52. package/dist/data-stores.mjs.map +0 -1
  53. package/dist/domains.d.mts +0 -347
  54. package/dist/domains.d.ts +0 -347
  55. package/dist/domains.js +0 -547
  56. package/dist/domains.js.map +0 -1
  57. package/dist/domains.mjs +0 -498
  58. package/dist/domains.mjs.map +0 -1
  59. package/dist/entities.d.mts +0 -174
  60. package/dist/entities.d.ts +0 -174
  61. package/dist/entities.js +0 -348
  62. package/dist/entities.js.map +0 -1
  63. package/dist/entities.mjs +0 -307
  64. package/dist/entities.mjs.map +0 -1
  65. package/dist/eventcatalog.d.mts +0 -21
  66. package/dist/eventcatalog.d.ts +0 -21
  67. package/dist/eventcatalog.js.map +0 -1
  68. package/dist/eventcatalog.mjs.map +0 -1
  69. package/dist/events.d.mts +0 -276
  70. package/dist/events.d.ts +0 -276
  71. package/dist/events.js +0 -393
  72. package/dist/events.js.map +0 -1
  73. package/dist/events.mjs +0 -349
  74. package/dist/events.mjs.map +0 -1
  75. package/dist/messages.d.mts +0 -65
  76. package/dist/messages.d.ts +0 -65
  77. package/dist/messages.js +0 -312
  78. package/dist/messages.js.map +0 -1
  79. package/dist/messages.mjs +0 -269
  80. package/dist/messages.mjs.map +0 -1
  81. package/dist/queries.d.mts +0 -276
  82. package/dist/queries.d.ts +0 -276
  83. package/dist/queries.js +0 -394
  84. package/dist/queries.js.map +0 -1
  85. package/dist/queries.mjs +0 -350
  86. package/dist/queries.mjs.map +0 -1
  87. package/dist/services.d.mts +0 -384
  88. package/dist/services.d.ts +0 -384
  89. package/dist/services.js +0 -577
  90. package/dist/services.js.map +0 -1
  91. package/dist/services.mjs +0 -526
  92. package/dist/services.mjs.map +0 -1
  93. package/dist/teams.d.mts +0 -90
  94. package/dist/teams.d.ts +0 -90
  95. package/dist/teams.js +0 -246
  96. package/dist/teams.js.map +0 -1
  97. package/dist/teams.mjs +0 -202
  98. package/dist/teams.mjs.map +0 -1
  99. package/dist/types.d.d.mts +0 -331
  100. package/dist/types.d.d.ts +0 -331
  101. package/dist/types.d.js +0 -19
  102. package/dist/types.d.js.map +0 -1
  103. package/dist/types.d.mjs +0 -1
  104. package/dist/types.d.mjs.map +0 -1
  105. package/dist/users.d.mts +0 -83
  106. package/dist/users.d.ts +0 -83
  107. package/dist/users.js +0 -127
  108. package/dist/users.js.map +0 -1
  109. package/dist/users.mjs +0 -88
  110. package/dist/users.mjs.map +0 -1
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  "use strict";
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
@@ -5,10 +6,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
7
  var __getProtoOf = Object.getPrototypeOf;
7
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
9
  var __copyProps = (to, from, except, desc) => {
13
10
  if (from && typeof from === "object" || typeof from === "function") {
14
11
  for (let key of __getOwnPropNames(from))
@@ -25,20 +22,39 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
22
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
23
  mod
27
24
  ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
25
 
30
- // src/eventcatalog.ts
31
- var eventcatalog_exports = {};
32
- __export(eventcatalog_exports, {
33
- dumpCatalog: () => dumpCatalog,
34
- getEventCatalogConfigurationFile: () => getEventCatalogConfigurationFile
35
- });
36
- module.exports = __toCommonJS(eventcatalog_exports);
37
- var import_fs = __toESM(require("fs"));
38
- var import_node_path19 = __toESM(require("path"));
26
+ // src/cli/index.ts
27
+ var import_commander = require("commander");
28
+ var import_node_fs8 = require("fs");
29
+ var import_node_path20 = require("path");
30
+
31
+ // src/cli/executor.ts
32
+ var import_node_fs7 = 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
+ }
39
55
 
40
56
  // src/index.ts
41
- var import_node_path18 = require("path");
57
+ var import_node_path19 = require("path");
42
58
 
43
59
  // src/events.ts
44
60
  var import_promises2 = __toESM(require("fs/promises"));
@@ -51,30 +67,30 @@ var import_fs_extra = require("fs-extra");
51
67
  var import_node_path = require("path");
52
68
  var import_gray_matter = __toESM(require("gray-matter"));
53
69
  var import_semver = require("semver");
54
- var versionExists = async (catalogDir, id, version) => {
70
+ var versionExists = async (catalogDir, id, version2) => {
55
71
  const files = await getFiles(`${catalogDir}/**/index.{md,mdx}`);
56
- const matchedFiles = await searchFilesForId(files, id, version) || [];
72
+ const matchedFiles = await searchFilesForId(files, id, version2) || [];
57
73
  return matchedFiles.length > 0;
58
74
  };
59
- var findFileById = async (catalogDir, id, version) => {
75
+ var findFileById = async (catalogDir, id, version2) => {
60
76
  const files = await getFiles(`${catalogDir}/**/index.{md,mdx}`);
61
77
  const matchedFiles = await searchFilesForId(files, id) || [];
62
78
  const latestVersion = matchedFiles.find((path6) => !path6.includes("versioned"));
63
- if (!version) {
79
+ if (!version2) {
64
80
  return latestVersion;
65
81
  }
66
82
  const parsedFiles = matchedFiles.map((path6) => {
67
83
  const { data } = import_gray_matter.default.read(path6);
68
84
  return { ...data, path: path6 };
69
85
  });
70
- if (version === "latest") {
86
+ if (version2 === "latest") {
71
87
  return latestVersion;
72
88
  }
73
- const exactMatch = parsedFiles.find((c) => c.version === version);
89
+ const exactMatch = parsedFiles.find((c) => c.version === version2);
74
90
  if (exactMatch) {
75
91
  return exactMatch.path;
76
92
  }
77
- const semverRange = (0, import_semver.validRange)(version);
93
+ const semverRange = (0, import_semver.validRange)(version2);
78
94
  if (semverRange) {
79
95
  const match = parsedFiles.filter((c) => {
80
96
  try {
@@ -118,14 +134,14 @@ var readMdxFile = async (path6) => {
118
134
  const { markdown, ...frontmatter } = data;
119
135
  return { ...frontmatter, markdown };
120
136
  };
121
- var searchFilesForId = async (files, id, version) => {
137
+ var searchFilesForId = async (files, id, version2) => {
122
138
  const escapedId = id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
123
139
  const idRegex = new RegExp(`^id:\\s*(['"]|>-)?\\s*${escapedId}['"]?\\s*$`, "m");
124
- const versionRegex = new RegExp(`^version:\\s*['"]?${version}['"]?\\s*$`, "m");
140
+ const versionRegex = new RegExp(`^version:\\s*['"]?${version2}['"]?\\s*$`, "m");
125
141
  const matches = files.map((file) => {
126
142
  const content = import_node_fs.default.readFileSync(file, "utf-8");
127
143
  const hasIdMatch = content.match(idRegex);
128
- if (version && !content.match(versionRegex)) {
144
+ if (version2 && !content.match(versionRegex)) {
129
145
  return void 0;
130
146
  }
131
147
  if (hasIdMatch) {
@@ -176,8 +192,8 @@ var versionResource = async (catalogDir, id) => {
176
192
  }
177
193
  const file = matchedFiles[0];
178
194
  const sourceDirectory = (0, import_path.dirname)(file).replace(/[/\\]versioned[/\\][^/\\]+[/\\]/, import_node_path3.default.sep);
179
- const { data: { version = "0.0.1" } = {} } = import_gray_matter2.default.read(file);
180
- const targetDirectory = getVersionedDirectory(sourceDirectory, version);
195
+ const { data: { version: version2 = "0.0.1" } = {} } = import_gray_matter2.default.read(file);
196
+ const targetDirectory = getVersionedDirectory(sourceDirectory, version2);
181
197
  import_node_fs2.default.mkdirSync(targetDirectory, { recursive: true });
182
198
  const ignoreListToCopy = ["events", "commands", "queries", "versioned"];
183
199
  await copyDir(catalogDir, sourceDirectory, targetDirectory, (src) => {
@@ -243,9 +259,9 @@ var writeResource = async (catalogDir, resource, options = {
243
259
  });
244
260
  }
245
261
  };
246
- var getResource = async (catalogDir, id, version, options, filePath) => {
262
+ var getResource = async (catalogDir, id, version2, options, filePath) => {
247
263
  const attachSchema = options?.attachSchema || false;
248
- const file = filePath || (id ? await findFileById(catalogDir, id, version) : void 0);
264
+ const file = filePath || (id ? await findFileById(catalogDir, id, version2) : void 0);
249
265
  if (!file || !import_node_fs2.default.existsSync(file)) return;
250
266
  const { data, content } = import_gray_matter2.default.read(file);
251
267
  if (attachSchema && data?.schemaPath) {
@@ -265,8 +281,8 @@ var getResource = async (catalogDir, id, version, options, filePath) => {
265
281
  markdown: content.trim()
266
282
  };
267
283
  };
268
- var getResourcePath = async (catalogDir, id, version) => {
269
- const file = await findFileById(catalogDir, id, version);
284
+ var getResourcePath = async (catalogDir, id, version2) => {
285
+ const file = await findFileById(catalogDir, id, version2);
270
286
  if (!file) return;
271
287
  return {
272
288
  fullPath: file,
@@ -274,8 +290,8 @@ var getResourcePath = async (catalogDir, id, version) => {
274
290
  directory: (0, import_path.dirname)(file.replace(catalogDir, ""))
275
291
  };
276
292
  };
277
- var getResourceFolderName = async (catalogDir, id, version) => {
278
- const paths = await getResourcePath(catalogDir, id, version);
293
+ var getResourceFolderName = async (catalogDir, id, version2) => {
294
+ const paths = await getResourcePath(catalogDir, id, version2);
279
295
  if (!paths) return;
280
296
  return paths?.directory.split(import_node_path3.default.sep).filter(Boolean).pop();
281
297
  };
@@ -317,9 +333,9 @@ var getResources = async (catalogDir, {
317
333
  };
318
334
  });
319
335
  };
320
- var rmResourceById = async (catalogDir, id, version, options) => {
336
+ var rmResourceById = async (catalogDir, id, version2, options) => {
321
337
  const files = await getFiles(`${catalogDir}/**/index.{md,mdx}`);
322
- const matchedFiles = await searchFilesForId(files, id, version);
338
+ const matchedFiles = await searchFilesForId(files, id, version2);
323
339
  if (matchedFiles.length === 0) {
324
340
  throw new Error(`No ${options?.type || "resource"} found with id: ${id}`);
325
341
  }
@@ -344,19 +360,19 @@ var waitForFileRemoval = async (path6, maxRetries = 50, delay = 10) => {
344
360
  for (let i = 0; i < maxRetries; i++) {
345
361
  try {
346
362
  await import_promises.default.access(path6);
347
- await new Promise((resolve2) => setTimeout(resolve2, delay));
363
+ await new Promise((resolve3) => setTimeout(resolve3, delay));
348
364
  } catch (error) {
349
365
  return;
350
366
  }
351
367
  }
352
368
  throw new Error(`File/directory ${path6} was not removed after ${maxRetries} attempts`);
353
369
  };
354
- var addFileToResource = async (catalogDir, id, file, version, options) => {
370
+ var addFileToResource = async (catalogDir, id, file, version2, options) => {
355
371
  let pathToResource;
356
372
  if (options?.path) {
357
373
  pathToResource = (0, import_path.join)(catalogDir, options.path, "index.mdx");
358
374
  } else {
359
- pathToResource = await findFileById(catalogDir, id, version);
375
+ pathToResource = await findFileById(catalogDir, id, version2);
360
376
  }
361
377
  if (!pathToResource) throw new Error("Cannot find directory to write file to");
362
378
  import_node_fs2.default.mkdirSync(import_node_path3.default.dirname(pathToResource), { recursive: true });
@@ -368,25 +384,25 @@ var addFileToResource = async (catalogDir, id, file, version, options) => {
368
384
  }
369
385
  import_node_fs2.default.writeFileSync((0, import_path.join)((0, import_path.dirname)(pathToResource), file.fileName), fileContent);
370
386
  };
371
- var getFileFromResource = async (catalogDir, id, file, version) => {
372
- const pathToResource = await findFileById(catalogDir, id, version);
387
+ var getFileFromResource = async (catalogDir, id, file, version2) => {
388
+ const pathToResource = await findFileById(catalogDir, id, version2);
373
389
  if (!pathToResource) throw new Error("Cannot find directory of resource");
374
390
  const exists = await import_promises.default.access((0, import_path.join)((0, import_path.dirname)(pathToResource), file.fileName)).then(() => true).catch(() => false);
375
- if (!exists) throw new Error(`File ${file.fileName} does not exist in resource ${id} v(${version})`);
391
+ if (!exists) throw new Error(`File ${file.fileName} does not exist in resource ${id} v(${version2})`);
376
392
  return import_node_fs2.default.readFileSync((0, import_path.join)((0, import_path.dirname)(pathToResource), file.fileName), "utf-8");
377
393
  };
378
- var getVersionedDirectory = (sourceDirectory, version) => {
379
- return (0, import_path.join)(sourceDirectory, "versioned", version);
394
+ var getVersionedDirectory = (sourceDirectory, version2) => {
395
+ return (0, import_path.join)(sourceDirectory, "versioned", version2);
380
396
  };
381
- var isLatestVersion = async (catalogDir, id, version) => {
382
- const resource = await getResource(catalogDir, id, version);
397
+ var isLatestVersion = async (catalogDir, id, version2) => {
398
+ const resource = await getResource(catalogDir, id, version2);
383
399
  if (!resource) return false;
384
- const pathToResource = await getResourcePath(catalogDir, id, version);
400
+ const pathToResource = await getResourcePath(catalogDir, id, version2);
385
401
  return !pathToResource?.relativePath.replace(/\\/g, "/").includes("/versioned/");
386
402
  };
387
403
 
388
404
  // src/events.ts
389
- var getEvent = (directory) => async (id, version, options) => getResource(directory, id, version, { type: "event", ...options });
405
+ var getEvent = (directory) => async (id, version2, options) => getResource(directory, id, version2, { type: "event", ...options });
390
406
  var getEvents = (directory) => async (options) => getResources(directory, { type: "events", ...options });
391
407
  var writeEvent = (directory) => async (event, options = {
392
408
  path: "",
@@ -405,23 +421,23 @@ var writeEventToService = (directory) => async (event, service, options = { path
405
421
  var rmEvent = (directory) => async (path6) => {
406
422
  await import_promises2.default.rm((0, import_node_path4.join)(directory, path6), { recursive: true });
407
423
  };
408
- var rmEventById = (directory) => async (id, version, persistFiles) => {
409
- await rmResourceById(directory, id, version, { type: "event", persistFiles });
424
+ var rmEventById = (directory) => async (id, version2, persistFiles) => {
425
+ await rmResourceById(directory, id, version2, { type: "event", persistFiles });
410
426
  };
411
427
  var versionEvent = (directory) => async (id) => versionResource(directory, id);
412
- var addFileToEvent = (directory) => async (id, file, version, options) => addFileToResource(directory, id, file, version, options);
413
- var addSchemaToEvent = (directory) => async (id, schema, version, options) => {
414
- await addFileToEvent(directory)(id, { content: schema.schema, fileName: schema.fileName }, version, options);
428
+ var addFileToEvent = (directory) => async (id, file, version2, options) => addFileToResource(directory, id, file, version2, options);
429
+ var addSchemaToEvent = (directory) => async (id, schema, version2, options) => {
430
+ await addFileToEvent(directory)(id, { content: schema.schema, fileName: schema.fileName }, version2, options);
415
431
  };
416
- var eventHasVersion = (directory) => async (id, version) => {
417
- const file = await findFileById(directory, id, version);
432
+ var eventHasVersion = (directory) => async (id, version2) => {
433
+ const file = await findFileById(directory, id, version2);
418
434
  return !!file;
419
435
  };
420
436
 
421
437
  // src/commands.ts
422
438
  var import_promises3 = __toESM(require("fs/promises"));
423
439
  var import_node_path5 = require("path");
424
- var getCommand = (directory) => async (id, version, options) => getResource(directory, id, version, { type: "command", ...options });
440
+ var getCommand = (directory) => async (id, version2, options) => getResource(directory, id, version2, { type: "command", ...options });
425
441
  var getCommands = (directory) => async (options) => getResources(directory, { type: "commands", ...options });
426
442
  var writeCommand = (directory) => async (command, options = {
427
443
  path: "",
@@ -441,21 +457,21 @@ var writeCommandToService = (directory) => async (command, service, options = {
441
457
  var rmCommand = (directory) => async (path6) => {
442
458
  await import_promises3.default.rm((0, import_node_path5.join)(directory, path6), { recursive: true });
443
459
  };
444
- var rmCommandById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "command", persistFiles });
460
+ var rmCommandById = (directory) => async (id, version2, persistFiles) => rmResourceById(directory, id, version2, { type: "command", persistFiles });
445
461
  var versionCommand = (directory) => async (id) => versionResource(directory, id);
446
- var addFileToCommand = (directory) => async (id, file, version, options) => addFileToResource(directory, id, file, version, options);
447
- var addSchemaToCommand = (directory) => async (id, schema, version, options) => {
448
- await addFileToCommand(directory)(id, { content: schema.schema, fileName: schema.fileName }, version, options);
462
+ var addFileToCommand = (directory) => async (id, file, version2, options) => addFileToResource(directory, id, file, version2, options);
463
+ var addSchemaToCommand = (directory) => async (id, schema, version2, options) => {
464
+ await addFileToCommand(directory)(id, { content: schema.schema, fileName: schema.fileName }, version2, options);
449
465
  };
450
- var commandHasVersion = (directory) => async (id, version) => {
451
- const file = await findFileById(directory, id, version);
466
+ var commandHasVersion = (directory) => async (id, version2) => {
467
+ const file = await findFileById(directory, id, version2);
452
468
  return !!file;
453
469
  };
454
470
 
455
471
  // src/queries.ts
456
472
  var import_promises4 = __toESM(require("fs/promises"));
457
473
  var import_node_path6 = require("path");
458
- var getQuery = (directory) => async (id, version, options) => getResource(directory, id, version, { type: "query", ...options });
474
+ var getQuery = (directory) => async (id, version2, options) => getResource(directory, id, version2, { type: "query", ...options });
459
475
  var writeQuery = (directory) => async (query, options = {
460
476
  path: "",
461
477
  override: false,
@@ -475,23 +491,23 @@ var writeQueryToService = (directory) => async (query, service, options = { path
475
491
  var rmQuery = (directory) => async (path6) => {
476
492
  await import_promises4.default.rm((0, import_node_path6.join)(directory, path6), { recursive: true });
477
493
  };
478
- var rmQueryById = (directory) => async (id, version, persistFiles) => {
479
- await rmResourceById(directory, id, version, { type: "query", persistFiles });
494
+ var rmQueryById = (directory) => async (id, version2, persistFiles) => {
495
+ await rmResourceById(directory, id, version2, { type: "query", persistFiles });
480
496
  };
481
497
  var versionQuery = (directory) => async (id) => versionResource(directory, id);
482
- var addFileToQuery = (directory) => async (id, file, version, options) => addFileToResource(directory, id, file, version, options);
483
- var addSchemaToQuery = (directory) => async (id, schema, version, options) => {
484
- await addFileToQuery(directory)(id, { content: schema.schema, fileName: schema.fileName }, version, options);
498
+ var addFileToQuery = (directory) => async (id, file, version2, options) => addFileToResource(directory, id, file, version2, options);
499
+ var addSchemaToQuery = (directory) => async (id, schema, version2, options) => {
500
+ await addFileToQuery(directory)(id, { content: schema.schema, fileName: schema.fileName }, version2, options);
485
501
  };
486
- var queryHasVersion = (directory) => async (id, version) => {
487
- const file = await findFileById(directory, id, version);
502
+ var queryHasVersion = (directory) => async (id, version2) => {
503
+ const file = await findFileById(directory, id, version2);
488
504
  return !!file;
489
505
  };
490
506
 
491
507
  // src/services.ts
492
508
  var import_promises5 = __toESM(require("fs/promises"));
493
509
  var import_node_path7 = require("path");
494
- var getService = (directory) => async (id, version) => getResource(directory, id, version, { type: "service" });
510
+ var getService = (directory) => async (id, version2) => getResource(directory, id, version2, { type: "service" });
495
511
  var getServiceByPath = (directory) => async (path6) => {
496
512
  const service = await getResource(directory, void 0, void 0, { type: "service" }, path6);
497
513
  return service;
@@ -529,13 +545,13 @@ var versionService = (directory) => async (id) => versionResource(directory, id)
529
545
  var rmService = (directory) => async (path6) => {
530
546
  await import_promises5.default.rm((0, import_node_path7.join)(directory, path6), { recursive: true });
531
547
  };
532
- var rmServiceById = (directory) => async (id, version, persistFiles) => {
533
- await rmResourceById(directory, id, version, { type: "service", persistFiles });
548
+ var rmServiceById = (directory) => async (id, version2, persistFiles) => {
549
+ await rmResourceById(directory, id, version2, { type: "service", persistFiles });
534
550
  };
535
- var addFileToService = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
536
- var getSpecificationFilesForService = (directory) => async (id, version) => {
537
- let service = await getService(directory)(id, version);
538
- const filePathToService = await findFileById(directory, id, version);
551
+ var addFileToService = (directory) => async (id, file, version2) => addFileToResource(directory, id, file, version2);
552
+ var getSpecificationFilesForService = (directory) => async (id, version2) => {
553
+ let service = await getService(directory)(id, version2);
554
+ const filePathToService = await findFileById(directory, id, version2);
539
555
  if (!filePathToService) throw new Error("Cannot find directory of service");
540
556
  let specs = [];
541
557
  if (service.specifications) {
@@ -553,16 +569,16 @@ var getSpecificationFilesForService = (directory) => async (id, version) => {
553
569
  if (!fileName) {
554
570
  throw new Error(`Specification file name for ${fileName} is undefined`);
555
571
  }
556
- const rawFile = await getFileFromResource(directory, id, { fileName }, version);
572
+ const rawFile = await getFileFromResource(directory, id, { fileName }, version2);
557
573
  return { key, content: rawFile, fileName, path: (0, import_node_path7.join)((0, import_node_path7.dirname)(filePathToService), fileName) };
558
574
  });
559
575
  specs = await Promise.all(getSpecs);
560
576
  }
561
577
  return specs;
562
578
  };
563
- var addMessageToService = (directory) => async (id, direction, event, version) => {
564
- let service = await getService(directory)(id, version);
565
- const servicePath = await getResourcePath(directory, id, version);
579
+ var addMessageToService = (directory) => async (id, direction, event, version2) => {
580
+ let service = await getService(directory)(id, version2);
581
+ const servicePath = await getResourcePath(directory, id, version2);
566
582
  const extension = (0, import_node_path7.extname)(servicePath?.fullPath || "");
567
583
  if (direction === "sends") {
568
584
  if (service.sends === void 0) {
@@ -587,17 +603,17 @@ var addMessageToService = (directory) => async (id, direction, event, version) =
587
603
  } else {
588
604
  throw new Error(`Direction ${direction} is invalid, only 'receives' and 'sends' are supported`);
589
605
  }
590
- const existingResource = await findFileById(directory, id, version);
606
+ const existingResource = await findFileById(directory, id, version2);
591
607
  if (!existingResource) {
592
608
  throw new Error(`Cannot find service ${id} in the catalog`);
593
609
  }
594
610
  const path6 = existingResource.split(/[\\/]+services/)[0];
595
611
  const pathToResource = (0, import_node_path7.join)(path6, "services");
596
- await rmServiceById(directory)(id, version);
612
+ await rmServiceById(directory)(id, version2);
597
613
  await writeService(pathToResource)(service, { format: extension === ".md" ? "md" : "mdx" });
598
614
  };
599
- var serviceHasVersion = (directory) => async (id, version) => {
600
- const file = await findFileById(directory, id, version);
615
+ var serviceHasVersion = (directory) => async (id, version2) => {
616
+ const file = await findFileById(directory, id, version2);
601
617
  return !!file;
602
618
  };
603
619
  var isService = (directory) => async (path6) => {
@@ -607,9 +623,9 @@ var isService = (directory) => async (path6) => {
607
623
  return !!service && segments.includes("services");
608
624
  };
609
625
  var toService = (directory) => async (file) => toResource(directory, file);
610
- var addEntityToService = (directory) => async (id, entity, version) => {
611
- let service = await getService(directory)(id, version);
612
- const servicePath = await getResourcePath(directory, id, version);
626
+ var addEntityToService = (directory) => async (id, entity, version2) => {
627
+ let service = await getService(directory)(id, version2);
628
+ const servicePath = await getResourcePath(directory, id, version2);
613
629
  const extension = (0, import_node_path7.extname)(servicePath?.fullPath || "");
614
630
  if (service.entities === void 0) {
615
631
  service.entities = [];
@@ -620,18 +636,18 @@ var addEntityToService = (directory) => async (id, entity, version) => {
620
636
  }
621
637
  }
622
638
  service.entities.push({ id: entity.id, version: entity.version });
623
- const existingResource = await findFileById(directory, id, version);
639
+ const existingResource = await findFileById(directory, id, version2);
624
640
  if (!existingResource) {
625
641
  throw new Error(`Cannot find service ${id} in the catalog`);
626
642
  }
627
643
  const path6 = existingResource.split(/[\\/]+services/)[0];
628
644
  const pathToResource = (0, import_node_path7.join)(path6, "services");
629
- await rmServiceById(directory)(id, version);
645
+ await rmServiceById(directory)(id, version2);
630
646
  await writeService(pathToResource)(service, { format: extension === ".md" ? "md" : "mdx" });
631
647
  };
632
- var addDataStoreToService = (directory) => async (id, operation, dataStore, version) => {
633
- let service = await getService(directory)(id, version);
634
- const servicePath = await getResourcePath(directory, id, version);
648
+ var addDataStoreToService = (directory) => async (id, operation, dataStore, version2) => {
649
+ let service = await getService(directory)(id, version2);
650
+ const servicePath = await getResourcePath(directory, id, version2);
635
651
  const extension = (0, import_node_path7.extname)(servicePath?.fullPath || "");
636
652
  if (operation === "writesTo") {
637
653
  if (service.writesTo === void 0) {
@@ -656,13 +672,13 @@ var addDataStoreToService = (directory) => async (id, operation, dataStore, vers
656
672
  } else {
657
673
  throw new Error(`Operation ${operation} is invalid, only 'writesTo' and 'readsFrom' are supported`);
658
674
  }
659
- const existingResource = await findFileById(directory, id, version);
675
+ const existingResource = await findFileById(directory, id, version2);
660
676
  if (!existingResource) {
661
677
  throw new Error(`Cannot find service ${id} in the catalog`);
662
678
  }
663
679
  const path6 = existingResource.split(/[\\/]+services/)[0];
664
680
  const pathToResource = (0, import_node_path7.join)(path6, "services");
665
- await rmServiceById(directory)(id, version);
681
+ await rmServiceById(directory)(id, version2);
666
682
  await writeService(pathToResource)(service, { format: extension === ".md" ? "md" : "mdx" });
667
683
  };
668
684
 
@@ -671,7 +687,7 @@ var import_promises6 = __toESM(require("fs/promises"));
671
687
  var import_node_path8 = __toESM(require("path"));
672
688
  var import_node_fs3 = __toESM(require("fs"));
673
689
  var import_gray_matter3 = __toESM(require("gray-matter"));
674
- var getDomain = (directory) => async (id, version) => getResource(directory, id, version, { type: "domain" });
690
+ var getDomain = (directory) => async (id, version2) => getResource(directory, id, version2, { type: "domain" });
675
691
  var getDomains = (directory) => async (options) => getResources(directory, {
676
692
  type: "domains",
677
693
  ignore: ["**/services/**", "**/events/**", "**/commands/**", "**/queries/**", "**/flows/**", "**/entities/**"],
@@ -705,16 +721,16 @@ var versionDomain = (directory) => async (id) => versionResource(directory, id);
705
721
  var rmDomain = (directory) => async (path6) => {
706
722
  await import_promises6.default.rm((0, import_node_path8.join)(directory, path6), { recursive: true });
707
723
  };
708
- var rmDomainById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "domain", persistFiles });
709
- var addFileToDomain = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
710
- var addUbiquitousLanguageToDomain = (directory) => async (id, ubiquitousLanguageDictionary, version) => {
724
+ var rmDomainById = (directory) => async (id, version2, persistFiles) => rmResourceById(directory, id, version2, { type: "domain", persistFiles });
725
+ var addFileToDomain = (directory) => async (id, file, version2) => addFileToResource(directory, id, file, version2);
726
+ var addUbiquitousLanguageToDomain = (directory) => async (id, ubiquitousLanguageDictionary, version2) => {
711
727
  const content = import_gray_matter3.default.stringify("", {
712
728
  ...ubiquitousLanguageDictionary
713
729
  });
714
- await addFileToResource(directory, id, { content, fileName: "ubiquitous-language.mdx" }, version);
730
+ await addFileToResource(directory, id, { content, fileName: "ubiquitous-language.mdx" }, version2);
715
731
  };
716
- var getUbiquitousLanguageFromDomain = (directory) => async (id, version) => {
717
- const pathToDomain = await findFileById(directory, id, version) || "";
732
+ var getUbiquitousLanguageFromDomain = (directory) => async (id, version2) => {
733
+ const pathToDomain = await findFileById(directory, id, version2) || "";
718
734
  const pathToUbiquitousLanguage = import_node_path8.default.join(import_node_path8.default.dirname(pathToDomain), "ubiquitous-language.mdx");
719
735
  const fileExists = import_node_fs3.default.existsSync(pathToUbiquitousLanguage);
720
736
  if (!fileExists) {
@@ -723,13 +739,13 @@ var getUbiquitousLanguageFromDomain = (directory) => async (id, version) => {
723
739
  const content = await readMdxFile(pathToUbiquitousLanguage);
724
740
  return content;
725
741
  };
726
- var domainHasVersion = (directory) => async (id, version) => {
727
- const file = await findFileById(directory, id, version);
742
+ var domainHasVersion = (directory) => async (id, version2) => {
743
+ const file = await findFileById(directory, id, version2);
728
744
  return !!file;
729
745
  };
730
- var addServiceToDomain = (directory) => async (id, service, version) => {
731
- let domain = await getDomain(directory)(id, version);
732
- const domainPath = await getResourcePath(directory, id, version);
746
+ var addServiceToDomain = (directory) => async (id, service, version2) => {
747
+ let domain = await getDomain(directory)(id, version2);
748
+ const domainPath = await getResourcePath(directory, id, version2);
733
749
  const extension = import_node_path8.default.extname(domainPath?.fullPath || "");
734
750
  if (domain.services === void 0) {
735
751
  domain.services = [];
@@ -739,12 +755,12 @@ var addServiceToDomain = (directory) => async (id, service, version) => {
739
755
  return;
740
756
  }
741
757
  domain.services.push(service);
742
- await rmDomainById(directory)(id, version, true);
758
+ await rmDomainById(directory)(id, version2, true);
743
759
  await writeDomain(directory)(domain, { format: extension === ".md" ? "md" : "mdx" });
744
760
  };
745
- var addSubDomainToDomain = (directory) => async (id, subDomain, version) => {
746
- let domain = await getDomain(directory)(id, version);
747
- const domainPath = await getResourcePath(directory, id, version);
761
+ var addSubDomainToDomain = (directory) => async (id, subDomain, version2) => {
762
+ let domain = await getDomain(directory)(id, version2);
763
+ const domainPath = await getResourcePath(directory, id, version2);
748
764
  const extension = import_node_path8.default.extname(domainPath?.fullPath || "");
749
765
  if (domain.domains === void 0) {
750
766
  domain.domains = [];
@@ -754,12 +770,12 @@ var addSubDomainToDomain = (directory) => async (id, subDomain, version) => {
754
770
  return;
755
771
  }
756
772
  domain.domains.push(subDomain);
757
- await rmDomainById(directory)(id, version, true);
773
+ await rmDomainById(directory)(id, version2, true);
758
774
  await writeDomain(directory)(domain, { format: extension === ".md" ? "md" : "mdx" });
759
775
  };
760
- var addEntityToDomain = (directory) => async (id, entity, version) => {
761
- let domain = await getDomain(directory)(id, version);
762
- const domainPath = await getResourcePath(directory, id, version);
776
+ var addEntityToDomain = (directory) => async (id, entity, version2) => {
777
+ let domain = await getDomain(directory)(id, version2);
778
+ const domainPath = await getResourcePath(directory, id, version2);
763
779
  const extension = import_node_path8.default.extname(domainPath?.fullPath || "");
764
780
  if (domain.entities === void 0) {
765
781
  domain.entities = [];
@@ -769,12 +785,12 @@ var addEntityToDomain = (directory) => async (id, entity, version) => {
769
785
  return;
770
786
  }
771
787
  domain.entities.push(entity);
772
- await rmDomainById(directory)(id, version, true);
788
+ await rmDomainById(directory)(id, version2, true);
773
789
  await writeDomain(directory)(domain, { format: extension === ".md" ? "md" : "mdx" });
774
790
  };
775
- var addDataProductToDomain = (directory) => async (id, dataProduct, version) => {
776
- let domain = await getDomain(directory)(id, version);
777
- const domainPath = await getResourcePath(directory, id, version);
791
+ var addDataProductToDomain = (directory) => async (id, dataProduct, version2) => {
792
+ let domain = await getDomain(directory)(id, version2);
793
+ const domainPath = await getResourcePath(directory, id, version2);
778
794
  const extension = import_node_path8.default.extname(domainPath?.fullPath || "");
779
795
  if (domain.dataProducts === void 0) {
780
796
  domain.dataProducts = [];
@@ -786,12 +802,12 @@ var addDataProductToDomain = (directory) => async (id, dataProduct, version) =>
786
802
  return;
787
803
  }
788
804
  domain.dataProducts.push(dataProduct);
789
- await rmDomainById(directory)(id, version, true);
805
+ await rmDomainById(directory)(id, version2, true);
790
806
  await writeDomain(directory)(domain, { format: extension === ".md" ? "md" : "mdx" });
791
807
  };
792
- var addMessageToDomain = (directory) => async (id, direction, message, version) => {
793
- let domain = await getDomain(directory)(id, version);
794
- const domainPath = await getResourcePath(directory, id, version);
808
+ var addMessageToDomain = (directory) => async (id, direction, message, version2) => {
809
+ let domain = await getDomain(directory)(id, version2);
810
+ const domainPath = await getResourcePath(directory, id, version2);
795
811
  const extension = import_node_path8.default.extname(domainPath?.fullPath || "");
796
812
  if (direction === "sends") {
797
813
  if (domain.sends === void 0) {
@@ -816,34 +832,34 @@ var addMessageToDomain = (directory) => async (id, direction, message, version)
816
832
  } else {
817
833
  throw new Error(`Direction ${direction} is invalid, only 'receives' and 'sends' are supported`);
818
834
  }
819
- const existingResource = await findFileById(directory, id, version);
835
+ const existingResource = await findFileById(directory, id, version2);
820
836
  if (!existingResource) {
821
837
  throw new Error(`Cannot find domain ${id} in the catalog`);
822
838
  }
823
839
  const normalizedPath = existingResource.replace(/\\/g, "/");
824
840
  const lastDomainsIndex = normalizedPath.lastIndexOf("/domains/");
825
841
  const pathToResource = existingResource.substring(0, lastDomainsIndex + "/domains".length);
826
- await rmDomainById(directory)(id, version, true);
842
+ await rmDomainById(directory)(id, version2, true);
827
843
  await writeDomain(pathToResource)(domain, { format: extension === ".md" ? "md" : "mdx" });
828
844
  };
829
845
 
830
846
  // src/channels.ts
831
847
  var import_promises7 = __toESM(require("fs/promises"));
832
848
  var import_node_path9 = require("path");
833
- var getChannel = (directory) => async (id, version) => getResource(directory, id, version, { type: "channel" });
849
+ var getChannel = (directory) => async (id, version2) => getResource(directory, id, version2, { type: "channel" });
834
850
  var getChannels = (directory) => async (options) => getResources(directory, { type: "channels", ...options });
835
851
  var writeChannel = (directory) => async (channel, options = { path: "" }) => writeResource(directory, { ...channel }, { ...options, type: "channel" });
836
852
  var rmChannel = (directory) => async (path6) => {
837
853
  await import_promises7.default.rm((0, import_node_path9.join)(directory, path6), { recursive: true });
838
854
  };
839
- var rmChannelById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "channel", persistFiles });
855
+ var rmChannelById = (directory) => async (id, version2, persistFiles) => rmResourceById(directory, id, version2, { type: "channel", persistFiles });
840
856
  var versionChannel = (directory) => async (id) => versionResource(directory, id);
841
- var channelHasVersion = (directory) => async (id, version) => {
842
- const file = await findFileById(directory, id, version);
857
+ var channelHasVersion = (directory) => async (id, version2) => {
858
+ const file = await findFileById(directory, id, version2);
843
859
  return !!file;
844
860
  };
845
- var addMessageToChannel = (directory, collection) => async (id, _message, version) => {
846
- let channel = await getChannel(directory)(id, version);
861
+ var addMessageToChannel = (directory, collection) => async (id, _message, version2) => {
862
+ let channel = await getChannel(directory)(id, version2);
847
863
  const functions = {
848
864
  events: {
849
865
  getMessage: getEvent,
@@ -894,13 +910,13 @@ var getMessageBySchemaPath = (directory) => async (path6, options) => {
894
910
  }
895
911
  const messageFile = files[0];
896
912
  const { data } = import_gray_matter4.default.read(messageFile);
897
- const { id, version } = data;
898
- if (!id || !version) {
913
+ const { id, version: version2 } = data;
914
+ if (!id || !version2) {
899
915
  throw new Error(`Message definition file at ${messageFile} is missing 'id' or 'version' in its frontmatter.`);
900
916
  }
901
- const message = await getResource(directory, id, version, { type: "message", ...options });
917
+ const message = await getResource(directory, id, version2, { type: "message", ...options });
902
918
  if (!message) {
903
- throw new Error(`Message resource with id '${id}' and version '${version}' not found, as referenced in ${messageFile}.`);
919
+ throw new Error(`Message resource with id '${id}' and version '${version2}' not found, as referenced in ${messageFile}.`);
904
920
  }
905
921
  return message;
906
922
  } catch (error) {
@@ -911,12 +927,12 @@ var getMessageBySchemaPath = (directory) => async (path6, options) => {
911
927
  throw new Error(`Failed to retrieve message from ${pathToMessage} due to an unknown error.`);
912
928
  }
913
929
  };
914
- var getProducersAndConsumersForMessage = (directory) => async (id, version, options) => {
930
+ var getProducersAndConsumersForMessage = (directory) => async (id, version2, options) => {
915
931
  const services = await getServices(directory)({ latestOnly: options?.latestOnly ?? true });
916
- const message = await getResource(directory, id, version, { type: "message" });
917
- const isMessageLatestVersion = await isLatestVersion(directory, id, version);
932
+ const message = await getResource(directory, id, version2, { type: "message" });
933
+ const isMessageLatestVersion = await isLatestVersion(directory, id, version2);
918
934
  if (!message) {
919
- throw new Error(`Message resource with id '${id}' and version '${version}' not found.`);
935
+ throw new Error(`Message resource with id '${id}' and version '${version2}' not found.`);
920
936
  }
921
937
  const producers = [];
922
938
  const consumers = [];
@@ -1108,8 +1124,8 @@ var writeTeam = (catalogDir) => async (team, options = {}) => {
1108
1124
  var rmTeamById = (catalogDir) => async (id) => {
1109
1125
  await import_promises9.default.rm((0, import_node_path13.join)(catalogDir, `${id}.mdx`), { recursive: true });
1110
1126
  };
1111
- var getOwnersForResource = (catalogDir) => async (id, version) => {
1112
- const resource = await getResource(catalogDir, id, version);
1127
+ var getOwnersForResource = (catalogDir) => async (id, version2) => {
1128
+ const resource = await getResource(catalogDir, id, version2);
1113
1129
  let owners = [];
1114
1130
  if (!resource) return [];
1115
1131
  if (!resource.owners) return [];
@@ -1127,10 +1143,107 @@ var getOwnersForResource = (catalogDir) => async (id, version) => {
1127
1143
  return owners;
1128
1144
  };
1129
1145
 
1146
+ // src/eventcatalog.ts
1147
+ var import_fs = __toESM(require("fs"));
1148
+ var import_node_path15 = __toESM(require("path"));
1149
+ var DUMP_VERSION = "0.0.1";
1150
+ var getEventCatalogVersion = async (catalogDir) => {
1151
+ try {
1152
+ const packageJson = import_fs.default.readFileSync((0, import_node_path15.join)(catalogDir, "package.json"), "utf8");
1153
+ const packageJsonObject = JSON.parse(packageJson);
1154
+ return packageJsonObject["dependencies"]["@eventcatalog/core"];
1155
+ } catch (error) {
1156
+ return "unknown";
1157
+ }
1158
+ };
1159
+ var hydrateResource = async (catalogDir, resources = [], { attachSchema = false } = {}) => {
1160
+ return await Promise.all(
1161
+ resources.map(async (resource) => {
1162
+ const resourcePath = await getResourcePath(catalogDir, resource.id, resource.version);
1163
+ let schema = "";
1164
+ if (resource.schemaPath && resourcePath?.fullPath) {
1165
+ const pathToSchema = import_node_path15.default.join(import_node_path15.default.dirname(resourcePath?.fullPath), resource.schemaPath);
1166
+ if (import_fs.default.existsSync(pathToSchema)) {
1167
+ schema = import_fs.default.readFileSync(pathToSchema, "utf8");
1168
+ }
1169
+ }
1170
+ const eventcatalog = schema ? { directory: resourcePath?.directory, schema } : { directory: resourcePath?.directory };
1171
+ return {
1172
+ ...resource,
1173
+ _eventcatalog: eventcatalog
1174
+ };
1175
+ })
1176
+ );
1177
+ };
1178
+ var filterCollection = (collection, options) => {
1179
+ return collection.map((item) => ({
1180
+ ...item,
1181
+ markdown: options?.includeMarkdown ? item.markdown : void 0
1182
+ }));
1183
+ };
1184
+ var getEventCatalogConfigurationFile = (directory) => async () => {
1185
+ try {
1186
+ const path6 = (0, import_node_path15.join)(directory, "eventcatalog.config.js");
1187
+ const configModule = await import(path6);
1188
+ return configModule.default;
1189
+ } catch (error) {
1190
+ console.error("Error getting event catalog configuration file", error);
1191
+ return null;
1192
+ }
1193
+ };
1194
+ var dumpCatalog = (directory) => async (options) => {
1195
+ const { getDomains: getDomains2, getServices: getServices2, getEvents: getEvents2, getQueries: getQueries2, getCommands: getCommands2, getChannels: getChannels2, getTeams: getTeams2, getUsers: getUsers3 } = src_default(directory);
1196
+ const { includeMarkdown = true } = options || {};
1197
+ const domains = await getDomains2();
1198
+ const services = await getServices2();
1199
+ const events = await getEvents2();
1200
+ const commands = await getCommands2();
1201
+ const queries = await getQueries2();
1202
+ const teams = await getTeams2();
1203
+ const users = await getUsers3();
1204
+ const channels = await getChannels2();
1205
+ const [
1206
+ hydratedDomains,
1207
+ hydratedServices,
1208
+ hydratedEvents,
1209
+ hydratedQueries,
1210
+ hydratedCommands,
1211
+ hydratedTeams,
1212
+ hydratedUsers,
1213
+ hydratedChannels
1214
+ ] = await Promise.all([
1215
+ hydrateResource(directory, domains),
1216
+ hydrateResource(directory, services),
1217
+ hydrateResource(directory, events),
1218
+ hydrateResource(directory, queries),
1219
+ hydrateResource(directory, commands),
1220
+ hydrateResource(directory, teams),
1221
+ hydrateResource(directory, users),
1222
+ hydrateResource(directory, channels)
1223
+ ]);
1224
+ return {
1225
+ version: DUMP_VERSION,
1226
+ catalogVersion: await getEventCatalogVersion(directory),
1227
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1228
+ resources: {
1229
+ domains: filterCollection(hydratedDomains, { includeMarkdown }),
1230
+ services: filterCollection(hydratedServices, { includeMarkdown }),
1231
+ messages: {
1232
+ events: filterCollection(hydratedEvents, { includeMarkdown }),
1233
+ queries: filterCollection(hydratedQueries, { includeMarkdown }),
1234
+ commands: filterCollection(hydratedCommands, { includeMarkdown })
1235
+ },
1236
+ teams: filterCollection(hydratedTeams, { includeMarkdown }),
1237
+ users: filterCollection(hydratedUsers, { includeMarkdown }),
1238
+ channels: filterCollection(hydratedChannels, { includeMarkdown })
1239
+ }
1240
+ };
1241
+ };
1242
+
1130
1243
  // src/entities.ts
1131
1244
  var import_promises10 = __toESM(require("fs/promises"));
1132
- var import_node_path15 = require("path");
1133
- var getEntity = (directory) => async (id, version) => getResource(directory, id, version, { type: "entity" });
1245
+ var import_node_path16 = require("path");
1246
+ var getEntity = (directory) => async (id, version2) => getResource(directory, id, version2, { type: "entity" });
1134
1247
  var getEntities = (directory) => async (options) => getResources(directory, { type: "entities", latestOnly: options?.latestOnly });
1135
1248
  var writeEntity = (directory) => async (entity, options = {
1136
1249
  path: "",
@@ -1138,21 +1251,21 @@ var writeEntity = (directory) => async (entity, options = {
1138
1251
  format: "mdx"
1139
1252
  }) => writeResource(directory, { ...entity }, { ...options, type: "entity" });
1140
1253
  var rmEntity = (directory) => async (path6) => {
1141
- await import_promises10.default.rm((0, import_node_path15.join)(directory, path6), { recursive: true });
1254
+ await import_promises10.default.rm((0, import_node_path16.join)(directory, path6), { recursive: true });
1142
1255
  };
1143
- var rmEntityById = (directory) => async (id, version, persistFiles) => {
1144
- await rmResourceById(directory, id, version, { type: "entity", persistFiles });
1256
+ var rmEntityById = (directory) => async (id, version2, persistFiles) => {
1257
+ await rmResourceById(directory, id, version2, { type: "entity", persistFiles });
1145
1258
  };
1146
1259
  var versionEntity = (directory) => async (id) => versionResource(directory, id);
1147
- var entityHasVersion = (directory) => async (id, version) => {
1148
- const file = await findFileById(directory, id, version);
1260
+ var entityHasVersion = (directory) => async (id, version2) => {
1261
+ const file = await findFileById(directory, id, version2);
1149
1262
  return !!file;
1150
1263
  };
1151
1264
 
1152
1265
  // src/containers.ts
1153
1266
  var import_promises11 = __toESM(require("fs/promises"));
1154
- var import_node_path16 = require("path");
1155
- var getContainer = (directory) => async (id, version) => getResource(directory, id, version, { type: "container" });
1267
+ var import_node_path17 = require("path");
1268
+ var getContainer = (directory) => async (id, version2) => getResource(directory, id, version2, { type: "container" });
1156
1269
  var getContainers = (directory) => async (options) => getResources(directory, { type: "containers", latestOnly: options?.latestOnly });
1157
1270
  var writeContainer = (directory) => async (data, options = {
1158
1271
  path: "",
@@ -1161,23 +1274,23 @@ var writeContainer = (directory) => async (data, options = {
1161
1274
  }) => writeResource(directory, { ...data }, { ...options, type: "container" });
1162
1275
  var versionContainer = (directory) => async (id) => versionResource(directory, id);
1163
1276
  var rmContainer = (directory) => async (path6) => {
1164
- await import_promises11.default.rm((0, import_node_path16.join)(directory, path6), { recursive: true });
1277
+ await import_promises11.default.rm((0, import_node_path17.join)(directory, path6), { recursive: true });
1165
1278
  };
1166
- var rmContainerById = (directory) => async (id, version, persistFiles) => {
1167
- await rmResourceById(directory, id, version, { type: "container", persistFiles });
1279
+ var rmContainerById = (directory) => async (id, version2, persistFiles) => {
1280
+ await rmResourceById(directory, id, version2, { type: "container", persistFiles });
1168
1281
  };
1169
- var containerHasVersion = (directory) => async (id, version) => {
1170
- const file = await findFileById(directory, id, version);
1282
+ var containerHasVersion = (directory) => async (id, version2) => {
1283
+ const file = await findFileById(directory, id, version2);
1171
1284
  return !!file;
1172
1285
  };
1173
- var addFileToContainer = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
1286
+ var addFileToContainer = (directory) => async (id, file, version2) => addFileToResource(directory, id, file, version2);
1174
1287
  var writeContainerToService = (directory) => async (container, service, options = { path: "", format: "mdx", override: false }) => {
1175
1288
  const resourcePath = await getResourcePath(directory, service.id, service.version);
1176
1289
  if (!resourcePath) {
1177
1290
  throw new Error("Service not found");
1178
1291
  }
1179
1292
  let pathForContainer = service.version && service.version !== "latest" ? `${resourcePath.directory}/versioned/${service.version}/containers` : `${resourcePath.directory}/containers`;
1180
- pathForContainer = (0, import_node_path16.join)(pathForContainer, container.id);
1293
+ pathForContainer = (0, import_node_path17.join)(pathForContainer, container.id);
1181
1294
  await writeResource(directory, { ...container }, { ...options, path: pathForContainer, type: "container" });
1182
1295
  };
1183
1296
 
@@ -1194,8 +1307,8 @@ var writeDataStoreToService = writeContainerToService;
1194
1307
 
1195
1308
  // src/data-products.ts
1196
1309
  var import_promises12 = __toESM(require("fs/promises"));
1197
- var import_node_path17 = require("path");
1198
- var getDataProduct = (directory) => async (id, version) => getResource(directory, id, version, { type: "data-product" });
1310
+ var import_node_path18 = require("path");
1311
+ var getDataProduct = (directory) => async (id, version2) => getResource(directory, id, version2, { type: "data-product" });
1199
1312
  var getDataProducts = (directory) => async (options) => getResources(directory, { type: "data-products", latestOnly: options?.latestOnly });
1200
1313
  var writeDataProduct = (directory) => async (dataProduct, options = {
1201
1314
  path: "",
@@ -1204,21 +1317,21 @@ var writeDataProduct = (directory) => async (dataProduct, options = {
1204
1317
  }) => writeResource(directory, { ...dataProduct }, { ...options, type: "data-product" });
1205
1318
  var writeDataProductToDomain = (directory) => async (dataProduct, domain, options = { path: "", format: "mdx", override: false }) => {
1206
1319
  let pathForDataProduct = domain.version && domain.version !== "latest" ? `/${domain.id}/versioned/${domain.version}/data-products` : `/${domain.id}/data-products`;
1207
- pathForDataProduct = (0, import_node_path17.join)(pathForDataProduct, dataProduct.id);
1320
+ pathForDataProduct = (0, import_node_path18.join)(pathForDataProduct, dataProduct.id);
1208
1321
  await writeResource(directory, { ...dataProduct }, { ...options, path: pathForDataProduct, type: "data-product" });
1209
1322
  };
1210
1323
  var rmDataProduct = (directory) => async (path6) => {
1211
- await import_promises12.default.rm((0, import_node_path17.join)(directory, path6), { recursive: true });
1324
+ await import_promises12.default.rm((0, import_node_path18.join)(directory, path6), { recursive: true });
1212
1325
  };
1213
- var rmDataProductById = (directory) => async (id, version, persistFiles) => {
1214
- await rmResourceById(directory, id, version, { type: "data-product", persistFiles });
1326
+ var rmDataProductById = (directory) => async (id, version2, persistFiles) => {
1327
+ await rmResourceById(directory, id, version2, { type: "data-product", persistFiles });
1215
1328
  };
1216
1329
  var versionDataProduct = (directory) => async (id) => versionResource(directory, id);
1217
- var dataProductHasVersion = (directory) => async (id, version) => {
1218
- const file = await findFileById(directory, id, version);
1330
+ var dataProductHasVersion = (directory) => async (id, version2) => {
1331
+ const file = await findFileById(directory, id, version2);
1219
1332
  return !!file;
1220
1333
  };
1221
- var addFileToDataProduct = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
1334
+ var addFileToDataProduct = (directory) => async (id, file, version2) => addFileToResource(directory, id, file, version2);
1222
1335
 
1223
1336
  // src/index.ts
1224
1337
  var src_default = (path6) => {
@@ -1229,13 +1342,13 @@ var src_default = (path6) => {
1229
1342
  * @param version - Optional id of the version to get (supports semver)
1230
1343
  * @returns Event|Undefined
1231
1344
  */
1232
- getEvent: getEvent((0, import_node_path18.join)(path6)),
1345
+ getEvent: getEvent((0, import_node_path19.join)(path6)),
1233
1346
  /**
1234
1347
  * Returns all events from EventCatalog
1235
1348
  * @param latestOnly - optional boolean, set to true to get only latest versions
1236
1349
  * @returns Event[]|Undefined
1237
1350
  */
1238
- getEvents: getEvents((0, import_node_path18.join)(path6)),
1351
+ getEvents: getEvents((0, import_node_path19.join)(path6)),
1239
1352
  /**
1240
1353
  * Adds an event to EventCatalog
1241
1354
  *
@@ -1243,7 +1356,7 @@ var src_default = (path6) => {
1243
1356
  * @param options - Optional options to write the event
1244
1357
  *
1245
1358
  */
1246
- writeEvent: writeEvent((0, import_node_path18.join)(path6, "events")),
1359
+ writeEvent: writeEvent((0, import_node_path19.join)(path6, "events")),
1247
1360
  /**
1248
1361
  * Adds an event to a service in EventCatalog
1249
1362
  *
@@ -1252,26 +1365,26 @@ var src_default = (path6) => {
1252
1365
  * @param options - Optional options to write the event
1253
1366
  *
1254
1367
  */
1255
- writeEventToService: writeEventToService((0, import_node_path18.join)(path6)),
1368
+ writeEventToService: writeEventToService((0, import_node_path19.join)(path6)),
1256
1369
  /**
1257
1370
  * Remove an event to EventCatalog (modeled on the standard POSIX rm utility)
1258
1371
  *
1259
1372
  * @param path - The path to your event, e.g. `/Inventory/InventoryAdjusted`
1260
1373
  *
1261
1374
  */
1262
- rmEvent: rmEvent((0, import_node_path18.join)(path6, "events")),
1375
+ rmEvent: rmEvent((0, import_node_path19.join)(path6, "events")),
1263
1376
  /**
1264
1377
  * Remove an event by an Event id
1265
1378
  *
1266
1379
  * @param id - The id of the event you want to remove
1267
1380
  *
1268
1381
  */
1269
- rmEventById: rmEventById((0, import_node_path18.join)(path6)),
1382
+ rmEventById: rmEventById((0, import_node_path19.join)(path6)),
1270
1383
  /**
1271
1384
  * Moves a given event id to the version directory
1272
1385
  * @param directory
1273
1386
  */
1274
- versionEvent: versionEvent((0, import_node_path18.join)(path6)),
1387
+ versionEvent: versionEvent((0, import_node_path19.join)(path6)),
1275
1388
  /**
1276
1389
  * Adds a file to the given event
1277
1390
  * @param id - The id of the event to add the file to
@@ -1279,7 +1392,7 @@ var src_default = (path6) => {
1279
1392
  * @param version - Optional version of the event to add the file to
1280
1393
  * @returns
1281
1394
  */
1282
- addFileToEvent: addFileToEvent((0, import_node_path18.join)(path6)),
1395
+ addFileToEvent: addFileToEvent((0, import_node_path19.join)(path6)),
1283
1396
  /**
1284
1397
  * Adds a schema to the given event
1285
1398
  * @param id - The id of the event to add the schema to
@@ -1287,14 +1400,14 @@ var src_default = (path6) => {
1287
1400
  * @param version - Optional version of the event to add the schema to
1288
1401
  * @returns
1289
1402
  */
1290
- addSchemaToEvent: addSchemaToEvent((0, import_node_path18.join)(path6)),
1403
+ addSchemaToEvent: addSchemaToEvent((0, import_node_path19.join)(path6)),
1291
1404
  /**
1292
1405
  * Check to see if an event version exists
1293
1406
  * @param id - The id of the event
1294
1407
  * @param version - The version of the event (supports semver)
1295
1408
  * @returns
1296
1409
  */
1297
- eventHasVersion: eventHasVersion((0, import_node_path18.join)(path6)),
1410
+ eventHasVersion: eventHasVersion((0, import_node_path19.join)(path6)),
1298
1411
  /**
1299
1412
  * ================================
1300
1413
  * Commands
@@ -1306,13 +1419,13 @@ var src_default = (path6) => {
1306
1419
  * @param version - Optional id of the version to get (supports semver)
1307
1420
  * @returns Command|Undefined
1308
1421
  */
1309
- getCommand: getCommand((0, import_node_path18.join)(path6)),
1422
+ getCommand: getCommand((0, import_node_path19.join)(path6)),
1310
1423
  /**
1311
1424
  * Returns all commands from EventCatalog
1312
1425
  * @param latestOnly - optional boolean, set to true to get only latest versions
1313
1426
  * @returns Command[]|Undefined
1314
1427
  */
1315
- getCommands: getCommands((0, import_node_path18.join)(path6)),
1428
+ getCommands: getCommands((0, import_node_path19.join)(path6)),
1316
1429
  /**
1317
1430
  * Adds an command to EventCatalog
1318
1431
  *
@@ -1320,7 +1433,7 @@ var src_default = (path6) => {
1320
1433
  * @param options - Optional options to write the command
1321
1434
  *
1322
1435
  */
1323
- writeCommand: writeCommand((0, import_node_path18.join)(path6, "commands")),
1436
+ writeCommand: writeCommand((0, import_node_path19.join)(path6, "commands")),
1324
1437
  /**
1325
1438
  * Adds a command to a service in EventCatalog
1326
1439
  *
@@ -1329,26 +1442,26 @@ var src_default = (path6) => {
1329
1442
  * @param options - Optional options to write the command
1330
1443
  *
1331
1444
  */
1332
- writeCommandToService: writeCommandToService((0, import_node_path18.join)(path6)),
1445
+ writeCommandToService: writeCommandToService((0, import_node_path19.join)(path6)),
1333
1446
  /**
1334
1447
  * Remove an command to EventCatalog (modeled on the standard POSIX rm utility)
1335
1448
  *
1336
1449
  * @param path - The path to your command, e.g. `/Inventory/InventoryAdjusted`
1337
1450
  *
1338
1451
  */
1339
- rmCommand: rmCommand((0, import_node_path18.join)(path6, "commands")),
1452
+ rmCommand: rmCommand((0, import_node_path19.join)(path6, "commands")),
1340
1453
  /**
1341
1454
  * Remove an command by an Event id
1342
1455
  *
1343
1456
  * @param id - The id of the command you want to remove
1344
1457
  *
1345
1458
  */
1346
- rmCommandById: rmCommandById((0, import_node_path18.join)(path6)),
1459
+ rmCommandById: rmCommandById((0, import_node_path19.join)(path6)),
1347
1460
  /**
1348
1461
  * Moves a given command id to the version directory
1349
1462
  * @param directory
1350
1463
  */
1351
- versionCommand: versionCommand((0, import_node_path18.join)(path6)),
1464
+ versionCommand: versionCommand((0, import_node_path19.join)(path6)),
1352
1465
  /**
1353
1466
  * Adds a file to the given command
1354
1467
  * @param id - The id of the command to add the file to
@@ -1356,7 +1469,7 @@ var src_default = (path6) => {
1356
1469
  * @param version - Optional version of the command to add the file to
1357
1470
  * @returns
1358
1471
  */
1359
- addFileToCommand: addFileToCommand((0, import_node_path18.join)(path6)),
1472
+ addFileToCommand: addFileToCommand((0, import_node_path19.join)(path6)),
1360
1473
  /**
1361
1474
  * Adds a schema to the given command
1362
1475
  * @param id - The id of the command to add the schema to
@@ -1364,14 +1477,14 @@ var src_default = (path6) => {
1364
1477
  * @param version - Optional version of the command to add the schema to
1365
1478
  * @returns
1366
1479
  */
1367
- addSchemaToCommand: addSchemaToCommand((0, import_node_path18.join)(path6)),
1480
+ addSchemaToCommand: addSchemaToCommand((0, import_node_path19.join)(path6)),
1368
1481
  /**
1369
1482
  * Check to see if a command version exists
1370
1483
  * @param id - The id of the command
1371
1484
  * @param version - The version of the command (supports semver)
1372
1485
  * @returns
1373
1486
  */
1374
- commandHasVersion: commandHasVersion((0, import_node_path18.join)(path6)),
1487
+ commandHasVersion: commandHasVersion((0, import_node_path19.join)(path6)),
1375
1488
  /**
1376
1489
  * ================================
1377
1490
  * Queries
@@ -1383,13 +1496,13 @@ var src_default = (path6) => {
1383
1496
  * @param version - Optional id of the version to get (supports semver)
1384
1497
  * @returns Query|Undefined
1385
1498
  */
1386
- getQuery: getQuery((0, import_node_path18.join)(path6)),
1499
+ getQuery: getQuery((0, import_node_path19.join)(path6)),
1387
1500
  /**
1388
1501
  * Returns all queries from EventCatalog
1389
1502
  * @param latestOnly - optional boolean, set to true to get only latest versions
1390
1503
  * @returns Query[]|Undefined
1391
1504
  */
1392
- getQueries: getQueries((0, import_node_path18.join)(path6)),
1505
+ getQueries: getQueries((0, import_node_path19.join)(path6)),
1393
1506
  /**
1394
1507
  * Adds a query to EventCatalog
1395
1508
  *
@@ -1397,7 +1510,7 @@ var src_default = (path6) => {
1397
1510
  * @param options - Optional options to write the event
1398
1511
  *
1399
1512
  */
1400
- writeQuery: writeQuery((0, import_node_path18.join)(path6, "queries")),
1513
+ writeQuery: writeQuery((0, import_node_path19.join)(path6, "queries")),
1401
1514
  /**
1402
1515
  * Adds a query to a service in EventCatalog
1403
1516
  *
@@ -1406,26 +1519,26 @@ var src_default = (path6) => {
1406
1519
  * @param options - Optional options to write the query
1407
1520
  *
1408
1521
  */
1409
- writeQueryToService: writeQueryToService((0, import_node_path18.join)(path6)),
1522
+ writeQueryToService: writeQueryToService((0, import_node_path19.join)(path6)),
1410
1523
  /**
1411
1524
  * Remove an query to EventCatalog (modeled on the standard POSIX rm utility)
1412
1525
  *
1413
1526
  * @param path - The path to your query, e.g. `/Orders/GetOrder`
1414
1527
  *
1415
1528
  */
1416
- rmQuery: rmQuery((0, import_node_path18.join)(path6, "queries")),
1529
+ rmQuery: rmQuery((0, import_node_path19.join)(path6, "queries")),
1417
1530
  /**
1418
1531
  * Remove a query by a Query id
1419
1532
  *
1420
1533
  * @param id - The id of the query you want to remove
1421
1534
  *
1422
1535
  */
1423
- rmQueryById: rmQueryById((0, import_node_path18.join)(path6)),
1536
+ rmQueryById: rmQueryById((0, import_node_path19.join)(path6)),
1424
1537
  /**
1425
1538
  * Moves a given query id to the version directory
1426
1539
  * @param directory
1427
1540
  */
1428
- versionQuery: versionQuery((0, import_node_path18.join)(path6)),
1541
+ versionQuery: versionQuery((0, import_node_path19.join)(path6)),
1429
1542
  /**
1430
1543
  * Adds a file to the given query
1431
1544
  * @param id - The id of the query to add the file to
@@ -1433,7 +1546,7 @@ var src_default = (path6) => {
1433
1546
  * @param version - Optional version of the query to add the file to
1434
1547
  * @returns
1435
1548
  */
1436
- addFileToQuery: addFileToQuery((0, import_node_path18.join)(path6)),
1549
+ addFileToQuery: addFileToQuery((0, import_node_path19.join)(path6)),
1437
1550
  /**
1438
1551
  * Adds a schema to the given query
1439
1552
  * @param id - The id of the query to add the schema to
@@ -1441,14 +1554,14 @@ var src_default = (path6) => {
1441
1554
  * @param version - Optional version of the query to add the schema to
1442
1555
  * @returns
1443
1556
  */
1444
- addSchemaToQuery: addSchemaToQuery((0, import_node_path18.join)(path6)),
1557
+ addSchemaToQuery: addSchemaToQuery((0, import_node_path19.join)(path6)),
1445
1558
  /**
1446
1559
  * Check to see if an query version exists
1447
1560
  * @param id - The id of the query
1448
1561
  * @param version - The version of the query (supports semver)
1449
1562
  * @returns
1450
1563
  */
1451
- queryHasVersion: queryHasVersion((0, import_node_path18.join)(path6)),
1564
+ queryHasVersion: queryHasVersion((0, import_node_path19.join)(path6)),
1452
1565
  /**
1453
1566
  * ================================
1454
1567
  * Channels
@@ -1460,13 +1573,13 @@ var src_default = (path6) => {
1460
1573
  * @param version - Optional id of the version to get (supports semver)
1461
1574
  * @returns Channel|Undefined
1462
1575
  */
1463
- getChannel: getChannel((0, import_node_path18.join)(path6)),
1576
+ getChannel: getChannel((0, import_node_path19.join)(path6)),
1464
1577
  /**
1465
1578
  * Returns all channels from EventCatalog
1466
1579
  * @param latestOnly - optional boolean, set to true to get only latest versions
1467
1580
  * @returns Channel[]|Undefined
1468
1581
  */
1469
- getChannels: getChannels((0, import_node_path18.join)(path6)),
1582
+ getChannels: getChannels((0, import_node_path19.join)(path6)),
1470
1583
  /**
1471
1584
  * Adds an channel to EventCatalog
1472
1585
  *
@@ -1474,33 +1587,33 @@ var src_default = (path6) => {
1474
1587
  * @param options - Optional options to write the channel
1475
1588
  *
1476
1589
  */
1477
- writeChannel: writeChannel((0, import_node_path18.join)(path6, "channels")),
1590
+ writeChannel: writeChannel((0, import_node_path19.join)(path6, "channels")),
1478
1591
  /**
1479
1592
  * Remove an channel to EventCatalog (modeled on the standard POSIX rm utility)
1480
1593
  *
1481
1594
  * @param path - The path to your channel, e.g. `/Inventory/InventoryAdjusted`
1482
1595
  *
1483
1596
  */
1484
- rmChannel: rmChannel((0, import_node_path18.join)(path6, "channels")),
1597
+ rmChannel: rmChannel((0, import_node_path19.join)(path6, "channels")),
1485
1598
  /**
1486
1599
  * Remove an channel by an Event id
1487
1600
  *
1488
1601
  * @param id - The id of the channel you want to remove
1489
1602
  *
1490
1603
  */
1491
- rmChannelById: rmChannelById((0, import_node_path18.join)(path6)),
1604
+ rmChannelById: rmChannelById((0, import_node_path19.join)(path6)),
1492
1605
  /**
1493
1606
  * Moves a given channel id to the version directory
1494
1607
  * @param directory
1495
1608
  */
1496
- versionChannel: versionChannel((0, import_node_path18.join)(path6)),
1609
+ versionChannel: versionChannel((0, import_node_path19.join)(path6)),
1497
1610
  /**
1498
1611
  * Check to see if a channel version exists
1499
1612
  * @param id - The id of the channel
1500
1613
  * @param version - The version of the channel (supports semver)
1501
1614
  * @returns
1502
1615
  */
1503
- channelHasVersion: channelHasVersion((0, import_node_path18.join)(path6)),
1616
+ channelHasVersion: channelHasVersion((0, import_node_path19.join)(path6)),
1504
1617
  /**
1505
1618
  * Add a channel to an event
1506
1619
  *
@@ -1517,7 +1630,7 @@ var src_default = (path6) => {
1517
1630
  *
1518
1631
  * ```
1519
1632
  */
1520
- addEventToChannel: addMessageToChannel((0, import_node_path18.join)(path6), "events"),
1633
+ addEventToChannel: addMessageToChannel((0, import_node_path19.join)(path6), "events"),
1521
1634
  /**
1522
1635
  * Add a channel to an command
1523
1636
  *
@@ -1534,7 +1647,7 @@ var src_default = (path6) => {
1534
1647
  *
1535
1648
  * ```
1536
1649
  */
1537
- addCommandToChannel: addMessageToChannel((0, import_node_path18.join)(path6), "commands"),
1650
+ addCommandToChannel: addMessageToChannel((0, import_node_path19.join)(path6), "commands"),
1538
1651
  /**
1539
1652
  * Add a channel to an query
1540
1653
  *
@@ -1551,7 +1664,7 @@ var src_default = (path6) => {
1551
1664
  *
1552
1665
  * ```
1553
1666
  */
1554
- addQueryToChannel: addMessageToChannel((0, import_node_path18.join)(path6), "queries"),
1667
+ addQueryToChannel: addMessageToChannel((0, import_node_path19.join)(path6), "queries"),
1555
1668
  /**
1556
1669
  * ================================
1557
1670
  * SERVICES
@@ -1564,14 +1677,14 @@ var src_default = (path6) => {
1564
1677
  * @param options - Optional options to write the event
1565
1678
  *
1566
1679
  */
1567
- writeService: writeService((0, import_node_path18.join)(path6, "services")),
1680
+ writeService: writeService((0, import_node_path19.join)(path6, "services")),
1568
1681
  /**
1569
1682
  * Adds a versioned service to EventCatalog
1570
1683
  *
1571
1684
  * @param service - The service to write
1572
1685
  *
1573
1686
  */
1574
- writeVersionedService: writeVersionedService((0, import_node_path18.join)(path6, "services")),
1687
+ writeVersionedService: writeVersionedService((0, import_node_path19.join)(path6, "services")),
1575
1688
  /**
1576
1689
  * Adds a service to a domain in EventCatalog
1577
1690
  *
@@ -1580,45 +1693,45 @@ var src_default = (path6) => {
1580
1693
  * @param options - Optional options to write the event
1581
1694
  *
1582
1695
  */
1583
- writeServiceToDomain: writeServiceToDomain((0, import_node_path18.join)(path6, "domains")),
1696
+ writeServiceToDomain: writeServiceToDomain((0, import_node_path19.join)(path6, "domains")),
1584
1697
  /**
1585
1698
  * Returns a service from EventCatalog
1586
1699
  * @param id - The id of the service to retrieve
1587
1700
  * @param version - Optional id of the version to get (supports semver)
1588
1701
  * @returns Service|Undefined
1589
1702
  */
1590
- getService: getService((0, import_node_path18.join)(path6)),
1703
+ getService: getService((0, import_node_path19.join)(path6)),
1591
1704
  /**
1592
1705
  * Returns a service from EventCatalog by it's path.
1593
1706
  * @param path - The path to the service to retrieve
1594
1707
  * @returns Service|Undefined
1595
1708
  */
1596
- getServiceByPath: getServiceByPath((0, import_node_path18.join)(path6)),
1709
+ getServiceByPath: getServiceByPath((0, import_node_path19.join)(path6)),
1597
1710
  /**
1598
1711
  * Returns all services from EventCatalog
1599
1712
  * @param latestOnly - optional boolean, set to true to get only latest versions
1600
1713
  * @returns Service[]|Undefined
1601
1714
  */
1602
- getServices: getServices((0, import_node_path18.join)(path6)),
1715
+ getServices: getServices((0, import_node_path19.join)(path6)),
1603
1716
  /**
1604
1717
  * Moves a given service id to the version directory
1605
1718
  * @param directory
1606
1719
  */
1607
- versionService: versionService((0, import_node_path18.join)(path6)),
1720
+ versionService: versionService((0, import_node_path19.join)(path6)),
1608
1721
  /**
1609
1722
  * Remove a service from EventCatalog (modeled on the standard POSIX rm utility)
1610
1723
  *
1611
1724
  * @param path - The path to your service, e.g. `/InventoryService`
1612
1725
  *
1613
1726
  */
1614
- rmService: rmService((0, import_node_path18.join)(path6, "services")),
1727
+ rmService: rmService((0, import_node_path19.join)(path6, "services")),
1615
1728
  /**
1616
1729
  * Remove an service by an service id
1617
1730
  *
1618
1731
  * @param id - The id of the service you want to remove
1619
1732
  *
1620
1733
  */
1621
- rmServiceById: rmServiceById((0, import_node_path18.join)(path6)),
1734
+ rmServiceById: rmServiceById((0, import_node_path19.join)(path6)),
1622
1735
  /**
1623
1736
  * Adds a file to the given service
1624
1737
  * @param id - The id of the service to add the file to
@@ -1626,21 +1739,21 @@ var src_default = (path6) => {
1626
1739
  * @param version - Optional version of the service to add the file to
1627
1740
  * @returns
1628
1741
  */
1629
- addFileToService: addFileToService((0, import_node_path18.join)(path6)),
1742
+ addFileToService: addFileToService((0, import_node_path19.join)(path6)),
1630
1743
  /**
1631
1744
  * Returns the specifications for a given service
1632
1745
  * @param id - The id of the service to retrieve the specifications for
1633
1746
  * @param version - Optional version of the service
1634
1747
  * @returns
1635
1748
  */
1636
- getSpecificationFilesForService: getSpecificationFilesForService((0, import_node_path18.join)(path6)),
1749
+ getSpecificationFilesForService: getSpecificationFilesForService((0, import_node_path19.join)(path6)),
1637
1750
  /**
1638
1751
  * Check to see if a service version exists
1639
1752
  * @param id - The id of the service
1640
1753
  * @param version - The version of the service (supports semver)
1641
1754
  * @returns
1642
1755
  */
1643
- serviceHasVersion: serviceHasVersion((0, import_node_path18.join)(path6)),
1756
+ serviceHasVersion: serviceHasVersion((0, import_node_path19.join)(path6)),
1644
1757
  /**
1645
1758
  * Add an event to a service by it's id.
1646
1759
  *
@@ -1660,7 +1773,7 @@ var src_default = (path6) => {
1660
1773
  *
1661
1774
  * ```
1662
1775
  */
1663
- addEventToService: addMessageToService((0, import_node_path18.join)(path6)),
1776
+ addEventToService: addMessageToService((0, import_node_path19.join)(path6)),
1664
1777
  /**
1665
1778
  * Add a data store to a service by it's id.
1666
1779
  *
@@ -1677,7 +1790,7 @@ var src_default = (path6) => {
1677
1790
  *
1678
1791
  * ```
1679
1792
  */
1680
- addDataStoreToService: addDataStoreToService((0, import_node_path18.join)(path6)),
1793
+ addDataStoreToService: addDataStoreToService((0, import_node_path19.join)(path6)),
1681
1794
  /**
1682
1795
  * Add a command to a service by it's id.
1683
1796
  *
@@ -1697,7 +1810,7 @@ var src_default = (path6) => {
1697
1810
  *
1698
1811
  * ```
1699
1812
  */
1700
- addCommandToService: addMessageToService((0, import_node_path18.join)(path6)),
1813
+ addCommandToService: addMessageToService((0, import_node_path19.join)(path6)),
1701
1814
  /**
1702
1815
  * Add a query to a service by it's id.
1703
1816
  *
@@ -1717,7 +1830,7 @@ var src_default = (path6) => {
1717
1830
  *
1718
1831
  * ```
1719
1832
  */
1720
- addQueryToService: addMessageToService((0, import_node_path18.join)(path6)),
1833
+ addQueryToService: addMessageToService((0, import_node_path19.join)(path6)),
1721
1834
  /**
1722
1835
  * Add an entity to a service by its id.
1723
1836
  *
@@ -1735,7 +1848,7 @@ var src_default = (path6) => {
1735
1848
  *
1736
1849
  * ```
1737
1850
  */
1738
- addEntityToService: addEntityToService((0, import_node_path18.join)(path6)),
1851
+ addEntityToService: addEntityToService((0, import_node_path19.join)(path6)),
1739
1852
  /**
1740
1853
  * Check to see if a service exists by it's path.
1741
1854
  *
@@ -1752,13 +1865,13 @@ var src_default = (path6) => {
1752
1865
  * @param path - The path to the service to check
1753
1866
  * @returns boolean
1754
1867
  */
1755
- isService: isService((0, import_node_path18.join)(path6)),
1868
+ isService: isService((0, import_node_path19.join)(path6)),
1756
1869
  /**
1757
1870
  * Converts a file to a service.
1758
1871
  * @param file - The file to convert to a service.
1759
1872
  * @returns The service.
1760
1873
  */
1761
- toService: toService((0, import_node_path18.join)(path6)),
1874
+ toService: toService((0, import_node_path19.join)(path6)),
1762
1875
  /**
1763
1876
  * ================================
1764
1877
  * Domains
@@ -1771,39 +1884,39 @@ var src_default = (path6) => {
1771
1884
  * @param options - Optional options to write the event
1772
1885
  *
1773
1886
  */
1774
- writeDomain: writeDomain((0, import_node_path18.join)(path6, "domains")),
1887
+ writeDomain: writeDomain((0, import_node_path19.join)(path6, "domains")),
1775
1888
  /**
1776
1889
  * Returns a domain from EventCatalog
1777
1890
  * @param id - The id of the domain to retrieve
1778
1891
  * @param version - Optional id of the version to get (supports semver)
1779
1892
  * @returns Domain|Undefined
1780
1893
  */
1781
- getDomain: getDomain((0, import_node_path18.join)(path6, "domains")),
1894
+ getDomain: getDomain((0, import_node_path19.join)(path6, "domains")),
1782
1895
  /**
1783
1896
  * Returns all domains from EventCatalog
1784
1897
  * @param latestOnly - optional boolean, set to true to get only latest versions
1785
1898
  * @returns Domain[]|Undefined
1786
1899
  */
1787
- getDomains: getDomains((0, import_node_path18.join)(path6)),
1900
+ getDomains: getDomains((0, import_node_path19.join)(path6)),
1788
1901
  /**
1789
1902
  * Moves a given domain id to the version directory
1790
1903
  * @param directory
1791
1904
  */
1792
- versionDomain: versionDomain((0, import_node_path18.join)(path6, "domains")),
1905
+ versionDomain: versionDomain((0, import_node_path19.join)(path6, "domains")),
1793
1906
  /**
1794
1907
  * Remove a domain from EventCatalog (modeled on the standard POSIX rm utility)
1795
1908
  *
1796
1909
  * @param path - The path to your domain, e.g. `/Payment`
1797
1910
  *
1798
1911
  */
1799
- rmDomain: rmDomain((0, import_node_path18.join)(path6, "domains")),
1912
+ rmDomain: rmDomain((0, import_node_path19.join)(path6, "domains")),
1800
1913
  /**
1801
1914
  * Remove an service by an domain id
1802
1915
  *
1803
1916
  * @param id - The id of the domain you want to remove
1804
1917
  *
1805
1918
  */
1806
- rmDomainById: rmDomainById((0, import_node_path18.join)(path6, "domains")),
1919
+ rmDomainById: rmDomainById((0, import_node_path19.join)(path6, "domains")),
1807
1920
  /**
1808
1921
  * Adds a file to the given domain
1809
1922
  * @param id - The id of the domain to add the file to
@@ -1811,28 +1924,28 @@ var src_default = (path6) => {
1811
1924
  * @param version - Optional version of the domain to add the file to
1812
1925
  * @returns
1813
1926
  */
1814
- addFileToDomain: addFileToDomain((0, import_node_path18.join)(path6, "domains")),
1927
+ addFileToDomain: addFileToDomain((0, import_node_path19.join)(path6, "domains")),
1815
1928
  /**
1816
1929
  * Adds an ubiquitous language dictionary to a domain
1817
1930
  * @param id - The id of the domain to add the ubiquitous language to
1818
1931
  * @param ubiquitousLanguageDictionary - The ubiquitous language dictionary to add
1819
1932
  * @param version - Optional version of the domain to add the ubiquitous language to
1820
1933
  */
1821
- addUbiquitousLanguageToDomain: addUbiquitousLanguageToDomain((0, import_node_path18.join)(path6, "domains")),
1934
+ addUbiquitousLanguageToDomain: addUbiquitousLanguageToDomain((0, import_node_path19.join)(path6, "domains")),
1822
1935
  /**
1823
1936
  * Get the ubiquitous language dictionary from a domain
1824
1937
  * @param id - The id of the domain to get the ubiquitous language from
1825
1938
  * @param version - Optional version of the domain to get the ubiquitous language from
1826
1939
  * @returns
1827
1940
  */
1828
- getUbiquitousLanguageFromDomain: getUbiquitousLanguageFromDomain((0, import_node_path18.join)(path6, "domains")),
1941
+ getUbiquitousLanguageFromDomain: getUbiquitousLanguageFromDomain((0, import_node_path19.join)(path6, "domains")),
1829
1942
  /**
1830
1943
  * Check to see if a domain version exists
1831
1944
  * @param id - The id of the domain
1832
1945
  * @param version - The version of the domain (supports semver)
1833
1946
  * @returns
1834
1947
  */
1835
- domainHasVersion: domainHasVersion((0, import_node_path18.join)(path6)),
1948
+ domainHasVersion: domainHasVersion((0, import_node_path19.join)(path6)),
1836
1949
  /**
1837
1950
  * Adds a given service to a domain
1838
1951
  * @param id - The id of the domain
@@ -1840,7 +1953,7 @@ var src_default = (path6) => {
1840
1953
  * @param version - (Optional) The version of the domain to add the service to
1841
1954
  * @returns
1842
1955
  */
1843
- addServiceToDomain: addServiceToDomain((0, import_node_path18.join)(path6, "domains")),
1956
+ addServiceToDomain: addServiceToDomain((0, import_node_path19.join)(path6, "domains")),
1844
1957
  /**
1845
1958
  * Adds a given subdomain to a domain
1846
1959
  * @param id - The id of the domain
@@ -1848,7 +1961,7 @@ var src_default = (path6) => {
1848
1961
  * @param version - (Optional) The version of the domain to add the subdomain to
1849
1962
  * @returns
1850
1963
  */
1851
- addSubDomainToDomain: addSubDomainToDomain((0, import_node_path18.join)(path6, "domains")),
1964
+ addSubDomainToDomain: addSubDomainToDomain((0, import_node_path19.join)(path6, "domains")),
1852
1965
  /**
1853
1966
  * Adds an entity to a domain
1854
1967
  * @param id - The id of the domain
@@ -1856,7 +1969,7 @@ var src_default = (path6) => {
1856
1969
  * @param version - (Optional) The version of the domain to add the entity to
1857
1970
  * @returns
1858
1971
  */
1859
- addEntityToDomain: addEntityToDomain((0, import_node_path18.join)(path6, "domains")),
1972
+ addEntityToDomain: addEntityToDomain((0, import_node_path19.join)(path6, "domains")),
1860
1973
  /**
1861
1974
  * Add an event to a domain by its id.
1862
1975
  *
@@ -1874,7 +1987,7 @@ var src_default = (path6) => {
1874
1987
  *
1875
1988
  * ```
1876
1989
  */
1877
- addEventToDomain: addMessageToDomain((0, import_node_path18.join)(path6, "domains")),
1990
+ addEventToDomain: addMessageToDomain((0, import_node_path19.join)(path6, "domains")),
1878
1991
  /**
1879
1992
  * Add a command to a domain by its id.
1880
1993
  *
@@ -1892,7 +2005,7 @@ var src_default = (path6) => {
1892
2005
  *
1893
2006
  * ```
1894
2007
  */
1895
- addCommandToDomain: addMessageToDomain((0, import_node_path18.join)(path6, "domains")),
2008
+ addCommandToDomain: addMessageToDomain((0, import_node_path19.join)(path6, "domains")),
1896
2009
  /**
1897
2010
  * Add a query to a domain by its id.
1898
2011
  *
@@ -1910,7 +2023,7 @@ var src_default = (path6) => {
1910
2023
  *
1911
2024
  * ```
1912
2025
  */
1913
- addQueryToDomain: addMessageToDomain((0, import_node_path18.join)(path6, "domains")),
2026
+ addQueryToDomain: addMessageToDomain((0, import_node_path19.join)(path6, "domains")),
1914
2027
  /**
1915
2028
  * ================================
1916
2029
  * Teams
@@ -1923,25 +2036,25 @@ var src_default = (path6) => {
1923
2036
  * @param options - Optional options to write the team
1924
2037
  *
1925
2038
  */
1926
- writeTeam: writeTeam((0, import_node_path18.join)(path6, "teams")),
2039
+ writeTeam: writeTeam((0, import_node_path19.join)(path6, "teams")),
1927
2040
  /**
1928
2041
  * Returns a team from EventCatalog
1929
2042
  * @param id - The id of the team to retrieve
1930
2043
  * @returns Team|Undefined
1931
2044
  */
1932
- getTeam: getTeam((0, import_node_path18.join)(path6, "teams")),
2045
+ getTeam: getTeam((0, import_node_path19.join)(path6, "teams")),
1933
2046
  /**
1934
2047
  * Returns all teams from EventCatalog
1935
2048
  * @returns Team[]|Undefined
1936
2049
  */
1937
- getTeams: getTeams((0, import_node_path18.join)(path6, "teams")),
2050
+ getTeams: getTeams((0, import_node_path19.join)(path6, "teams")),
1938
2051
  /**
1939
2052
  * Remove a team by the team id
1940
2053
  *
1941
2054
  * @param id - The id of the team you want to remove
1942
2055
  *
1943
2056
  */
1944
- rmTeamById: rmTeamById((0, import_node_path18.join)(path6, "teams")),
2057
+ rmTeamById: rmTeamById((0, import_node_path19.join)(path6, "teams")),
1945
2058
  /**
1946
2059
  * ================================
1947
2060
  * Users
@@ -1954,25 +2067,25 @@ var src_default = (path6) => {
1954
2067
  * @param options - Optional options to write the user
1955
2068
  *
1956
2069
  */
1957
- writeUser: writeUser((0, import_node_path18.join)(path6, "users")),
2070
+ writeUser: writeUser((0, import_node_path19.join)(path6, "users")),
1958
2071
  /**
1959
2072
  * Returns a user from EventCatalog
1960
2073
  * @param id - The id of the user to retrieve
1961
2074
  * @returns User|Undefined
1962
2075
  */
1963
- getUser: getUser((0, import_node_path18.join)(path6, "users")),
2076
+ getUser: getUser((0, import_node_path19.join)(path6, "users")),
1964
2077
  /**
1965
2078
  * Returns all user from EventCatalog
1966
2079
  * @returns User[]|Undefined
1967
2080
  */
1968
- getUsers: getUsers((0, import_node_path18.join)(path6)),
2081
+ getUsers: getUsers((0, import_node_path19.join)(path6)),
1969
2082
  /**
1970
2083
  * Remove a user by the user id
1971
2084
  *
1972
2085
  * @param id - The id of the user you want to remove
1973
2086
  *
1974
2087
  */
1975
- rmUserById: rmUserById((0, import_node_path18.join)(path6, "users")),
2088
+ rmUserById: rmUserById((0, import_node_path19.join)(path6, "users")),
1976
2089
  /**
1977
2090
  * ================================
1978
2091
  * Custom Docs
@@ -1983,32 +2096,32 @@ var src_default = (path6) => {
1983
2096
  * @param path - The path to the custom doc to retrieve
1984
2097
  * @returns CustomDoc|Undefined
1985
2098
  */
1986
- getCustomDoc: getCustomDoc((0, import_node_path18.join)(path6, "docs")),
2099
+ getCustomDoc: getCustomDoc((0, import_node_path19.join)(path6, "docs")),
1987
2100
  /**
1988
2101
  * Returns all custom docs from EventCatalog
1989
2102
  * @param options - Optional options to get custom docs from a specific path
1990
2103
  * @returns CustomDoc[]|Undefined
1991
2104
  */
1992
- getCustomDocs: getCustomDocs((0, import_node_path18.join)(path6, "docs")),
2105
+ getCustomDocs: getCustomDocs((0, import_node_path19.join)(path6, "docs")),
1993
2106
  /**
1994
2107
  * Writes a custom doc to EventCatalog
1995
2108
  * @param customDoc - The custom doc to write
1996
2109
  * @param options - Optional options to write the custom doc
1997
2110
  *
1998
2111
  */
1999
- writeCustomDoc: writeCustomDoc((0, import_node_path18.join)(path6, "docs")),
2112
+ writeCustomDoc: writeCustomDoc((0, import_node_path19.join)(path6, "docs")),
2000
2113
  /**
2001
2114
  * Removes a custom doc from EventCatalog
2002
2115
  * @param path - The path to the custom doc to remove
2003
2116
  *
2004
2117
  */
2005
- rmCustomDoc: rmCustomDoc((0, import_node_path18.join)(path6, "docs")),
2118
+ rmCustomDoc: rmCustomDoc((0, import_node_path19.join)(path6, "docs")),
2006
2119
  /**
2007
2120
  * Dumps the catalog to a JSON file.
2008
2121
  * @param directory - The directory to dump the catalog to
2009
2122
  * @returns A JSON file with the catalog
2010
2123
  */
2011
- dumpCatalog: dumpCatalog((0, import_node_path18.join)(path6)),
2124
+ dumpCatalog: dumpCatalog((0, import_node_path19.join)(path6)),
2012
2125
  /**
2013
2126
  * Returns the event catalog configuration file.
2014
2127
  * The event catalog configuration file is the file that contains the configuration for the event catalog.
@@ -2016,7 +2129,7 @@ var src_default = (path6) => {
2016
2129
  * @param directory - The directory of the catalog.
2017
2130
  * @returns A JSON object with the configuration for the event catalog.
2018
2131
  */
2019
- getEventCatalogConfigurationFile: getEventCatalogConfigurationFile((0, import_node_path18.join)(path6)),
2132
+ getEventCatalogConfigurationFile: getEventCatalogConfigurationFile((0, import_node_path19.join)(path6)),
2020
2133
  /**
2021
2134
  * ================================
2022
2135
  * Resources Utils
@@ -2041,33 +2154,33 @@ var src_default = (path6) => {
2041
2154
  * @param path - The path to the message to retrieve
2042
2155
  * @returns Message|Undefined
2043
2156
  */
2044
- getMessageBySchemaPath: getMessageBySchemaPath((0, import_node_path18.join)(path6)),
2157
+ getMessageBySchemaPath: getMessageBySchemaPath((0, import_node_path19.join)(path6)),
2045
2158
  /**
2046
2159
  * Returns the producers and consumers (services) for a given message
2047
2160
  * @param id - The id of the message to get the producers and consumers for
2048
2161
  * @param version - Optional version of the message
2049
2162
  * @returns { producers: Service[], consumers: Service[] }
2050
2163
  */
2051
- getProducersAndConsumersForMessage: getProducersAndConsumersForMessage((0, import_node_path18.join)(path6)),
2164
+ getProducersAndConsumersForMessage: getProducersAndConsumersForMessage((0, import_node_path19.join)(path6)),
2052
2165
  /**
2053
2166
  * Returns the consumers of a given schema path
2054
2167
  * @param path - The path to the schema to get the consumers for
2055
2168
  * @returns Service[]
2056
2169
  */
2057
- getConsumersOfSchema: getConsumersOfSchema((0, import_node_path18.join)(path6)),
2170
+ getConsumersOfSchema: getConsumersOfSchema((0, import_node_path19.join)(path6)),
2058
2171
  /**
2059
2172
  * Returns the producers of a given schema path
2060
2173
  * @param path - The path to the schema to get the producers for
2061
2174
  * @returns Service[]
2062
2175
  */
2063
- getProducersOfSchema: getProducersOfSchema((0, import_node_path18.join)(path6)),
2176
+ getProducersOfSchema: getProducersOfSchema((0, import_node_path19.join)(path6)),
2064
2177
  /**
2065
2178
  * Returns the owners for a given resource (e.g domain, service, event, command, query, etc.)
2066
2179
  * @param id - The id of the resource to get the owners for
2067
2180
  * @param version - Optional version of the resource
2068
2181
  * @returns { owners: User[] }
2069
2182
  */
2070
- getOwnersForResource: getOwnersForResource((0, import_node_path18.join)(path6)),
2183
+ getOwnersForResource: getOwnersForResource((0, import_node_path19.join)(path6)),
2071
2184
  /**
2072
2185
  * ================================
2073
2186
  * Entities
@@ -2079,13 +2192,13 @@ var src_default = (path6) => {
2079
2192
  * @param version - Optional id of the version to get (supports semver)
2080
2193
  * @returns Entity|Undefined
2081
2194
  */
2082
- getEntity: getEntity((0, import_node_path18.join)(path6)),
2195
+ getEntity: getEntity((0, import_node_path19.join)(path6)),
2083
2196
  /**
2084
2197
  * Returns all entities from EventCatalog
2085
2198
  * @param latestOnly - optional boolean, set to true to get only latest versions
2086
2199
  * @returns Entity[]|Undefined
2087
2200
  */
2088
- getEntities: getEntities((0, import_node_path18.join)(path6)),
2201
+ getEntities: getEntities((0, import_node_path19.join)(path6)),
2089
2202
  /**
2090
2203
  * Adds an entity to EventCatalog
2091
2204
  *
@@ -2093,33 +2206,33 @@ var src_default = (path6) => {
2093
2206
  * @param options - Optional options to write the entity
2094
2207
  *
2095
2208
  */
2096
- writeEntity: writeEntity((0, import_node_path18.join)(path6, "entities")),
2209
+ writeEntity: writeEntity((0, import_node_path19.join)(path6, "entities")),
2097
2210
  /**
2098
2211
  * Remove an entity from EventCatalog (modeled on the standard POSIX rm utility)
2099
2212
  *
2100
2213
  * @param path - The path to your entity, e.g. `/User`
2101
2214
  *
2102
2215
  */
2103
- rmEntity: rmEntity((0, import_node_path18.join)(path6, "entities")),
2216
+ rmEntity: rmEntity((0, import_node_path19.join)(path6, "entities")),
2104
2217
  /**
2105
2218
  * Remove an entity by an entity id
2106
2219
  *
2107
2220
  * @param id - The id of the entity you want to remove
2108
2221
  *
2109
2222
  */
2110
- rmEntityById: rmEntityById((0, import_node_path18.join)(path6)),
2223
+ rmEntityById: rmEntityById((0, import_node_path19.join)(path6)),
2111
2224
  /**
2112
2225
  * Moves a given entity id to the version directory
2113
2226
  * @param id - The id of the entity to version
2114
2227
  */
2115
- versionEntity: versionEntity((0, import_node_path18.join)(path6)),
2228
+ versionEntity: versionEntity((0, import_node_path19.join)(path6)),
2116
2229
  /**
2117
2230
  * Check to see if an entity version exists
2118
2231
  * @param id - The id of the entity
2119
2232
  * @param version - The version of the entity (supports semver)
2120
2233
  * @returns
2121
2234
  */
2122
- entityHasVersion: entityHasVersion((0, import_node_path18.join)(path6)),
2235
+ entityHasVersion: entityHasVersion((0, import_node_path19.join)(path6)),
2123
2236
  /**
2124
2237
  * ================================
2125
2238
  * Data Stores
@@ -2131,42 +2244,42 @@ var src_default = (path6) => {
2131
2244
  * @param options - Optional options to write the data store
2132
2245
  *
2133
2246
  */
2134
- writeDataStore: writeDataStore((0, import_node_path18.join)(path6, "containers")),
2247
+ writeDataStore: writeDataStore((0, import_node_path19.join)(path6, "containers")),
2135
2248
  /**
2136
2249
  * Returns a data store from EventCatalog
2137
2250
  * @param id - The id of the data store to retrieve
2138
2251
  * @param version - Optional id of the version to get (supports semver)
2139
2252
  * @returns Container|Undefined
2140
2253
  */
2141
- getDataStore: getDataStore((0, import_node_path18.join)(path6)),
2254
+ getDataStore: getDataStore((0, import_node_path19.join)(path6)),
2142
2255
  /**
2143
2256
  * Returns all data stores from EventCatalog
2144
2257
  * @param latestOnly - optional boolean, set to true to get only latest versions
2145
2258
  * @returns Container[]|Undefined
2146
2259
  */
2147
- getDataStores: getDataStores((0, import_node_path18.join)(path6)),
2260
+ getDataStores: getDataStores((0, import_node_path19.join)(path6)),
2148
2261
  /**
2149
2262
  * Version a data store by its id
2150
2263
  * @param id - The id of the data store to version
2151
2264
  */
2152
- versionDataStore: versionDataStore((0, import_node_path18.join)(path6, "containers")),
2265
+ versionDataStore: versionDataStore((0, import_node_path19.join)(path6, "containers")),
2153
2266
  /**
2154
2267
  * Remove a data store by its path
2155
2268
  * @param path - The path to the data store to remove
2156
2269
  */
2157
- rmDataStore: rmDataStore((0, import_node_path18.join)(path6, "containers")),
2270
+ rmDataStore: rmDataStore((0, import_node_path19.join)(path6, "containers")),
2158
2271
  /**
2159
2272
  * Remove a data store by its id
2160
2273
  * @param id - The id of the data store to remove
2161
2274
  */
2162
- rmDataStoreById: rmDataStoreById((0, import_node_path18.join)(path6)),
2275
+ rmDataStoreById: rmDataStoreById((0, import_node_path19.join)(path6)),
2163
2276
  /**
2164
2277
  * Check to see if a data store version exists
2165
2278
  * @param id - The id of the data store
2166
2279
  * @param version - The version of the data store (supports semver)
2167
2280
  * @returns
2168
2281
  */
2169
- dataStoreHasVersion: dataStoreHasVersion((0, import_node_path18.join)(path6)),
2282
+ dataStoreHasVersion: dataStoreHasVersion((0, import_node_path19.join)(path6)),
2170
2283
  /**
2171
2284
  * Adds a file to a data store by its id
2172
2285
  * @param id - The id of the data store to add the file to
@@ -2174,14 +2287,14 @@ var src_default = (path6) => {
2174
2287
  * @param version - Optional version of the data store to add the file to
2175
2288
  * @returns
2176
2289
  */
2177
- addFileToDataStore: addFileToDataStore((0, import_node_path18.join)(path6)),
2290
+ addFileToDataStore: addFileToDataStore((0, import_node_path19.join)(path6)),
2178
2291
  /**
2179
2292
  * Writes a data store to a service by its id
2180
2293
  * @param dataStore - The data store to write
2181
2294
  * @param service - The service to write the data store to
2182
2295
  * @returns
2183
2296
  */
2184
- writeDataStoreToService: writeDataStoreToService((0, import_node_path18.join)(path6)),
2297
+ writeDataStoreToService: writeDataStoreToService((0, import_node_path19.join)(path6)),
2185
2298
  /**
2186
2299
  * ================================
2187
2300
  * Data Products
@@ -2193,7 +2306,7 @@ var src_default = (path6) => {
2193
2306
  * @param options - Optional options to write the data product
2194
2307
  *
2195
2308
  */
2196
- writeDataProduct: writeDataProduct((0, import_node_path18.join)(path6, "data-products")),
2309
+ writeDataProduct: writeDataProduct((0, import_node_path19.join)(path6, "data-products")),
2197
2310
  /**
2198
2311
  * Writes a data product to a domain in EventCatalog
2199
2312
  * @param dataProduct - The data product to write
@@ -2201,43 +2314,43 @@ var src_default = (path6) => {
2201
2314
  * @param options - Optional options to write the data product
2202
2315
  *
2203
2316
  */
2204
- writeDataProductToDomain: writeDataProductToDomain((0, import_node_path18.join)(path6, "domains")),
2317
+ writeDataProductToDomain: writeDataProductToDomain((0, import_node_path19.join)(path6, "domains")),
2205
2318
  /**
2206
2319
  * Returns a data product from EventCatalog
2207
2320
  * @param id - The id of the data product to retrieve
2208
2321
  * @param version - Optional id of the version to get (supports semver)
2209
2322
  * @returns DataProduct|Undefined
2210
2323
  */
2211
- getDataProduct: getDataProduct((0, import_node_path18.join)(path6)),
2324
+ getDataProduct: getDataProduct((0, import_node_path19.join)(path6)),
2212
2325
  /**
2213
2326
  * Returns all data products from EventCatalog
2214
2327
  * @param latestOnly - optional boolean, set to true to get only latest versions
2215
2328
  * @returns DataProduct[]|Undefined
2216
2329
  */
2217
- getDataProducts: getDataProducts((0, import_node_path18.join)(path6)),
2330
+ getDataProducts: getDataProducts((0, import_node_path19.join)(path6)),
2218
2331
  /**
2219
2332
  * Version a data product by its id
2220
2333
  * @param id - The id of the data product to version
2221
2334
  */
2222
- versionDataProduct: versionDataProduct((0, import_node_path18.join)(path6)),
2335
+ versionDataProduct: versionDataProduct((0, import_node_path19.join)(path6)),
2223
2336
  /**
2224
2337
  * Remove a data product by its path
2225
2338
  * @param path - The path to the data product to remove
2226
2339
  */
2227
- rmDataProduct: rmDataProduct((0, import_node_path18.join)(path6, "data-products")),
2340
+ rmDataProduct: rmDataProduct((0, import_node_path19.join)(path6, "data-products")),
2228
2341
  /**
2229
2342
  * Remove a data product by its id
2230
2343
  * @param id - The id of the data product to remove
2231
2344
  * @param version - Optional version of the data product to remove
2232
2345
  */
2233
- rmDataProductById: rmDataProductById((0, import_node_path18.join)(path6)),
2346
+ rmDataProductById: rmDataProductById((0, import_node_path19.join)(path6)),
2234
2347
  /**
2235
2348
  * Check to see if a data product version exists
2236
2349
  * @param id - The id of the data product
2237
2350
  * @param version - The version of the data product (supports semver)
2238
2351
  * @returns
2239
2352
  */
2240
- dataProductHasVersion: dataProductHasVersion((0, import_node_path18.join)(path6)),
2353
+ dataProductHasVersion: dataProductHasVersion((0, import_node_path19.join)(path6)),
2241
2354
  /**
2242
2355
  * Adds a file to a data product by its id
2243
2356
  * @param id - The id of the data product to add the file to
@@ -2245,7 +2358,7 @@ var src_default = (path6) => {
2245
2358
  * @param version - Optional version of the data product to add the file to
2246
2359
  * @returns
2247
2360
  */
2248
- addFileToDataProduct: addFileToDataProduct((0, import_node_path18.join)(path6)),
2361
+ addFileToDataProduct: addFileToDataProduct((0, import_node_path19.join)(path6)),
2249
2362
  /**
2250
2363
  * Adds a data product to a domain
2251
2364
  * @param id - The id of the domain
@@ -2253,107 +2366,121 @@ var src_default = (path6) => {
2253
2366
  * @param version - (Optional) The version of the domain to add the data product to
2254
2367
  * @returns
2255
2368
  */
2256
- addDataProductToDomain: addDataProductToDomain((0, import_node_path18.join)(path6, "domains"))
2369
+ addDataProductToDomain: addDataProductToDomain((0, import_node_path19.join)(path6, "domains"))
2257
2370
  };
2258
2371
  };
2259
2372
 
2260
- // src/eventcatalog.ts
2261
- var DUMP_VERSION = "0.0.1";
2262
- var getEventCatalogVersion = async (catalogDir) => {
2373
+ // src/cli/executor.ts
2374
+ async function executeFunction(catalogDir, functionName, rawArgs) {
2375
+ if (!(0, import_node_fs7.existsSync)(catalogDir)) {
2376
+ throw new Error(`Catalog directory not found: ${catalogDir}`);
2377
+ }
2378
+ const sdk = src_default(catalogDir);
2379
+ if (!(functionName in sdk)) {
2380
+ throw new Error(`Function '${functionName}' not found. Use 'eventcatalog list' to see available functions.`);
2381
+ }
2382
+ const fn = sdk[functionName];
2383
+ if (typeof fn !== "function") {
2384
+ throw new Error(`'${functionName}' is not a callable function.`);
2385
+ }
2386
+ const parsedArgs = parseArguments(rawArgs);
2263
2387
  try {
2264
- const packageJson = import_fs.default.readFileSync((0, import_node_path19.join)(catalogDir, "package.json"), "utf8");
2265
- const packageJsonObject = JSON.parse(packageJson);
2266
- return packageJsonObject["dependencies"]["@eventcatalog/core"];
2388
+ return await fn(...parsedArgs);
2267
2389
  } catch (error) {
2268
- return "unknown";
2390
+ throw new Error(`Error executing '${functionName}': ${error instanceof Error ? error.message : String(error)}`);
2269
2391
  }
2270
- };
2271
- var hydrateResource = async (catalogDir, resources = [], { attachSchema = false } = {}) => {
2272
- return await Promise.all(
2273
- resources.map(async (resource) => {
2274
- const resourcePath = await getResourcePath(catalogDir, resource.id, resource.version);
2275
- let schema = "";
2276
- if (resource.schemaPath && resourcePath?.fullPath) {
2277
- const pathToSchema = import_node_path19.default.join(import_node_path19.default.dirname(resourcePath?.fullPath), resource.schemaPath);
2278
- if (import_fs.default.existsSync(pathToSchema)) {
2279
- schema = import_fs.default.readFileSync(pathToSchema, "utf8");
2280
- }
2281
- }
2282
- const eventcatalog = schema ? { directory: resourcePath?.directory, schema } : { directory: resourcePath?.directory };
2283
- return {
2284
- ...resource,
2285
- _eventcatalog: eventcatalog
2286
- };
2287
- })
2288
- );
2289
- };
2290
- var filterCollection = (collection, options) => {
2291
- return collection.map((item) => ({
2292
- ...item,
2293
- markdown: options?.includeMarkdown ? item.markdown : void 0
2294
- }));
2295
- };
2296
- var getEventCatalogConfigurationFile = (directory) => async () => {
2392
+ }
2393
+
2394
+ // src/cli/list.ts
2395
+ function listFunctions(catalogDir = ".") {
2396
+ const sdk = src_default(catalogDir);
2397
+ const functionNames = Object.keys(sdk).filter((key) => typeof sdk[key] === "function");
2398
+ const categories = {
2399
+ Events: [],
2400
+ Commands: [],
2401
+ Queries: [],
2402
+ Channels: [],
2403
+ Services: [],
2404
+ Domains: [],
2405
+ Entities: [],
2406
+ DataStores: [],
2407
+ DataProducts: [],
2408
+ Teams: [],
2409
+ Users: [],
2410
+ "Custom Docs": [],
2411
+ Messages: [],
2412
+ Utilities: []
2413
+ };
2414
+ functionNames.forEach((name) => {
2415
+ if (name.includes("Event")) categories["Events"].push(name);
2416
+ else if (name.includes("Command")) categories["Commands"].push(name);
2417
+ else if (name.includes("Query")) categories["Queries"].push(name);
2418
+ else if (name.includes("Channel")) categories["Channels"].push(name);
2419
+ else if (name.includes("Service")) categories["Services"].push(name);
2420
+ else if (name.includes("Domain")) categories["Domains"].push(name);
2421
+ else if (name.includes("Entity")) categories["Entities"].push(name);
2422
+ else if (name.includes("DataStore")) categories["DataStores"].push(name);
2423
+ else if (name.includes("DataProduct")) categories["DataProducts"].push(name);
2424
+ else if (name.includes("Team")) categories["Teams"].push(name);
2425
+ else if (name.includes("User")) categories["Users"].push(name);
2426
+ else if (name.includes("CustomDoc")) categories["Custom Docs"].push(name);
2427
+ else if (name.includes("Message") || name.includes("Producers") || name.includes("Consumers"))
2428
+ categories["Messages"].push(name);
2429
+ else categories["Utilities"].push(name);
2430
+ });
2431
+ Object.keys(categories).forEach((key) => {
2432
+ if (categories[key].length === 0) {
2433
+ delete categories[key];
2434
+ }
2435
+ });
2436
+ return categories;
2437
+ }
2438
+ function formatListOutput(functions) {
2439
+ let output = "Available EventCatalog SDK Functions:\n\n";
2440
+ Object.entries(functions).forEach(([category, names]) => {
2441
+ output += `${category}:
2442
+ `;
2443
+ names.sort().forEach((name) => {
2444
+ output += ` - ${name}
2445
+ `;
2446
+ });
2447
+ output += "\n";
2448
+ });
2449
+ return output;
2450
+ }
2451
+
2452
+ // src/cli/index.ts
2453
+ var version = "1.0.0";
2454
+ try {
2455
+ const packageJsonPath = (0, import_node_path20.resolve)(__dirname, "../../package.json");
2456
+ const packageJson = JSON.parse((0, import_node_fs8.readFileSync)(packageJsonPath, "utf-8"));
2457
+ version = packageJson.version;
2458
+ } catch {
2459
+ }
2460
+ import_commander.program.name("eventcatalog").description("EventCatalog SDK Command-Line Interface").version(version).option("-d, --dir <path>", "Path to the EventCatalog directory (default: current directory)", ".");
2461
+ import_commander.program.command("list").description("List all available SDK functions").action(() => {
2297
2462
  try {
2298
- const path6 = (0, import_node_path19.join)(directory, "eventcatalog.config.js");
2299
- const configModule = await import(path6);
2300
- return configModule.default;
2463
+ const functions = listFunctions(".");
2464
+ const output = formatListOutput(functions);
2465
+ console.log(output);
2301
2466
  } catch (error) {
2302
- console.error("Error getting event catalog configuration file", error);
2303
- return null;
2467
+ console.error("Error listing functions:", error instanceof Error ? error.message : String(error));
2468
+ process.exit(1);
2469
+ }
2470
+ });
2471
+ import_commander.program.arguments("<function> [args...]").action(async (functionName, args) => {
2472
+ try {
2473
+ const options = import_commander.program.opts();
2474
+ const dir = options.dir || ".";
2475
+ const result = await executeFunction(dir, functionName, args);
2476
+ console.log(JSON.stringify(result, null, 0));
2477
+ } catch (error) {
2478
+ console.error(error instanceof Error ? error.message : String(error));
2479
+ process.exit(1);
2304
2480
  }
2305
- };
2306
- var dumpCatalog = (directory) => async (options) => {
2307
- const { getDomains: getDomains2, getServices: getServices2, getEvents: getEvents2, getQueries: getQueries2, getCommands: getCommands2, getChannels: getChannels2, getTeams: getTeams2, getUsers: getUsers3 } = src_default(directory);
2308
- const { includeMarkdown = true } = options || {};
2309
- const domains = await getDomains2();
2310
- const services = await getServices2();
2311
- const events = await getEvents2();
2312
- const commands = await getCommands2();
2313
- const queries = await getQueries2();
2314
- const teams = await getTeams2();
2315
- const users = await getUsers3();
2316
- const channels = await getChannels2();
2317
- const [
2318
- hydratedDomains,
2319
- hydratedServices,
2320
- hydratedEvents,
2321
- hydratedQueries,
2322
- hydratedCommands,
2323
- hydratedTeams,
2324
- hydratedUsers,
2325
- hydratedChannels
2326
- ] = await Promise.all([
2327
- hydrateResource(directory, domains),
2328
- hydrateResource(directory, services),
2329
- hydrateResource(directory, events),
2330
- hydrateResource(directory, queries),
2331
- hydrateResource(directory, commands),
2332
- hydrateResource(directory, teams),
2333
- hydrateResource(directory, users),
2334
- hydrateResource(directory, channels)
2335
- ]);
2336
- return {
2337
- version: DUMP_VERSION,
2338
- catalogVersion: await getEventCatalogVersion(directory),
2339
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2340
- resources: {
2341
- domains: filterCollection(hydratedDomains, { includeMarkdown }),
2342
- services: filterCollection(hydratedServices, { includeMarkdown }),
2343
- messages: {
2344
- events: filterCollection(hydratedEvents, { includeMarkdown }),
2345
- queries: filterCollection(hydratedQueries, { includeMarkdown }),
2346
- commands: filterCollection(hydratedCommands, { includeMarkdown })
2347
- },
2348
- teams: filterCollection(hydratedTeams, { includeMarkdown }),
2349
- users: filterCollection(hydratedUsers, { includeMarkdown }),
2350
- channels: filterCollection(hydratedChannels, { includeMarkdown })
2351
- }
2352
- };
2353
- };
2354
- // Annotate the CommonJS export names for ESM import in node:
2355
- 0 && (module.exports = {
2356
- dumpCatalog,
2357
- getEventCatalogConfigurationFile
2358
2481
  });
2359
- //# sourceMappingURL=eventcatalog.js.map
2482
+ import_commander.program.parse(process.argv);
2483
+ if (process.argv.length < 3) {
2484
+ import_commander.program.outputHelp();
2485
+ }
2486
+ //# sourceMappingURL=index.js.map