@eventcatalog/sdk 2.11.0 → 2.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) 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} +588 -378
  5. package/dist/cli/index.js.map +1 -0
  6. package/dist/{eventcatalog.mjs → cli/index.mjs} +666 -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 +1614 -0
  11. package/dist/cli-docs.js.map +1 -0
  12. package/dist/cli-docs.mjs +1586 -0
  13. package/dist/cli-docs.mjs.map +1 -0
  14. package/dist/index.d.mts +443 -25
  15. package/dist/index.d.ts +443 -25
  16. package/dist/index.js +204 -121
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +204 -121
  19. package/dist/index.mjs.map +1 -1
  20. package/package.json +13 -4
  21. package/dist/channels.d.mts +0 -214
  22. package/dist/channels.d.ts +0 -214
  23. package/dist/channels.js +0 -432
  24. package/dist/channels.js.map +0 -1
  25. package/dist/channels.mjs +0 -384
  26. package/dist/channels.mjs.map +0 -1
  27. package/dist/commands.d.mts +0 -274
  28. package/dist/commands.d.ts +0 -274
  29. package/dist/commands.js +0 -394
  30. package/dist/commands.js.map +0 -1
  31. package/dist/commands.mjs +0 -350
  32. package/dist/commands.mjs.map +0 -1
  33. package/dist/containers.d.mts +0 -179
  34. package/dist/containers.d.ts +0 -179
  35. package/dist/containers.js +0 -388
  36. package/dist/containers.js.map +0 -1
  37. package/dist/containers.mjs +0 -345
  38. package/dist/containers.mjs.map +0 -1
  39. package/dist/custom-docs.d.mts +0 -89
  40. package/dist/custom-docs.d.ts +0 -89
  41. package/dist/custom-docs.js +0 -164
  42. package/dist/custom-docs.js.map +0 -1
  43. package/dist/custom-docs.mjs +0 -122
  44. package/dist/custom-docs.mjs.map +0 -1
  45. package/dist/data-products.d.mts +0 -225
  46. package/dist/data-products.d.ts +0 -225
  47. package/dist/data-products.js +0 -375
  48. package/dist/data-products.js.map +0 -1
  49. package/dist/data-products.mjs +0 -332
  50. package/dist/data-products.mjs.map +0 -1
  51. package/dist/data-stores.d.mts +0 -179
  52. package/dist/data-stores.d.ts +0 -179
  53. package/dist/data-stores.js +0 -401
  54. package/dist/data-stores.js.map +0 -1
  55. package/dist/data-stores.mjs +0 -356
  56. package/dist/data-stores.mjs.map +0 -1
  57. package/dist/domains.d.mts +0 -347
  58. package/dist/domains.d.ts +0 -347
  59. package/dist/domains.js +0 -547
  60. package/dist/domains.js.map +0 -1
  61. package/dist/domains.mjs +0 -498
  62. package/dist/domains.mjs.map +0 -1
  63. package/dist/entities.d.mts +0 -174
  64. package/dist/entities.d.ts +0 -174
  65. package/dist/entities.js +0 -348
  66. package/dist/entities.js.map +0 -1
  67. package/dist/entities.mjs +0 -307
  68. package/dist/entities.mjs.map +0 -1
  69. package/dist/eventcatalog.d.mts +0 -21
  70. package/dist/eventcatalog.d.ts +0 -21
  71. package/dist/eventcatalog.js.map +0 -1
  72. package/dist/eventcatalog.mjs.map +0 -1
  73. package/dist/events.d.mts +0 -276
  74. package/dist/events.d.ts +0 -276
  75. package/dist/events.js +0 -393
  76. package/dist/events.js.map +0 -1
  77. package/dist/events.mjs +0 -349
  78. package/dist/events.mjs.map +0 -1
  79. package/dist/messages.d.mts +0 -65
  80. package/dist/messages.d.ts +0 -65
  81. package/dist/messages.js +0 -312
  82. package/dist/messages.js.map +0 -1
  83. package/dist/messages.mjs +0 -269
  84. package/dist/messages.mjs.map +0 -1
  85. package/dist/queries.d.mts +0 -276
  86. package/dist/queries.d.ts +0 -276
  87. package/dist/queries.js +0 -394
  88. package/dist/queries.js.map +0 -1
  89. package/dist/queries.mjs +0 -350
  90. package/dist/queries.mjs.map +0 -1
  91. package/dist/services.d.mts +0 -384
  92. package/dist/services.d.ts +0 -384
  93. package/dist/services.js +0 -577
  94. package/dist/services.js.map +0 -1
  95. package/dist/services.mjs +0 -526
  96. package/dist/services.mjs.map +0 -1
  97. package/dist/teams.d.mts +0 -90
  98. package/dist/teams.d.ts +0 -90
  99. package/dist/teams.js +0 -246
  100. package/dist/teams.js.map +0 -1
  101. package/dist/teams.mjs +0 -202
  102. package/dist/teams.mjs.map +0 -1
  103. package/dist/types.d.d.mts +0 -331
  104. package/dist/types.d.d.ts +0 -331
  105. package/dist/types.d.js +0 -19
  106. package/dist/types.d.js.map +0 -1
  107. package/dist/types.d.mjs +0 -1
  108. package/dist/types.d.mjs.map +0 -1
  109. package/dist/users.d.mts +0 -83
  110. package/dist/users.d.ts +0 -83
  111. package/dist/users.js +0 -127
  112. package/dist/users.js.map +0 -1
  113. package/dist/users.mjs +0 -88
  114. package/dist/users.mjs.map +0 -1
@@ -1,9 +1,44 @@
1
- // src/eventcatalog.ts
2
- import fs13 from "fs";
3
- import path5, { join as join17 } from "node:path";
1
+ #!/usr/bin/env node
2
+
3
+ // node_modules/.pnpm/tsup@8.2.4_postcss@8.4.45_typescript@5.5.4/node_modules/tsup/assets/esm_shims.js
4
+ import { fileURLToPath } from "url";
5
+ import path from "path";
6
+ var getFilename = () => fileURLToPath(import.meta.url);
7
+ var getDirname = () => path.dirname(getFilename());
8
+ var __dirname = /* @__PURE__ */ getDirname();
9
+
10
+ // src/cli/index.ts
11
+ import { program } from "commander";
12
+ import { readFileSync } from "node:fs";
13
+ import { resolve as resolve2 } from "node:path";
14
+
15
+ // src/cli/executor.ts
16
+ import { existsSync } from "node:fs";
17
+
18
+ // src/cli/parser.ts
19
+ function parseArguments(rawArgs) {
20
+ return rawArgs.map((arg, index) => {
21
+ if (arg.startsWith("{") && arg.endsWith("}") || arg.startsWith("[") && arg.endsWith("]")) {
22
+ try {
23
+ return JSON.parse(arg);
24
+ } catch (error) {
25
+ if (arg.includes(":") || arg.includes(",")) {
26
+ throw new Error(`Invalid JSON in argument ${index + 1}: ${error instanceof Error ? error.message : String(error)}`);
27
+ }
28
+ return arg;
29
+ }
30
+ }
31
+ if (arg === "true") return true;
32
+ if (arg === "false") return false;
33
+ if (/^-?\d+(\.\d+)?$/.test(arg)) {
34
+ return Number(arg);
35
+ }
36
+ return arg;
37
+ });
38
+ }
4
39
 
5
40
  // src/index.ts
6
- import { join as join16 } from "node:path";
41
+ import { join as join18 } from "node:path";
7
42
 
8
43
  // src/events.ts
9
44
  import fs2 from "node:fs/promises";
@@ -16,30 +51,30 @@ import { copy } from "fs-extra";
16
51
  import { join, dirname, normalize, resolve, relative } from "node:path";
17
52
  import matter from "gray-matter";
18
53
  import { satisfies, validRange } from "semver";
19
- var versionExists = async (catalogDir, id, version) => {
54
+ var versionExists = async (catalogDir, id, version2) => {
20
55
  const files = await getFiles(`${catalogDir}/**/index.{md,mdx}`);
21
- const matchedFiles = await searchFilesForId(files, id, version) || [];
56
+ const matchedFiles = await searchFilesForId(files, id, version2) || [];
22
57
  return matchedFiles.length > 0;
23
58
  };
24
- var findFileById = async (catalogDir, id, version) => {
59
+ var findFileById = async (catalogDir, id, version2) => {
25
60
  const files = await getFiles(`${catalogDir}/**/index.{md,mdx}`);
26
61
  const matchedFiles = await searchFilesForId(files, id) || [];
27
- const latestVersion = matchedFiles.find((path6) => !path6.includes("versioned"));
28
- if (!version) {
62
+ const latestVersion = matchedFiles.find((path7) => !path7.includes("versioned"));
63
+ if (!version2) {
29
64
  return latestVersion;
30
65
  }
31
- const parsedFiles = matchedFiles.map((path6) => {
32
- const { data } = matter.read(path6);
33
- return { ...data, path: path6 };
66
+ const parsedFiles = matchedFiles.map((path7) => {
67
+ const { data } = matter.read(path7);
68
+ return { ...data, path: path7 };
34
69
  });
35
- if (version === "latest") {
70
+ if (version2 === "latest") {
36
71
  return latestVersion;
37
72
  }
38
- const exactMatch = parsedFiles.find((c) => c.version === version);
73
+ const exactMatch = parsedFiles.find((c) => c.version === version2);
39
74
  if (exactMatch) {
40
75
  return exactMatch.path;
41
76
  }
42
- const semverRange = validRange(version);
77
+ const semverRange = validRange(version2);
43
78
  if (semverRange) {
44
79
  const match = parsedFiles.filter((c) => {
45
80
  try {
@@ -78,19 +113,19 @@ var getFiles = async (pattern, ignore = "") => {
78
113
  );
79
114
  }
80
115
  };
81
- var readMdxFile = async (path6) => {
82
- const { data } = matter.read(path6);
116
+ var readMdxFile = async (path7) => {
117
+ const { data } = matter.read(path7);
83
118
  const { markdown, ...frontmatter } = data;
84
119
  return { ...frontmatter, markdown };
85
120
  };
86
- var searchFilesForId = async (files, id, version) => {
121
+ var searchFilesForId = async (files, id, version2) => {
87
122
  const escapedId = id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
88
123
  const idRegex = new RegExp(`^id:\\s*(['"]|>-)?\\s*${escapedId}['"]?\\s*$`, "m");
89
- const versionRegex = new RegExp(`^version:\\s*['"]?${version}['"]?\\s*$`, "m");
124
+ const versionRegex = new RegExp(`^version:\\s*['"]?${version2}['"]?\\s*$`, "m");
90
125
  const matches = files.map((file) => {
91
126
  const content = fsSync.readFileSync(file, "utf-8");
92
127
  const hasIdMatch = content.match(idRegex);
93
- if (version && !content.match(versionRegex)) {
128
+ if (version2 && !content.match(versionRegex)) {
94
129
  return void 0;
95
130
  }
96
131
  if (hasIdMatch) {
@@ -132,7 +167,7 @@ import fsSync2 from "node:fs";
132
167
  import { satisfies as satisfies2 } from "semver";
133
168
  import { lock, unlock } from "proper-lockfile";
134
169
  import { basename as basename2 } from "node:path";
135
- import path from "node:path";
170
+ import path2 from "node:path";
136
171
  var versionResource = async (catalogDir, id) => {
137
172
  const files = await getFiles(`${catalogDir}/**/index.{md,mdx}`);
138
173
  const matchedFiles = await searchFilesForId(files, id);
@@ -140,9 +175,9 @@ var versionResource = async (catalogDir, id) => {
140
175
  throw new Error(`No resource found with id: ${id}`);
141
176
  }
142
177
  const file = matchedFiles[0];
143
- const sourceDirectory = dirname2(file).replace(/[/\\]versioned[/\\][^/\\]+[/\\]/, path.sep);
144
- const { data: { version = "0.0.1" } = {} } = matter2.read(file);
145
- const targetDirectory = getVersionedDirectory(sourceDirectory, version);
178
+ const sourceDirectory = dirname2(file).replace(/[/\\]versioned[/\\][^/\\]+[/\\]/, path2.sep);
179
+ const { data: { version: version2 = "0.0.1" } = {} } = matter2.read(file);
180
+ const targetDirectory = getVersionedDirectory(sourceDirectory, version2);
146
181
  fsSync2.mkdirSync(targetDirectory, { recursive: true });
147
182
  const ignoreListToCopy = ["events", "commands", "queries", "versioned"];
148
183
  await copyDir(catalogDir, sourceDirectory, targetDirectory, (src) => {
@@ -172,8 +207,8 @@ var writeResource = async (catalogDir, resource, options = {
172
207
  versionExistingContent: false,
173
208
  format: "mdx"
174
209
  }) => {
175
- const path6 = options.path || `/${resource.id}`;
176
- const fullPath = join2(catalogDir, path6);
210
+ const path7 = options.path || `/${resource.id}`;
211
+ const fullPath = join2(catalogDir, path7);
177
212
  const format = options.format || "mdx";
178
213
  fsSync2.mkdirSync(fullPath, { recursive: true });
179
214
  const lockPath = join2(fullPath, `index.${format}`);
@@ -208,9 +243,9 @@ var writeResource = async (catalogDir, resource, options = {
208
243
  });
209
244
  }
210
245
  };
211
- var getResource = async (catalogDir, id, version, options, filePath) => {
246
+ var getResource = async (catalogDir, id, version2, options, filePath) => {
212
247
  const attachSchema = options?.attachSchema || false;
213
- const file = filePath || (id ? await findFileById(catalogDir, id, version) : void 0);
248
+ const file = filePath || (id ? await findFileById(catalogDir, id, version2) : void 0);
214
249
  if (!file || !fsSync2.existsSync(file)) return;
215
250
  const { data, content } = matter2.read(file);
216
251
  if (attachSchema && data?.schemaPath) {
@@ -230,8 +265,8 @@ var getResource = async (catalogDir, id, version, options, filePath) => {
230
265
  markdown: content.trim()
231
266
  };
232
267
  };
233
- var getResourcePath = async (catalogDir, id, version) => {
234
- const file = await findFileById(catalogDir, id, version);
268
+ var getResourcePath = async (catalogDir, id, version2) => {
269
+ const file = await findFileById(catalogDir, id, version2);
235
270
  if (!file) return;
236
271
  return {
237
272
  fullPath: file,
@@ -239,10 +274,10 @@ var getResourcePath = async (catalogDir, id, version) => {
239
274
  directory: dirname2(file.replace(catalogDir, ""))
240
275
  };
241
276
  };
242
- var getResourceFolderName = async (catalogDir, id, version) => {
243
- const paths = await getResourcePath(catalogDir, id, version);
277
+ var getResourceFolderName = async (catalogDir, id, version2) => {
278
+ const paths = await getResourcePath(catalogDir, id, version2);
244
279
  if (!paths) return;
245
- return paths?.directory.split(path.sep).filter(Boolean).pop();
280
+ return paths?.directory.split(path2.sep).filter(Boolean).pop();
246
281
  };
247
282
  var toResource = async (catalogDir, rawContents) => {
248
283
  const { data, content } = matter2(rawContents);
@@ -282,9 +317,9 @@ var getResources = async (catalogDir, {
282
317
  };
283
318
  });
284
319
  };
285
- var rmResourceById = async (catalogDir, id, version, options) => {
320
+ var rmResourceById = async (catalogDir, id, version2, options) => {
286
321
  const files = await getFiles(`${catalogDir}/**/index.{md,mdx}`);
287
- const matchedFiles = await searchFilesForId(files, id, version);
322
+ const matchedFiles = await searchFilesForId(files, id, version2);
288
323
  if (matchedFiles.length === 0) {
289
324
  throw new Error(`No ${options?.type || "resource"} found with id: ${id}`);
290
325
  }
@@ -305,26 +340,26 @@ var rmResourceById = async (catalogDir, id, version, options) => {
305
340
  );
306
341
  }
307
342
  };
308
- var waitForFileRemoval = async (path6, maxRetries = 50, delay = 10) => {
343
+ var waitForFileRemoval = async (path7, maxRetries = 50, delay = 10) => {
309
344
  for (let i = 0; i < maxRetries; i++) {
310
345
  try {
311
- await fs.access(path6);
312
- await new Promise((resolve2) => setTimeout(resolve2, delay));
346
+ await fs.access(path7);
347
+ await new Promise((resolve3) => setTimeout(resolve3, delay));
313
348
  } catch (error) {
314
349
  return;
315
350
  }
316
351
  }
317
- throw new Error(`File/directory ${path6} was not removed after ${maxRetries} attempts`);
352
+ throw new Error(`File/directory ${path7} was not removed after ${maxRetries} attempts`);
318
353
  };
319
- var addFileToResource = async (catalogDir, id, file, version, options) => {
354
+ var addFileToResource = async (catalogDir, id, file, version2, options) => {
320
355
  let pathToResource;
321
356
  if (options?.path) {
322
357
  pathToResource = join2(catalogDir, options.path, "index.mdx");
323
358
  } else {
324
- pathToResource = await findFileById(catalogDir, id, version);
359
+ pathToResource = await findFileById(catalogDir, id, version2);
325
360
  }
326
361
  if (!pathToResource) throw new Error("Cannot find directory to write file to");
327
- fsSync2.mkdirSync(path.dirname(pathToResource), { recursive: true });
362
+ fsSync2.mkdirSync(path2.dirname(pathToResource), { recursive: true });
328
363
  let fileContent = file.content.trim();
329
364
  try {
330
365
  const json = JSON.parse(fileContent);
@@ -333,25 +368,25 @@ var addFileToResource = async (catalogDir, id, file, version, options) => {
333
368
  }
334
369
  fsSync2.writeFileSync(join2(dirname2(pathToResource), file.fileName), fileContent);
335
370
  };
336
- var getFileFromResource = async (catalogDir, id, file, version) => {
337
- const pathToResource = await findFileById(catalogDir, id, version);
371
+ var getFileFromResource = async (catalogDir, id, file, version2) => {
372
+ const pathToResource = await findFileById(catalogDir, id, version2);
338
373
  if (!pathToResource) throw new Error("Cannot find directory of resource");
339
374
  const exists = await fs.access(join2(dirname2(pathToResource), file.fileName)).then(() => true).catch(() => false);
340
- if (!exists) throw new Error(`File ${file.fileName} does not exist in resource ${id} v(${version})`);
375
+ if (!exists) throw new Error(`File ${file.fileName} does not exist in resource ${id} v(${version2})`);
341
376
  return fsSync2.readFileSync(join2(dirname2(pathToResource), file.fileName), "utf-8");
342
377
  };
343
- var getVersionedDirectory = (sourceDirectory, version) => {
344
- return join2(sourceDirectory, "versioned", version);
378
+ var getVersionedDirectory = (sourceDirectory, version2) => {
379
+ return join2(sourceDirectory, "versioned", version2);
345
380
  };
346
- var isLatestVersion = async (catalogDir, id, version) => {
347
- const resource = await getResource(catalogDir, id, version);
381
+ var isLatestVersion = async (catalogDir, id, version2) => {
382
+ const resource = await getResource(catalogDir, id, version2);
348
383
  if (!resource) return false;
349
- const pathToResource = await getResourcePath(catalogDir, id, version);
384
+ const pathToResource = await getResourcePath(catalogDir, id, version2);
350
385
  return !pathToResource?.relativePath.replace(/\\/g, "/").includes("/versioned/");
351
386
  };
352
387
 
353
388
  // src/events.ts
354
- var getEvent = (directory) => async (id, version, options) => getResource(directory, id, version, { type: "event", ...options });
389
+ var getEvent = (directory) => async (id, version2, options) => getResource(directory, id, version2, { type: "event", ...options });
355
390
  var getEvents = (directory) => async (options) => getResources(directory, { type: "events", ...options });
356
391
  var writeEvent = (directory) => async (event, options = {
357
392
  path: "",
@@ -367,26 +402,26 @@ var writeEventToService = (directory) => async (event, service, options = { path
367
402
  pathForEvent = join3(pathForEvent, event.id);
368
403
  await writeResource(directory, { ...event }, { ...options, path: pathForEvent, type: "event" });
369
404
  };
370
- var rmEvent = (directory) => async (path6) => {
371
- await fs2.rm(join3(directory, path6), { recursive: true });
405
+ var rmEvent = (directory) => async (path7) => {
406
+ await fs2.rm(join3(directory, path7), { recursive: true });
372
407
  };
373
- var rmEventById = (directory) => async (id, version, persistFiles) => {
374
- await rmResourceById(directory, id, version, { type: "event", persistFiles });
408
+ var rmEventById = (directory) => async (id, version2, persistFiles) => {
409
+ await rmResourceById(directory, id, version2, { type: "event", persistFiles });
375
410
  };
376
411
  var versionEvent = (directory) => async (id) => versionResource(directory, id);
377
- var addFileToEvent = (directory) => async (id, file, version, options) => addFileToResource(directory, id, file, version, options);
378
- var addSchemaToEvent = (directory) => async (id, schema, version, options) => {
379
- await addFileToEvent(directory)(id, { content: schema.schema, fileName: schema.fileName }, version, options);
412
+ var addFileToEvent = (directory) => async (id, file, version2, options) => addFileToResource(directory, id, file, version2, options);
413
+ var addSchemaToEvent = (directory) => async (id, schema, version2, options) => {
414
+ await addFileToEvent(directory)(id, { content: schema.schema, fileName: schema.fileName }, version2, options);
380
415
  };
381
- var eventHasVersion = (directory) => async (id, version) => {
382
- const file = await findFileById(directory, id, version);
416
+ var eventHasVersion = (directory) => async (id, version2) => {
417
+ const file = await findFileById(directory, id, version2);
383
418
  return !!file;
384
419
  };
385
420
 
386
421
  // src/commands.ts
387
422
  import fs3 from "node:fs/promises";
388
423
  import { join as join4 } from "node:path";
389
- var getCommand = (directory) => async (id, version, options) => getResource(directory, id, version, { type: "command", ...options });
424
+ var getCommand = (directory) => async (id, version2, options) => getResource(directory, id, version2, { type: "command", ...options });
390
425
  var getCommands = (directory) => async (options) => getResources(directory, { type: "commands", ...options });
391
426
  var writeCommand = (directory) => async (command, options = {
392
427
  path: "",
@@ -403,24 +438,24 @@ var writeCommandToService = (directory) => async (command, service, options = {
403
438
  pathForCommand = join4(pathForCommand, command.id);
404
439
  await writeResource(directory, { ...command }, { ...options, path: pathForCommand, type: "command" });
405
440
  };
406
- var rmCommand = (directory) => async (path6) => {
407
- await fs3.rm(join4(directory, path6), { recursive: true });
441
+ var rmCommand = (directory) => async (path7) => {
442
+ await fs3.rm(join4(directory, path7), { recursive: true });
408
443
  };
409
- var rmCommandById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "command", persistFiles });
444
+ var rmCommandById = (directory) => async (id, version2, persistFiles) => rmResourceById(directory, id, version2, { type: "command", persistFiles });
410
445
  var versionCommand = (directory) => async (id) => versionResource(directory, id);
411
- var addFileToCommand = (directory) => async (id, file, version, options) => addFileToResource(directory, id, file, version, options);
412
- var addSchemaToCommand = (directory) => async (id, schema, version, options) => {
413
- await addFileToCommand(directory)(id, { content: schema.schema, fileName: schema.fileName }, version, options);
446
+ var addFileToCommand = (directory) => async (id, file, version2, options) => addFileToResource(directory, id, file, version2, options);
447
+ var addSchemaToCommand = (directory) => async (id, schema, version2, options) => {
448
+ await addFileToCommand(directory)(id, { content: schema.schema, fileName: schema.fileName }, version2, options);
414
449
  };
415
- var commandHasVersion = (directory) => async (id, version) => {
416
- const file = await findFileById(directory, id, version);
450
+ var commandHasVersion = (directory) => async (id, version2) => {
451
+ const file = await findFileById(directory, id, version2);
417
452
  return !!file;
418
453
  };
419
454
 
420
455
  // src/queries.ts
421
456
  import fs4 from "node:fs/promises";
422
457
  import { join as join5 } from "node:path";
423
- var getQuery = (directory) => async (id, version, options) => getResource(directory, id, version, { type: "query", ...options });
458
+ var getQuery = (directory) => async (id, version2, options) => getResource(directory, id, version2, { type: "query", ...options });
424
459
  var writeQuery = (directory) => async (query, options = {
425
460
  path: "",
426
461
  override: false,
@@ -437,28 +472,28 @@ var writeQueryToService = (directory) => async (query, service, options = { path
437
472
  pathForQuery = join5(pathForQuery, query.id);
438
473
  await writeResource(directory, { ...query }, { ...options, path: pathForQuery, type: "query" });
439
474
  };
440
- var rmQuery = (directory) => async (path6) => {
441
- await fs4.rm(join5(directory, path6), { recursive: true });
475
+ var rmQuery = (directory) => async (path7) => {
476
+ await fs4.rm(join5(directory, path7), { recursive: true });
442
477
  };
443
- var rmQueryById = (directory) => async (id, version, persistFiles) => {
444
- await rmResourceById(directory, id, version, { type: "query", persistFiles });
478
+ var rmQueryById = (directory) => async (id, version2, persistFiles) => {
479
+ await rmResourceById(directory, id, version2, { type: "query", persistFiles });
445
480
  };
446
481
  var versionQuery = (directory) => async (id) => versionResource(directory, id);
447
- var addFileToQuery = (directory) => async (id, file, version, options) => addFileToResource(directory, id, file, version, options);
448
- var addSchemaToQuery = (directory) => async (id, schema, version, options) => {
449
- await addFileToQuery(directory)(id, { content: schema.schema, fileName: schema.fileName }, version, options);
482
+ var addFileToQuery = (directory) => async (id, file, version2, options) => addFileToResource(directory, id, file, version2, options);
483
+ var addSchemaToQuery = (directory) => async (id, schema, version2, options) => {
484
+ await addFileToQuery(directory)(id, { content: schema.schema, fileName: schema.fileName }, version2, options);
450
485
  };
451
- var queryHasVersion = (directory) => async (id, version) => {
452
- const file = await findFileById(directory, id, version);
486
+ var queryHasVersion = (directory) => async (id, version2) => {
487
+ const file = await findFileById(directory, id, version2);
453
488
  return !!file;
454
489
  };
455
490
 
456
491
  // src/services.ts
457
492
  import fs5 from "node:fs/promises";
458
493
  import { join as join6, dirname as dirname4, extname, relative as relative2 } from "node:path";
459
- var getService = (directory) => async (id, version) => getResource(directory, id, version, { type: "service" });
460
- var getServiceByPath = (directory) => async (path6) => {
461
- const service = await getResource(directory, void 0, void 0, { type: "service" }, path6);
494
+ var getService = (directory) => async (id, version2) => getResource(directory, id, version2, { type: "service" });
495
+ var getServiceByPath = (directory) => async (path7) => {
496
+ const service = await getResource(directory, void 0, void 0, { type: "service" }, path7);
462
497
  return service;
463
498
  };
464
499
  var getServices = (directory) => async (options) => getResources(directory, {
@@ -482,8 +517,8 @@ var writeService = (directory) => async (service, options = {
482
517
  };
483
518
  var writeVersionedService = (directory) => async (service) => {
484
519
  const resource = { ...service };
485
- const path6 = getVersionedDirectory(service.id, service.version);
486
- return await writeService(directory)(resource, { path: path6 });
520
+ const path7 = getVersionedDirectory(service.id, service.version);
521
+ return await writeService(directory)(resource, { path: path7 });
487
522
  };
488
523
  var writeServiceToDomain = (directory) => async (service, domain, options = { path: "", format: "mdx", override: false }) => {
489
524
  let pathForService = domain.version && domain.version !== "latest" ? `/${domain.id}/versioned/${domain.version}/services` : `/${domain.id}/services`;
@@ -491,16 +526,16 @@ var writeServiceToDomain = (directory) => async (service, domain, options = { pa
491
526
  await writeResource(directory, { ...service }, { ...options, path: pathForService, type: "service" });
492
527
  };
493
528
  var versionService = (directory) => async (id) => versionResource(directory, id);
494
- var rmService = (directory) => async (path6) => {
495
- await fs5.rm(join6(directory, path6), { recursive: true });
529
+ var rmService = (directory) => async (path7) => {
530
+ await fs5.rm(join6(directory, path7), { recursive: true });
496
531
  };
497
- var rmServiceById = (directory) => async (id, version, persistFiles) => {
498
- await rmResourceById(directory, id, version, { type: "service", persistFiles });
532
+ var rmServiceById = (directory) => async (id, version2, persistFiles) => {
533
+ await rmResourceById(directory, id, version2, { type: "service", persistFiles });
499
534
  };
500
- var addFileToService = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
501
- var getSpecificationFilesForService = (directory) => async (id, version) => {
502
- let service = await getService(directory)(id, version);
503
- const filePathToService = await findFileById(directory, id, version);
535
+ var addFileToService = (directory) => async (id, file, version2) => addFileToResource(directory, id, file, version2);
536
+ var getSpecificationFilesForService = (directory) => async (id, version2) => {
537
+ let service = await getService(directory)(id, version2);
538
+ const filePathToService = await findFileById(directory, id, version2);
504
539
  if (!filePathToService) throw new Error("Cannot find directory of service");
505
540
  let specs = [];
506
541
  if (service.specifications) {
@@ -518,16 +553,16 @@ var getSpecificationFilesForService = (directory) => async (id, version) => {
518
553
  if (!fileName) {
519
554
  throw new Error(`Specification file name for ${fileName} is undefined`);
520
555
  }
521
- const rawFile = await getFileFromResource(directory, id, { fileName }, version);
556
+ const rawFile = await getFileFromResource(directory, id, { fileName }, version2);
522
557
  return { key, content: rawFile, fileName, path: join6(dirname4(filePathToService), fileName) };
523
558
  });
524
559
  specs = await Promise.all(getSpecs);
525
560
  }
526
561
  return specs;
527
562
  };
528
- var addMessageToService = (directory) => async (id, direction, event, version) => {
529
- let service = await getService(directory)(id, version);
530
- const servicePath = await getResourcePath(directory, id, version);
563
+ var addMessageToService = (directory) => async (id, direction, event, version2) => {
564
+ let service = await getService(directory)(id, version2);
565
+ const servicePath = await getResourcePath(directory, id, version2);
531
566
  const extension = extname(servicePath?.fullPath || "");
532
567
  if (direction === "sends") {
533
568
  if (service.sends === void 0) {
@@ -552,29 +587,29 @@ var addMessageToService = (directory) => async (id, direction, event, version) =
552
587
  } else {
553
588
  throw new Error(`Direction ${direction} is invalid, only 'receives' and 'sends' are supported`);
554
589
  }
555
- const existingResource = await findFileById(directory, id, version);
590
+ const existingResource = await findFileById(directory, id, version2);
556
591
  if (!existingResource) {
557
592
  throw new Error(`Cannot find service ${id} in the catalog`);
558
593
  }
559
- const path6 = existingResource.split(/[\\/]+services/)[0];
560
- const pathToResource = join6(path6, "services");
561
- await rmServiceById(directory)(id, version);
594
+ const path7 = existingResource.split(/[\\/]+services/)[0];
595
+ const pathToResource = join6(path7, "services");
596
+ await rmServiceById(directory)(id, version2);
562
597
  await writeService(pathToResource)(service, { format: extension === ".md" ? "md" : "mdx" });
563
598
  };
564
- var serviceHasVersion = (directory) => async (id, version) => {
565
- const file = await findFileById(directory, id, version);
599
+ var serviceHasVersion = (directory) => async (id, version2) => {
600
+ const file = await findFileById(directory, id, version2);
566
601
  return !!file;
567
602
  };
568
- var isService = (directory) => async (path6) => {
569
- const service = await getServiceByPath(directory)(path6);
570
- const relativePath = relative2(directory, path6);
603
+ var isService = (directory) => async (path7) => {
604
+ const service = await getServiceByPath(directory)(path7);
605
+ const relativePath = relative2(directory, path7);
571
606
  const segments = relativePath.split(/[/\\]+/);
572
607
  return !!service && segments.includes("services");
573
608
  };
574
609
  var toService = (directory) => async (file) => toResource(directory, file);
575
- var addEntityToService = (directory) => async (id, entity, version) => {
576
- let service = await getService(directory)(id, version);
577
- const servicePath = await getResourcePath(directory, id, version);
610
+ var addEntityToService = (directory) => async (id, entity, version2) => {
611
+ let service = await getService(directory)(id, version2);
612
+ const servicePath = await getResourcePath(directory, id, version2);
578
613
  const extension = extname(servicePath?.fullPath || "");
579
614
  if (service.entities === void 0) {
580
615
  service.entities = [];
@@ -585,18 +620,18 @@ var addEntityToService = (directory) => async (id, entity, version) => {
585
620
  }
586
621
  }
587
622
  service.entities.push({ id: entity.id, version: entity.version });
588
- const existingResource = await findFileById(directory, id, version);
623
+ const existingResource = await findFileById(directory, id, version2);
589
624
  if (!existingResource) {
590
625
  throw new Error(`Cannot find service ${id} in the catalog`);
591
626
  }
592
- const path6 = existingResource.split(/[\\/]+services/)[0];
593
- const pathToResource = join6(path6, "services");
594
- await rmServiceById(directory)(id, version);
627
+ const path7 = existingResource.split(/[\\/]+services/)[0];
628
+ const pathToResource = join6(path7, "services");
629
+ await rmServiceById(directory)(id, version2);
595
630
  await writeService(pathToResource)(service, { format: extension === ".md" ? "md" : "mdx" });
596
631
  };
597
- var addDataStoreToService = (directory) => async (id, operation, dataStore, version) => {
598
- let service = await getService(directory)(id, version);
599
- const servicePath = await getResourcePath(directory, id, version);
632
+ var addDataStoreToService = (directory) => async (id, operation, dataStore, version2) => {
633
+ let service = await getService(directory)(id, version2);
634
+ const servicePath = await getResourcePath(directory, id, version2);
600
635
  const extension = extname(servicePath?.fullPath || "");
601
636
  if (operation === "writesTo") {
602
637
  if (service.writesTo === void 0) {
@@ -621,22 +656,22 @@ var addDataStoreToService = (directory) => async (id, operation, dataStore, vers
621
656
  } else {
622
657
  throw new Error(`Operation ${operation} is invalid, only 'writesTo' and 'readsFrom' are supported`);
623
658
  }
624
- const existingResource = await findFileById(directory, id, version);
659
+ const existingResource = await findFileById(directory, id, version2);
625
660
  if (!existingResource) {
626
661
  throw new Error(`Cannot find service ${id} in the catalog`);
627
662
  }
628
- const path6 = existingResource.split(/[\\/]+services/)[0];
629
- const pathToResource = join6(path6, "services");
630
- await rmServiceById(directory)(id, version);
663
+ const path7 = existingResource.split(/[\\/]+services/)[0];
664
+ const pathToResource = join6(path7, "services");
665
+ await rmServiceById(directory)(id, version2);
631
666
  await writeService(pathToResource)(service, { format: extension === ".md" ? "md" : "mdx" });
632
667
  };
633
668
 
634
669
  // src/domains.ts
635
670
  import fs6 from "node:fs/promises";
636
- import path2, { join as join7 } from "node:path";
671
+ import path3, { join as join7 } from "node:path";
637
672
  import fsSync3 from "node:fs";
638
673
  import matter3 from "gray-matter";
639
- var getDomain = (directory) => async (id, version) => getResource(directory, id, version, { type: "domain" });
674
+ var getDomain = (directory) => async (id, version2) => getResource(directory, id, version2, { type: "domain" });
640
675
  var getDomains = (directory) => async (options) => getResources(directory, {
641
676
  type: "domains",
642
677
  ignore: ["**/services/**", "**/events/**", "**/commands/**", "**/queries/**", "**/flows/**", "**/entities/**"],
@@ -667,20 +702,20 @@ var writeDomain = (directory) => async (domain, options = {
667
702
  return await writeResource(directory, resource, { ...options, type: "domain" });
668
703
  };
669
704
  var versionDomain = (directory) => async (id) => versionResource(directory, id);
670
- var rmDomain = (directory) => async (path6) => {
671
- await fs6.rm(join7(directory, path6), { recursive: true });
705
+ var rmDomain = (directory) => async (path7) => {
706
+ await fs6.rm(join7(directory, path7), { recursive: true });
672
707
  };
673
- var rmDomainById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "domain", persistFiles });
674
- var addFileToDomain = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
675
- var addUbiquitousLanguageToDomain = (directory) => async (id, ubiquitousLanguageDictionary, version) => {
708
+ var rmDomainById = (directory) => async (id, version2, persistFiles) => rmResourceById(directory, id, version2, { type: "domain", persistFiles });
709
+ var addFileToDomain = (directory) => async (id, file, version2) => addFileToResource(directory, id, file, version2);
710
+ var addUbiquitousLanguageToDomain = (directory) => async (id, ubiquitousLanguageDictionary, version2) => {
676
711
  const content = matter3.stringify("", {
677
712
  ...ubiquitousLanguageDictionary
678
713
  });
679
- await addFileToResource(directory, id, { content, fileName: "ubiquitous-language.mdx" }, version);
714
+ await addFileToResource(directory, id, { content, fileName: "ubiquitous-language.mdx" }, version2);
680
715
  };
681
- var getUbiquitousLanguageFromDomain = (directory) => async (id, version) => {
682
- const pathToDomain = await findFileById(directory, id, version) || "";
683
- const pathToUbiquitousLanguage = path2.join(path2.dirname(pathToDomain), "ubiquitous-language.mdx");
716
+ var getUbiquitousLanguageFromDomain = (directory) => async (id, version2) => {
717
+ const pathToDomain = await findFileById(directory, id, version2) || "";
718
+ const pathToUbiquitousLanguage = path3.join(path3.dirname(pathToDomain), "ubiquitous-language.mdx");
684
719
  const fileExists = fsSync3.existsSync(pathToUbiquitousLanguage);
685
720
  if (!fileExists) {
686
721
  return void 0;
@@ -688,14 +723,14 @@ var getUbiquitousLanguageFromDomain = (directory) => async (id, version) => {
688
723
  const content = await readMdxFile(pathToUbiquitousLanguage);
689
724
  return content;
690
725
  };
691
- var domainHasVersion = (directory) => async (id, version) => {
692
- const file = await findFileById(directory, id, version);
726
+ var domainHasVersion = (directory) => async (id, version2) => {
727
+ const file = await findFileById(directory, id, version2);
693
728
  return !!file;
694
729
  };
695
- var addServiceToDomain = (directory) => async (id, service, version) => {
696
- let domain = await getDomain(directory)(id, version);
697
- const domainPath = await getResourcePath(directory, id, version);
698
- const extension = path2.extname(domainPath?.fullPath || "");
730
+ var addServiceToDomain = (directory) => async (id, service, version2) => {
731
+ let domain = await getDomain(directory)(id, version2);
732
+ const domainPath = await getResourcePath(directory, id, version2);
733
+ const extension = path3.extname(domainPath?.fullPath || "");
699
734
  if (domain.services === void 0) {
700
735
  domain.services = [];
701
736
  }
@@ -704,13 +739,13 @@ var addServiceToDomain = (directory) => async (id, service, version) => {
704
739
  return;
705
740
  }
706
741
  domain.services.push(service);
707
- await rmDomainById(directory)(id, version, true);
742
+ await rmDomainById(directory)(id, version2, true);
708
743
  await writeDomain(directory)(domain, { format: extension === ".md" ? "md" : "mdx" });
709
744
  };
710
- var addSubDomainToDomain = (directory) => async (id, subDomain, version) => {
711
- let domain = await getDomain(directory)(id, version);
712
- const domainPath = await getResourcePath(directory, id, version);
713
- const extension = path2.extname(domainPath?.fullPath || "");
745
+ var addSubDomainToDomain = (directory) => async (id, subDomain, version2) => {
746
+ let domain = await getDomain(directory)(id, version2);
747
+ const domainPath = await getResourcePath(directory, id, version2);
748
+ const extension = path3.extname(domainPath?.fullPath || "");
714
749
  if (domain.domains === void 0) {
715
750
  domain.domains = [];
716
751
  }
@@ -719,13 +754,13 @@ var addSubDomainToDomain = (directory) => async (id, subDomain, version) => {
719
754
  return;
720
755
  }
721
756
  domain.domains.push(subDomain);
722
- await rmDomainById(directory)(id, version, true);
757
+ await rmDomainById(directory)(id, version2, true);
723
758
  await writeDomain(directory)(domain, { format: extension === ".md" ? "md" : "mdx" });
724
759
  };
725
- var addEntityToDomain = (directory) => async (id, entity, version) => {
726
- let domain = await getDomain(directory)(id, version);
727
- const domainPath = await getResourcePath(directory, id, version);
728
- const extension = path2.extname(domainPath?.fullPath || "");
760
+ var addEntityToDomain = (directory) => async (id, entity, version2) => {
761
+ let domain = await getDomain(directory)(id, version2);
762
+ const domainPath = await getResourcePath(directory, id, version2);
763
+ const extension = path3.extname(domainPath?.fullPath || "");
729
764
  if (domain.entities === void 0) {
730
765
  domain.entities = [];
731
766
  }
@@ -734,13 +769,13 @@ var addEntityToDomain = (directory) => async (id, entity, version) => {
734
769
  return;
735
770
  }
736
771
  domain.entities.push(entity);
737
- await rmDomainById(directory)(id, version, true);
772
+ await rmDomainById(directory)(id, version2, true);
738
773
  await writeDomain(directory)(domain, { format: extension === ".md" ? "md" : "mdx" });
739
774
  };
740
- var addDataProductToDomain = (directory) => async (id, dataProduct, version) => {
741
- let domain = await getDomain(directory)(id, version);
742
- const domainPath = await getResourcePath(directory, id, version);
743
- const extension = path2.extname(domainPath?.fullPath || "");
775
+ var addDataProductToDomain = (directory) => async (id, dataProduct, version2) => {
776
+ let domain = await getDomain(directory)(id, version2);
777
+ const domainPath = await getResourcePath(directory, id, version2);
778
+ const extension = path3.extname(domainPath?.fullPath || "");
744
779
  if (domain.dataProducts === void 0) {
745
780
  domain.dataProducts = [];
746
781
  }
@@ -751,13 +786,13 @@ var addDataProductToDomain = (directory) => async (id, dataProduct, version) =>
751
786
  return;
752
787
  }
753
788
  domain.dataProducts.push(dataProduct);
754
- await rmDomainById(directory)(id, version, true);
789
+ await rmDomainById(directory)(id, version2, true);
755
790
  await writeDomain(directory)(domain, { format: extension === ".md" ? "md" : "mdx" });
756
791
  };
757
- var addMessageToDomain = (directory) => async (id, direction, message, version) => {
758
- let domain = await getDomain(directory)(id, version);
759
- const domainPath = await getResourcePath(directory, id, version);
760
- const extension = path2.extname(domainPath?.fullPath || "");
792
+ var addMessageToDomain = (directory) => async (id, direction, message, version2) => {
793
+ let domain = await getDomain(directory)(id, version2);
794
+ const domainPath = await getResourcePath(directory, id, version2);
795
+ const extension = path3.extname(domainPath?.fullPath || "");
761
796
  if (direction === "sends") {
762
797
  if (domain.sends === void 0) {
763
798
  domain.sends = [];
@@ -781,34 +816,34 @@ var addMessageToDomain = (directory) => async (id, direction, message, version)
781
816
  } else {
782
817
  throw new Error(`Direction ${direction} is invalid, only 'receives' and 'sends' are supported`);
783
818
  }
784
- const existingResource = await findFileById(directory, id, version);
819
+ const existingResource = await findFileById(directory, id, version2);
785
820
  if (!existingResource) {
786
821
  throw new Error(`Cannot find domain ${id} in the catalog`);
787
822
  }
788
823
  const normalizedPath = existingResource.replace(/\\/g, "/");
789
824
  const lastDomainsIndex = normalizedPath.lastIndexOf("/domains/");
790
825
  const pathToResource = existingResource.substring(0, lastDomainsIndex + "/domains".length);
791
- await rmDomainById(directory)(id, version, true);
826
+ await rmDomainById(directory)(id, version2, true);
792
827
  await writeDomain(pathToResource)(domain, { format: extension === ".md" ? "md" : "mdx" });
793
828
  };
794
829
 
795
830
  // src/channels.ts
796
831
  import fs7 from "node:fs/promises";
797
832
  import { join as join8, extname as extname2 } from "node:path";
798
- var getChannel = (directory) => async (id, version) => getResource(directory, id, version, { type: "channel" });
833
+ var getChannel = (directory) => async (id, version2) => getResource(directory, id, version2, { type: "channel" });
799
834
  var getChannels = (directory) => async (options) => getResources(directory, { type: "channels", ...options });
800
835
  var writeChannel = (directory) => async (channel, options = { path: "" }) => writeResource(directory, { ...channel }, { ...options, type: "channel" });
801
- var rmChannel = (directory) => async (path6) => {
802
- await fs7.rm(join8(directory, path6), { recursive: true });
836
+ var rmChannel = (directory) => async (path7) => {
837
+ await fs7.rm(join8(directory, path7), { recursive: true });
803
838
  };
804
- var rmChannelById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "channel", persistFiles });
839
+ var rmChannelById = (directory) => async (id, version2, persistFiles) => rmResourceById(directory, id, version2, { type: "channel", persistFiles });
805
840
  var versionChannel = (directory) => async (id) => versionResource(directory, id);
806
- var channelHasVersion = (directory) => async (id, version) => {
807
- const file = await findFileById(directory, id, version);
841
+ var channelHasVersion = (directory) => async (id, version2) => {
842
+ const file = await findFileById(directory, id, version2);
808
843
  return !!file;
809
844
  };
810
- var addMessageToChannel = (directory, collection) => async (id, _message, version) => {
811
- let channel = await getChannel(directory)(id, version);
845
+ var addMessageToChannel = (directory, collection) => async (id, _message, version2) => {
846
+ let channel = await getChannel(directory)(id, version2);
812
847
  const functions = {
813
848
  events: {
814
849
  getMessage: getEvent,
@@ -840,8 +875,8 @@ var addMessageToChannel = (directory, collection) => async (id, _message, versio
840
875
  if (!existingResource) {
841
876
  throw new Error(`Cannot find message ${id} in the catalog`);
842
877
  }
843
- const path6 = existingResource.split(`/[\\/]+${collection}`)[0];
844
- const pathToResource = join8(path6, collection);
878
+ const path7 = existingResource.split(`/[\\/]+${collection}`)[0];
879
+ const pathToResource = join8(path7, collection);
845
880
  await rmMessageById(directory)(_message.id, _message.version, true);
846
881
  await writeMessage(pathToResource)(message, { format: extension === ".md" ? "md" : "mdx" });
847
882
  };
@@ -850,8 +885,8 @@ var addMessageToChannel = (directory, collection) => async (id, _message, versio
850
885
  import { dirname as dirname5 } from "node:path";
851
886
  import matter4 from "gray-matter";
852
887
  import { satisfies as satisfies3, validRange as validRange2 } from "semver";
853
- var getMessageBySchemaPath = (directory) => async (path6, options) => {
854
- const pathToMessage = dirname5(path6);
888
+ var getMessageBySchemaPath = (directory) => async (path7, options) => {
889
+ const pathToMessage = dirname5(path7);
855
890
  try {
856
891
  const files = await getFiles(`${directory}/${pathToMessage}/index.{md,mdx}`);
857
892
  if (!files || files.length === 0) {
@@ -859,13 +894,13 @@ var getMessageBySchemaPath = (directory) => async (path6, options) => {
859
894
  }
860
895
  const messageFile = files[0];
861
896
  const { data } = matter4.read(messageFile);
862
- const { id, version } = data;
863
- if (!id || !version) {
897
+ const { id, version: version2 } = data;
898
+ if (!id || !version2) {
864
899
  throw new Error(`Message definition file at ${messageFile} is missing 'id' or 'version' in its frontmatter.`);
865
900
  }
866
- const message = await getResource(directory, id, version, { type: "message", ...options });
901
+ const message = await getResource(directory, id, version2, { type: "message", ...options });
867
902
  if (!message) {
868
- throw new Error(`Message resource with id '${id}' and version '${version}' not found, as referenced in ${messageFile}.`);
903
+ throw new Error(`Message resource with id '${id}' and version '${version2}' not found, as referenced in ${messageFile}.`);
869
904
  }
870
905
  return message;
871
906
  } catch (error) {
@@ -876,12 +911,12 @@ var getMessageBySchemaPath = (directory) => async (path6, options) => {
876
911
  throw new Error(`Failed to retrieve message from ${pathToMessage} due to an unknown error.`);
877
912
  }
878
913
  };
879
- var getProducersAndConsumersForMessage = (directory) => async (id, version, options) => {
914
+ var getProducersAndConsumersForMessage = (directory) => async (id, version2, options) => {
880
915
  const services = await getServices(directory)({ latestOnly: options?.latestOnly ?? true });
881
- const message = await getResource(directory, id, version, { type: "message" });
882
- const isMessageLatestVersion = await isLatestVersion(directory, id, version);
916
+ const message = await getResource(directory, id, version2, { type: "message" });
917
+ const isMessageLatestVersion = await isLatestVersion(directory, id, version2);
883
918
  if (!message) {
884
- throw new Error(`Message resource with id '${id}' and version '${version}' not found.`);
919
+ throw new Error(`Message resource with id '${id}' and version '${version2}' not found.`);
885
920
  }
886
921
  const producers = [];
887
922
  const consumers = [];
@@ -923,18 +958,18 @@ var getProducersAndConsumersForMessage = (directory) => async (id, version, opti
923
958
  }
924
959
  return { producers, consumers };
925
960
  };
926
- var getConsumersOfSchema = (directory) => async (path6) => {
961
+ var getConsumersOfSchema = (directory) => async (path7) => {
927
962
  try {
928
- const message = await getMessageBySchemaPath(directory)(path6);
963
+ const message = await getMessageBySchemaPath(directory)(path7);
929
964
  const { consumers } = await getProducersAndConsumersForMessage(directory)(message.id, message.version);
930
965
  return consumers;
931
966
  } catch (error) {
932
967
  return [];
933
968
  }
934
969
  };
935
- var getProducersOfSchema = (directory) => async (path6) => {
970
+ var getProducersOfSchema = (directory) => async (path7) => {
936
971
  try {
937
- const message = await getMessageBySchemaPath(directory)(path6);
972
+ const message = await getMessageBySchemaPath(directory)(path7);
938
973
  const { producers } = await getProducersAndConsumersForMessage(directory)(message.id, message.version);
939
974
  return producers;
940
975
  } catch (error) {
@@ -943,13 +978,13 @@ var getProducersOfSchema = (directory) => async (path6) => {
943
978
  };
944
979
 
945
980
  // src/custom-docs.ts
946
- import path3, { join as join10 } from "node:path";
981
+ import path4, { join as join10 } from "node:path";
947
982
  import fsSync4 from "node:fs";
948
983
  import fs8 from "node:fs/promises";
949
984
  import matter5 from "gray-matter";
950
985
  import slugify from "slugify";
951
986
  var getCustomDoc = (directory) => async (filePath) => {
952
- const fullPath = path3.join(directory, filePath);
987
+ const fullPath = path4.join(directory, filePath);
953
988
  const fullPathWithExtension = fullPath.endsWith(".mdx") ? fullPath : `${fullPath}.mdx`;
954
989
  const fileExists = fsSync4.existsSync(fullPathWithExtension);
955
990
  if (!fileExists) {
@@ -968,8 +1003,8 @@ var writeCustomDoc = (directory) => async (customDoc, options = { path: "" }) =>
968
1003
  const { fileName, ...rest } = customDoc;
969
1004
  const name = fileName || slugify(customDoc.title, { lower: true });
970
1005
  const withExtension = name.endsWith(".mdx") ? name : `${name}.mdx`;
971
- const fullPath = path3.join(directory, options.path || "", withExtension);
972
- fsSync4.mkdirSync(path3.dirname(fullPath), { recursive: true });
1006
+ const fullPath = path4.join(directory, options.path || "", withExtension);
1007
+ fsSync4.mkdirSync(path4.dirname(fullPath), { recursive: true });
973
1008
  const document = matter5.stringify(customDoc.markdown.trim(), rest);
974
1009
  fsSync4.writeFileSync(fullPath, document);
975
1010
  };
@@ -983,7 +1018,7 @@ import fs9 from "node:fs/promises";
983
1018
  import fsSync6 from "node:fs";
984
1019
  import { join as join12 } from "node:path";
985
1020
  import matter7 from "gray-matter";
986
- import path4 from "node:path";
1021
+ import path5 from "node:path";
987
1022
 
988
1023
  // src/users.ts
989
1024
  import fsSync5 from "node:fs";
@@ -1073,17 +1108,17 @@ var writeTeam = (catalogDir) => async (team, options = {}) => {
1073
1108
  var rmTeamById = (catalogDir) => async (id) => {
1074
1109
  await fs9.rm(join12(catalogDir, `${id}.mdx`), { recursive: true });
1075
1110
  };
1076
- var getOwnersForResource = (catalogDir) => async (id, version) => {
1077
- const resource = await getResource(catalogDir, id, version);
1111
+ var getOwnersForResource = (catalogDir) => async (id, version2) => {
1112
+ const resource = await getResource(catalogDir, id, version2);
1078
1113
  let owners = [];
1079
1114
  if (!resource) return [];
1080
1115
  if (!resource.owners) return [];
1081
1116
  for (const owner of resource.owners) {
1082
- const team = await getTeam(path4.join(catalogDir, "teams"))(owner);
1117
+ const team = await getTeam(path5.join(catalogDir, "teams"))(owner);
1083
1118
  if (team) {
1084
1119
  owners.push(team);
1085
1120
  } else {
1086
- const user = await getUser(path4.join(catalogDir, "users"))(owner);
1121
+ const user = await getUser(path5.join(catalogDir, "users"))(owner);
1087
1122
  if (user) {
1088
1123
  owners.push(user);
1089
1124
  }
@@ -1092,32 +1127,129 @@ var getOwnersForResource = (catalogDir) => async (id, version) => {
1092
1127
  return owners;
1093
1128
  };
1094
1129
 
1130
+ // src/eventcatalog.ts
1131
+ import fs10 from "fs";
1132
+ import path6, { join as join13 } from "node:path";
1133
+ var DUMP_VERSION = "0.0.1";
1134
+ var getEventCatalogVersion = async (catalogDir) => {
1135
+ try {
1136
+ const packageJson = fs10.readFileSync(join13(catalogDir, "package.json"), "utf8");
1137
+ const packageJsonObject = JSON.parse(packageJson);
1138
+ return packageJsonObject["dependencies"]["@eventcatalog/core"];
1139
+ } catch (error) {
1140
+ return "unknown";
1141
+ }
1142
+ };
1143
+ var hydrateResource = async (catalogDir, resources = [], { attachSchema = false } = {}) => {
1144
+ return await Promise.all(
1145
+ resources.map(async (resource) => {
1146
+ const resourcePath = await getResourcePath(catalogDir, resource.id, resource.version);
1147
+ let schema = "";
1148
+ if (resource.schemaPath && resourcePath?.fullPath) {
1149
+ const pathToSchema = path6.join(path6.dirname(resourcePath?.fullPath), resource.schemaPath);
1150
+ if (fs10.existsSync(pathToSchema)) {
1151
+ schema = fs10.readFileSync(pathToSchema, "utf8");
1152
+ }
1153
+ }
1154
+ const eventcatalog = schema ? { directory: resourcePath?.directory, schema } : { directory: resourcePath?.directory };
1155
+ return {
1156
+ ...resource,
1157
+ _eventcatalog: eventcatalog
1158
+ };
1159
+ })
1160
+ );
1161
+ };
1162
+ var filterCollection = (collection, options) => {
1163
+ return collection.map((item) => ({
1164
+ ...item,
1165
+ markdown: options?.includeMarkdown ? item.markdown : void 0
1166
+ }));
1167
+ };
1168
+ var getEventCatalogConfigurationFile = (directory) => async () => {
1169
+ try {
1170
+ const path7 = join13(directory, "eventcatalog.config.js");
1171
+ const configModule = await import(path7);
1172
+ return configModule.default;
1173
+ } catch (error) {
1174
+ console.error("Error getting event catalog configuration file", error);
1175
+ return null;
1176
+ }
1177
+ };
1178
+ var dumpCatalog = (directory) => async (options) => {
1179
+ const { getDomains: getDomains2, getServices: getServices2, getEvents: getEvents2, getQueries: getQueries2, getCommands: getCommands2, getChannels: getChannels2, getTeams: getTeams2, getUsers: getUsers3 } = src_default(directory);
1180
+ const { includeMarkdown = true } = options || {};
1181
+ const domains = await getDomains2();
1182
+ const services = await getServices2();
1183
+ const events = await getEvents2();
1184
+ const commands = await getCommands2();
1185
+ const queries = await getQueries2();
1186
+ const teams = await getTeams2();
1187
+ const users = await getUsers3();
1188
+ const channels = await getChannels2();
1189
+ const [
1190
+ hydratedDomains,
1191
+ hydratedServices,
1192
+ hydratedEvents,
1193
+ hydratedQueries,
1194
+ hydratedCommands,
1195
+ hydratedTeams,
1196
+ hydratedUsers,
1197
+ hydratedChannels
1198
+ ] = await Promise.all([
1199
+ hydrateResource(directory, domains),
1200
+ hydrateResource(directory, services),
1201
+ hydrateResource(directory, events),
1202
+ hydrateResource(directory, queries),
1203
+ hydrateResource(directory, commands),
1204
+ hydrateResource(directory, teams),
1205
+ hydrateResource(directory, users),
1206
+ hydrateResource(directory, channels)
1207
+ ]);
1208
+ return {
1209
+ version: DUMP_VERSION,
1210
+ catalogVersion: await getEventCatalogVersion(directory),
1211
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1212
+ resources: {
1213
+ domains: filterCollection(hydratedDomains, { includeMarkdown }),
1214
+ services: filterCollection(hydratedServices, { includeMarkdown }),
1215
+ messages: {
1216
+ events: filterCollection(hydratedEvents, { includeMarkdown }),
1217
+ queries: filterCollection(hydratedQueries, { includeMarkdown }),
1218
+ commands: filterCollection(hydratedCommands, { includeMarkdown })
1219
+ },
1220
+ teams: filterCollection(hydratedTeams, { includeMarkdown }),
1221
+ users: filterCollection(hydratedUsers, { includeMarkdown }),
1222
+ channels: filterCollection(hydratedChannels, { includeMarkdown })
1223
+ }
1224
+ };
1225
+ };
1226
+
1095
1227
  // src/entities.ts
1096
- import fs10 from "node:fs/promises";
1097
- import { join as join13 } from "node:path";
1098
- var getEntity = (directory) => async (id, version) => getResource(directory, id, version, { type: "entity" });
1228
+ import fs11 from "node:fs/promises";
1229
+ import { join as join14 } from "node:path";
1230
+ var getEntity = (directory) => async (id, version2) => getResource(directory, id, version2, { type: "entity" });
1099
1231
  var getEntities = (directory) => async (options) => getResources(directory, { type: "entities", latestOnly: options?.latestOnly });
1100
1232
  var writeEntity = (directory) => async (entity, options = {
1101
1233
  path: "",
1102
1234
  override: false,
1103
1235
  format: "mdx"
1104
1236
  }) => writeResource(directory, { ...entity }, { ...options, type: "entity" });
1105
- var rmEntity = (directory) => async (path6) => {
1106
- await fs10.rm(join13(directory, path6), { recursive: true });
1237
+ var rmEntity = (directory) => async (path7) => {
1238
+ await fs11.rm(join14(directory, path7), { recursive: true });
1107
1239
  };
1108
- var rmEntityById = (directory) => async (id, version, persistFiles) => {
1109
- await rmResourceById(directory, id, version, { type: "entity", persistFiles });
1240
+ var rmEntityById = (directory) => async (id, version2, persistFiles) => {
1241
+ await rmResourceById(directory, id, version2, { type: "entity", persistFiles });
1110
1242
  };
1111
1243
  var versionEntity = (directory) => async (id) => versionResource(directory, id);
1112
- var entityHasVersion = (directory) => async (id, version) => {
1113
- const file = await findFileById(directory, id, version);
1244
+ var entityHasVersion = (directory) => async (id, version2) => {
1245
+ const file = await findFileById(directory, id, version2);
1114
1246
  return !!file;
1115
1247
  };
1116
1248
 
1117
1249
  // src/containers.ts
1118
- import fs11 from "node:fs/promises";
1119
- import { join as join14 } from "node:path";
1120
- var getContainer = (directory) => async (id, version) => getResource(directory, id, version, { type: "container" });
1250
+ import fs12 from "node:fs/promises";
1251
+ import { join as join15 } from "node:path";
1252
+ var getContainer = (directory) => async (id, version2) => getResource(directory, id, version2, { type: "container" });
1121
1253
  var getContainers = (directory) => async (options) => getResources(directory, { type: "containers", latestOnly: options?.latestOnly });
1122
1254
  var writeContainer = (directory) => async (data, options = {
1123
1255
  path: "",
@@ -1125,24 +1257,24 @@ var writeContainer = (directory) => async (data, options = {
1125
1257
  format: "mdx"
1126
1258
  }) => writeResource(directory, { ...data }, { ...options, type: "container" });
1127
1259
  var versionContainer = (directory) => async (id) => versionResource(directory, id);
1128
- var rmContainer = (directory) => async (path6) => {
1129
- await fs11.rm(join14(directory, path6), { recursive: true });
1260
+ var rmContainer = (directory) => async (path7) => {
1261
+ await fs12.rm(join15(directory, path7), { recursive: true });
1130
1262
  };
1131
- var rmContainerById = (directory) => async (id, version, persistFiles) => {
1132
- await rmResourceById(directory, id, version, { type: "container", persistFiles });
1263
+ var rmContainerById = (directory) => async (id, version2, persistFiles) => {
1264
+ await rmResourceById(directory, id, version2, { type: "container", persistFiles });
1133
1265
  };
1134
- var containerHasVersion = (directory) => async (id, version) => {
1135
- const file = await findFileById(directory, id, version);
1266
+ var containerHasVersion = (directory) => async (id, version2) => {
1267
+ const file = await findFileById(directory, id, version2);
1136
1268
  return !!file;
1137
1269
  };
1138
- var addFileToContainer = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
1270
+ var addFileToContainer = (directory) => async (id, file, version2) => addFileToResource(directory, id, file, version2);
1139
1271
  var writeContainerToService = (directory) => async (container, service, options = { path: "", format: "mdx", override: false }) => {
1140
1272
  const resourcePath = await getResourcePath(directory, service.id, service.version);
1141
1273
  if (!resourcePath) {
1142
1274
  throw new Error("Service not found");
1143
1275
  }
1144
1276
  let pathForContainer = service.version && service.version !== "latest" ? `${resourcePath.directory}/versioned/${service.version}/containers` : `${resourcePath.directory}/containers`;
1145
- pathForContainer = join14(pathForContainer, container.id);
1277
+ pathForContainer = join15(pathForContainer, container.id);
1146
1278
  await writeResource(directory, { ...container }, { ...options, path: pathForContainer, type: "container" });
1147
1279
  };
1148
1280
 
@@ -1158,9 +1290,9 @@ var addFileToDataStore = addFileToContainer;
1158
1290
  var writeDataStoreToService = writeContainerToService;
1159
1291
 
1160
1292
  // src/data-products.ts
1161
- import fs12 from "node:fs/promises";
1162
- import { join as join15 } from "node:path";
1163
- var getDataProduct = (directory) => async (id, version) => getResource(directory, id, version, { type: "data-product" });
1293
+ import fs13 from "node:fs/promises";
1294
+ import { join as join16 } from "node:path";
1295
+ var getDataProduct = (directory) => async (id, version2) => getResource(directory, id, version2, { type: "data-product" });
1164
1296
  var getDataProducts = (directory) => async (options) => getResources(directory, { type: "data-products", latestOnly: options?.latestOnly });
1165
1297
  var writeDataProduct = (directory) => async (dataProduct, options = {
1166
1298
  path: "",
@@ -1169,24 +1301,47 @@ var writeDataProduct = (directory) => async (dataProduct, options = {
1169
1301
  }) => writeResource(directory, { ...dataProduct }, { ...options, type: "data-product" });
1170
1302
  var writeDataProductToDomain = (directory) => async (dataProduct, domain, options = { path: "", format: "mdx", override: false }) => {
1171
1303
  let pathForDataProduct = domain.version && domain.version !== "latest" ? `/${domain.id}/versioned/${domain.version}/data-products` : `/${domain.id}/data-products`;
1172
- pathForDataProduct = join15(pathForDataProduct, dataProduct.id);
1304
+ pathForDataProduct = join16(pathForDataProduct, dataProduct.id);
1173
1305
  await writeResource(directory, { ...dataProduct }, { ...options, path: pathForDataProduct, type: "data-product" });
1174
1306
  };
1175
- var rmDataProduct = (directory) => async (path6) => {
1176
- await fs12.rm(join15(directory, path6), { recursive: true });
1307
+ var rmDataProduct = (directory) => async (path7) => {
1308
+ await fs13.rm(join16(directory, path7), { recursive: true });
1177
1309
  };
1178
- var rmDataProductById = (directory) => async (id, version, persistFiles) => {
1179
- await rmResourceById(directory, id, version, { type: "data-product", persistFiles });
1310
+ var rmDataProductById = (directory) => async (id, version2, persistFiles) => {
1311
+ await rmResourceById(directory, id, version2, { type: "data-product", persistFiles });
1180
1312
  };
1181
1313
  var versionDataProduct = (directory) => async (id) => versionResource(directory, id);
1182
- var dataProductHasVersion = (directory) => async (id, version) => {
1183
- const file = await findFileById(directory, id, version);
1314
+ var dataProductHasVersion = (directory) => async (id, version2) => {
1315
+ const file = await findFileById(directory, id, version2);
1184
1316
  return !!file;
1185
1317
  };
1186
- var addFileToDataProduct = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
1318
+ var addFileToDataProduct = (directory) => async (id, file, version2) => addFileToResource(directory, id, file, version2);
1319
+
1320
+ // src/diagrams.ts
1321
+ import fs14 from "node:fs/promises";
1322
+ import { join as join17 } from "node:path";
1323
+ var getDiagram = (directory) => async (id, version2) => getResource(directory, id, version2, { type: "diagram" });
1324
+ var getDiagrams = (directory) => async (options) => getResources(directory, { type: "diagrams", latestOnly: options?.latestOnly });
1325
+ var writeDiagram = (directory) => async (diagram, options = {
1326
+ path: "",
1327
+ override: false,
1328
+ format: "mdx"
1329
+ }) => writeResource(directory, { ...diagram }, { ...options, type: "diagram" });
1330
+ var rmDiagram = (directory) => async (path7) => {
1331
+ await fs14.rm(join17(directory, path7), { recursive: true });
1332
+ };
1333
+ var rmDiagramById = (directory) => async (id, version2, persistFiles) => {
1334
+ await rmResourceById(directory, id, version2, { type: "diagram", persistFiles });
1335
+ };
1336
+ var versionDiagram = (directory) => async (id) => versionResource(directory, id);
1337
+ var diagramHasVersion = (directory) => async (id, version2) => {
1338
+ const file = await findFileById(directory, id, version2);
1339
+ return !!file;
1340
+ };
1341
+ var addFileToDiagram = (directory) => async (id, file, version2) => addFileToResource(directory, id, file, version2, { type: "diagram" });
1187
1342
 
1188
1343
  // src/index.ts
1189
- var src_default = (path6) => {
1344
+ var src_default = (path7) => {
1190
1345
  return {
1191
1346
  /**
1192
1347
  * Returns an events from EventCatalog
@@ -1194,13 +1349,13 @@ var src_default = (path6) => {
1194
1349
  * @param version - Optional id of the version to get (supports semver)
1195
1350
  * @returns Event|Undefined
1196
1351
  */
1197
- getEvent: getEvent(join16(path6)),
1352
+ getEvent: getEvent(join18(path7)),
1198
1353
  /**
1199
1354
  * Returns all events from EventCatalog
1200
1355
  * @param latestOnly - optional boolean, set to true to get only latest versions
1201
1356
  * @returns Event[]|Undefined
1202
1357
  */
1203
- getEvents: getEvents(join16(path6)),
1358
+ getEvents: getEvents(join18(path7)),
1204
1359
  /**
1205
1360
  * Adds an event to EventCatalog
1206
1361
  *
@@ -1208,7 +1363,7 @@ var src_default = (path6) => {
1208
1363
  * @param options - Optional options to write the event
1209
1364
  *
1210
1365
  */
1211
- writeEvent: writeEvent(join16(path6, "events")),
1366
+ writeEvent: writeEvent(join18(path7, "events")),
1212
1367
  /**
1213
1368
  * Adds an event to a service in EventCatalog
1214
1369
  *
@@ -1217,26 +1372,26 @@ var src_default = (path6) => {
1217
1372
  * @param options - Optional options to write the event
1218
1373
  *
1219
1374
  */
1220
- writeEventToService: writeEventToService(join16(path6)),
1375
+ writeEventToService: writeEventToService(join18(path7)),
1221
1376
  /**
1222
1377
  * Remove an event to EventCatalog (modeled on the standard POSIX rm utility)
1223
1378
  *
1224
1379
  * @param path - The path to your event, e.g. `/Inventory/InventoryAdjusted`
1225
1380
  *
1226
1381
  */
1227
- rmEvent: rmEvent(join16(path6, "events")),
1382
+ rmEvent: rmEvent(join18(path7, "events")),
1228
1383
  /**
1229
1384
  * Remove an event by an Event id
1230
1385
  *
1231
1386
  * @param id - The id of the event you want to remove
1232
1387
  *
1233
1388
  */
1234
- rmEventById: rmEventById(join16(path6)),
1389
+ rmEventById: rmEventById(join18(path7)),
1235
1390
  /**
1236
1391
  * Moves a given event id to the version directory
1237
1392
  * @param directory
1238
1393
  */
1239
- versionEvent: versionEvent(join16(path6)),
1394
+ versionEvent: versionEvent(join18(path7)),
1240
1395
  /**
1241
1396
  * Adds a file to the given event
1242
1397
  * @param id - The id of the event to add the file to
@@ -1244,7 +1399,7 @@ var src_default = (path6) => {
1244
1399
  * @param version - Optional version of the event to add the file to
1245
1400
  * @returns
1246
1401
  */
1247
- addFileToEvent: addFileToEvent(join16(path6)),
1402
+ addFileToEvent: addFileToEvent(join18(path7)),
1248
1403
  /**
1249
1404
  * Adds a schema to the given event
1250
1405
  * @param id - The id of the event to add the schema to
@@ -1252,14 +1407,14 @@ var src_default = (path6) => {
1252
1407
  * @param version - Optional version of the event to add the schema to
1253
1408
  * @returns
1254
1409
  */
1255
- addSchemaToEvent: addSchemaToEvent(join16(path6)),
1410
+ addSchemaToEvent: addSchemaToEvent(join18(path7)),
1256
1411
  /**
1257
1412
  * Check to see if an event version exists
1258
1413
  * @param id - The id of the event
1259
1414
  * @param version - The version of the event (supports semver)
1260
1415
  * @returns
1261
1416
  */
1262
- eventHasVersion: eventHasVersion(join16(path6)),
1417
+ eventHasVersion: eventHasVersion(join18(path7)),
1263
1418
  /**
1264
1419
  * ================================
1265
1420
  * Commands
@@ -1271,13 +1426,13 @@ var src_default = (path6) => {
1271
1426
  * @param version - Optional id of the version to get (supports semver)
1272
1427
  * @returns Command|Undefined
1273
1428
  */
1274
- getCommand: getCommand(join16(path6)),
1429
+ getCommand: getCommand(join18(path7)),
1275
1430
  /**
1276
1431
  * Returns all commands from EventCatalog
1277
1432
  * @param latestOnly - optional boolean, set to true to get only latest versions
1278
1433
  * @returns Command[]|Undefined
1279
1434
  */
1280
- getCommands: getCommands(join16(path6)),
1435
+ getCommands: getCommands(join18(path7)),
1281
1436
  /**
1282
1437
  * Adds an command to EventCatalog
1283
1438
  *
@@ -1285,7 +1440,7 @@ var src_default = (path6) => {
1285
1440
  * @param options - Optional options to write the command
1286
1441
  *
1287
1442
  */
1288
- writeCommand: writeCommand(join16(path6, "commands")),
1443
+ writeCommand: writeCommand(join18(path7, "commands")),
1289
1444
  /**
1290
1445
  * Adds a command to a service in EventCatalog
1291
1446
  *
@@ -1294,26 +1449,26 @@ var src_default = (path6) => {
1294
1449
  * @param options - Optional options to write the command
1295
1450
  *
1296
1451
  */
1297
- writeCommandToService: writeCommandToService(join16(path6)),
1452
+ writeCommandToService: writeCommandToService(join18(path7)),
1298
1453
  /**
1299
1454
  * Remove an command to EventCatalog (modeled on the standard POSIX rm utility)
1300
1455
  *
1301
1456
  * @param path - The path to your command, e.g. `/Inventory/InventoryAdjusted`
1302
1457
  *
1303
1458
  */
1304
- rmCommand: rmCommand(join16(path6, "commands")),
1459
+ rmCommand: rmCommand(join18(path7, "commands")),
1305
1460
  /**
1306
1461
  * Remove an command by an Event id
1307
1462
  *
1308
1463
  * @param id - The id of the command you want to remove
1309
1464
  *
1310
1465
  */
1311
- rmCommandById: rmCommandById(join16(path6)),
1466
+ rmCommandById: rmCommandById(join18(path7)),
1312
1467
  /**
1313
1468
  * Moves a given command id to the version directory
1314
1469
  * @param directory
1315
1470
  */
1316
- versionCommand: versionCommand(join16(path6)),
1471
+ versionCommand: versionCommand(join18(path7)),
1317
1472
  /**
1318
1473
  * Adds a file to the given command
1319
1474
  * @param id - The id of the command to add the file to
@@ -1321,7 +1476,7 @@ var src_default = (path6) => {
1321
1476
  * @param version - Optional version of the command to add the file to
1322
1477
  * @returns
1323
1478
  */
1324
- addFileToCommand: addFileToCommand(join16(path6)),
1479
+ addFileToCommand: addFileToCommand(join18(path7)),
1325
1480
  /**
1326
1481
  * Adds a schema to the given command
1327
1482
  * @param id - The id of the command to add the schema to
@@ -1329,14 +1484,14 @@ var src_default = (path6) => {
1329
1484
  * @param version - Optional version of the command to add the schema to
1330
1485
  * @returns
1331
1486
  */
1332
- addSchemaToCommand: addSchemaToCommand(join16(path6)),
1487
+ addSchemaToCommand: addSchemaToCommand(join18(path7)),
1333
1488
  /**
1334
1489
  * Check to see if a command version exists
1335
1490
  * @param id - The id of the command
1336
1491
  * @param version - The version of the command (supports semver)
1337
1492
  * @returns
1338
1493
  */
1339
- commandHasVersion: commandHasVersion(join16(path6)),
1494
+ commandHasVersion: commandHasVersion(join18(path7)),
1340
1495
  /**
1341
1496
  * ================================
1342
1497
  * Queries
@@ -1348,13 +1503,13 @@ var src_default = (path6) => {
1348
1503
  * @param version - Optional id of the version to get (supports semver)
1349
1504
  * @returns Query|Undefined
1350
1505
  */
1351
- getQuery: getQuery(join16(path6)),
1506
+ getQuery: getQuery(join18(path7)),
1352
1507
  /**
1353
1508
  * Returns all queries from EventCatalog
1354
1509
  * @param latestOnly - optional boolean, set to true to get only latest versions
1355
1510
  * @returns Query[]|Undefined
1356
1511
  */
1357
- getQueries: getQueries(join16(path6)),
1512
+ getQueries: getQueries(join18(path7)),
1358
1513
  /**
1359
1514
  * Adds a query to EventCatalog
1360
1515
  *
@@ -1362,7 +1517,7 @@ var src_default = (path6) => {
1362
1517
  * @param options - Optional options to write the event
1363
1518
  *
1364
1519
  */
1365
- writeQuery: writeQuery(join16(path6, "queries")),
1520
+ writeQuery: writeQuery(join18(path7, "queries")),
1366
1521
  /**
1367
1522
  * Adds a query to a service in EventCatalog
1368
1523
  *
@@ -1371,26 +1526,26 @@ var src_default = (path6) => {
1371
1526
  * @param options - Optional options to write the query
1372
1527
  *
1373
1528
  */
1374
- writeQueryToService: writeQueryToService(join16(path6)),
1529
+ writeQueryToService: writeQueryToService(join18(path7)),
1375
1530
  /**
1376
1531
  * Remove an query to EventCatalog (modeled on the standard POSIX rm utility)
1377
1532
  *
1378
1533
  * @param path - The path to your query, e.g. `/Orders/GetOrder`
1379
1534
  *
1380
1535
  */
1381
- rmQuery: rmQuery(join16(path6, "queries")),
1536
+ rmQuery: rmQuery(join18(path7, "queries")),
1382
1537
  /**
1383
1538
  * Remove a query by a Query id
1384
1539
  *
1385
1540
  * @param id - The id of the query you want to remove
1386
1541
  *
1387
1542
  */
1388
- rmQueryById: rmQueryById(join16(path6)),
1543
+ rmQueryById: rmQueryById(join18(path7)),
1389
1544
  /**
1390
1545
  * Moves a given query id to the version directory
1391
1546
  * @param directory
1392
1547
  */
1393
- versionQuery: versionQuery(join16(path6)),
1548
+ versionQuery: versionQuery(join18(path7)),
1394
1549
  /**
1395
1550
  * Adds a file to the given query
1396
1551
  * @param id - The id of the query to add the file to
@@ -1398,7 +1553,7 @@ var src_default = (path6) => {
1398
1553
  * @param version - Optional version of the query to add the file to
1399
1554
  * @returns
1400
1555
  */
1401
- addFileToQuery: addFileToQuery(join16(path6)),
1556
+ addFileToQuery: addFileToQuery(join18(path7)),
1402
1557
  /**
1403
1558
  * Adds a schema to the given query
1404
1559
  * @param id - The id of the query to add the schema to
@@ -1406,14 +1561,14 @@ var src_default = (path6) => {
1406
1561
  * @param version - Optional version of the query to add the schema to
1407
1562
  * @returns
1408
1563
  */
1409
- addSchemaToQuery: addSchemaToQuery(join16(path6)),
1564
+ addSchemaToQuery: addSchemaToQuery(join18(path7)),
1410
1565
  /**
1411
1566
  * Check to see if an query version exists
1412
1567
  * @param id - The id of the query
1413
1568
  * @param version - The version of the query (supports semver)
1414
1569
  * @returns
1415
1570
  */
1416
- queryHasVersion: queryHasVersion(join16(path6)),
1571
+ queryHasVersion: queryHasVersion(join18(path7)),
1417
1572
  /**
1418
1573
  * ================================
1419
1574
  * Channels
@@ -1425,13 +1580,13 @@ var src_default = (path6) => {
1425
1580
  * @param version - Optional id of the version to get (supports semver)
1426
1581
  * @returns Channel|Undefined
1427
1582
  */
1428
- getChannel: getChannel(join16(path6)),
1583
+ getChannel: getChannel(join18(path7)),
1429
1584
  /**
1430
1585
  * Returns all channels from EventCatalog
1431
1586
  * @param latestOnly - optional boolean, set to true to get only latest versions
1432
1587
  * @returns Channel[]|Undefined
1433
1588
  */
1434
- getChannels: getChannels(join16(path6)),
1589
+ getChannels: getChannels(join18(path7)),
1435
1590
  /**
1436
1591
  * Adds an channel to EventCatalog
1437
1592
  *
@@ -1439,33 +1594,33 @@ var src_default = (path6) => {
1439
1594
  * @param options - Optional options to write the channel
1440
1595
  *
1441
1596
  */
1442
- writeChannel: writeChannel(join16(path6, "channels")),
1597
+ writeChannel: writeChannel(join18(path7, "channels")),
1443
1598
  /**
1444
1599
  * Remove an channel to EventCatalog (modeled on the standard POSIX rm utility)
1445
1600
  *
1446
1601
  * @param path - The path to your channel, e.g. `/Inventory/InventoryAdjusted`
1447
1602
  *
1448
1603
  */
1449
- rmChannel: rmChannel(join16(path6, "channels")),
1604
+ rmChannel: rmChannel(join18(path7, "channels")),
1450
1605
  /**
1451
1606
  * Remove an channel by an Event id
1452
1607
  *
1453
1608
  * @param id - The id of the channel you want to remove
1454
1609
  *
1455
1610
  */
1456
- rmChannelById: rmChannelById(join16(path6)),
1611
+ rmChannelById: rmChannelById(join18(path7)),
1457
1612
  /**
1458
1613
  * Moves a given channel id to the version directory
1459
1614
  * @param directory
1460
1615
  */
1461
- versionChannel: versionChannel(join16(path6)),
1616
+ versionChannel: versionChannel(join18(path7)),
1462
1617
  /**
1463
1618
  * Check to see if a channel version exists
1464
1619
  * @param id - The id of the channel
1465
1620
  * @param version - The version of the channel (supports semver)
1466
1621
  * @returns
1467
1622
  */
1468
- channelHasVersion: channelHasVersion(join16(path6)),
1623
+ channelHasVersion: channelHasVersion(join18(path7)),
1469
1624
  /**
1470
1625
  * Add a channel to an event
1471
1626
  *
@@ -1482,7 +1637,7 @@ var src_default = (path6) => {
1482
1637
  *
1483
1638
  * ```
1484
1639
  */
1485
- addEventToChannel: addMessageToChannel(join16(path6), "events"),
1640
+ addEventToChannel: addMessageToChannel(join18(path7), "events"),
1486
1641
  /**
1487
1642
  * Add a channel to an command
1488
1643
  *
@@ -1499,7 +1654,7 @@ var src_default = (path6) => {
1499
1654
  *
1500
1655
  * ```
1501
1656
  */
1502
- addCommandToChannel: addMessageToChannel(join16(path6), "commands"),
1657
+ addCommandToChannel: addMessageToChannel(join18(path7), "commands"),
1503
1658
  /**
1504
1659
  * Add a channel to an query
1505
1660
  *
@@ -1516,7 +1671,7 @@ var src_default = (path6) => {
1516
1671
  *
1517
1672
  * ```
1518
1673
  */
1519
- addQueryToChannel: addMessageToChannel(join16(path6), "queries"),
1674
+ addQueryToChannel: addMessageToChannel(join18(path7), "queries"),
1520
1675
  /**
1521
1676
  * ================================
1522
1677
  * SERVICES
@@ -1529,14 +1684,14 @@ var src_default = (path6) => {
1529
1684
  * @param options - Optional options to write the event
1530
1685
  *
1531
1686
  */
1532
- writeService: writeService(join16(path6, "services")),
1687
+ writeService: writeService(join18(path7, "services")),
1533
1688
  /**
1534
1689
  * Adds a versioned service to EventCatalog
1535
1690
  *
1536
1691
  * @param service - The service to write
1537
1692
  *
1538
1693
  */
1539
- writeVersionedService: writeVersionedService(join16(path6, "services")),
1694
+ writeVersionedService: writeVersionedService(join18(path7, "services")),
1540
1695
  /**
1541
1696
  * Adds a service to a domain in EventCatalog
1542
1697
  *
@@ -1545,45 +1700,45 @@ var src_default = (path6) => {
1545
1700
  * @param options - Optional options to write the event
1546
1701
  *
1547
1702
  */
1548
- writeServiceToDomain: writeServiceToDomain(join16(path6, "domains")),
1703
+ writeServiceToDomain: writeServiceToDomain(join18(path7, "domains")),
1549
1704
  /**
1550
1705
  * Returns a service from EventCatalog
1551
1706
  * @param id - The id of the service to retrieve
1552
1707
  * @param version - Optional id of the version to get (supports semver)
1553
1708
  * @returns Service|Undefined
1554
1709
  */
1555
- getService: getService(join16(path6)),
1710
+ getService: getService(join18(path7)),
1556
1711
  /**
1557
1712
  * Returns a service from EventCatalog by it's path.
1558
1713
  * @param path - The path to the service to retrieve
1559
1714
  * @returns Service|Undefined
1560
1715
  */
1561
- getServiceByPath: getServiceByPath(join16(path6)),
1716
+ getServiceByPath: getServiceByPath(join18(path7)),
1562
1717
  /**
1563
1718
  * Returns all services from EventCatalog
1564
1719
  * @param latestOnly - optional boolean, set to true to get only latest versions
1565
1720
  * @returns Service[]|Undefined
1566
1721
  */
1567
- getServices: getServices(join16(path6)),
1722
+ getServices: getServices(join18(path7)),
1568
1723
  /**
1569
1724
  * Moves a given service id to the version directory
1570
1725
  * @param directory
1571
1726
  */
1572
- versionService: versionService(join16(path6)),
1727
+ versionService: versionService(join18(path7)),
1573
1728
  /**
1574
1729
  * Remove a service from EventCatalog (modeled on the standard POSIX rm utility)
1575
1730
  *
1576
1731
  * @param path - The path to your service, e.g. `/InventoryService`
1577
1732
  *
1578
1733
  */
1579
- rmService: rmService(join16(path6, "services")),
1734
+ rmService: rmService(join18(path7, "services")),
1580
1735
  /**
1581
1736
  * Remove an service by an service id
1582
1737
  *
1583
1738
  * @param id - The id of the service you want to remove
1584
1739
  *
1585
1740
  */
1586
- rmServiceById: rmServiceById(join16(path6)),
1741
+ rmServiceById: rmServiceById(join18(path7)),
1587
1742
  /**
1588
1743
  * Adds a file to the given service
1589
1744
  * @param id - The id of the service to add the file to
@@ -1591,21 +1746,21 @@ var src_default = (path6) => {
1591
1746
  * @param version - Optional version of the service to add the file to
1592
1747
  * @returns
1593
1748
  */
1594
- addFileToService: addFileToService(join16(path6)),
1749
+ addFileToService: addFileToService(join18(path7)),
1595
1750
  /**
1596
1751
  * Returns the specifications for a given service
1597
1752
  * @param id - The id of the service to retrieve the specifications for
1598
1753
  * @param version - Optional version of the service
1599
1754
  * @returns
1600
1755
  */
1601
- getSpecificationFilesForService: getSpecificationFilesForService(join16(path6)),
1756
+ getSpecificationFilesForService: getSpecificationFilesForService(join18(path7)),
1602
1757
  /**
1603
1758
  * Check to see if a service version exists
1604
1759
  * @param id - The id of the service
1605
1760
  * @param version - The version of the service (supports semver)
1606
1761
  * @returns
1607
1762
  */
1608
- serviceHasVersion: serviceHasVersion(join16(path6)),
1763
+ serviceHasVersion: serviceHasVersion(join18(path7)),
1609
1764
  /**
1610
1765
  * Add an event to a service by it's id.
1611
1766
  *
@@ -1625,7 +1780,7 @@ var src_default = (path6) => {
1625
1780
  *
1626
1781
  * ```
1627
1782
  */
1628
- addEventToService: addMessageToService(join16(path6)),
1783
+ addEventToService: addMessageToService(join18(path7)),
1629
1784
  /**
1630
1785
  * Add a data store to a service by it's id.
1631
1786
  *
@@ -1642,7 +1797,7 @@ var src_default = (path6) => {
1642
1797
  *
1643
1798
  * ```
1644
1799
  */
1645
- addDataStoreToService: addDataStoreToService(join16(path6)),
1800
+ addDataStoreToService: addDataStoreToService(join18(path7)),
1646
1801
  /**
1647
1802
  * Add a command to a service by it's id.
1648
1803
  *
@@ -1662,7 +1817,7 @@ var src_default = (path6) => {
1662
1817
  *
1663
1818
  * ```
1664
1819
  */
1665
- addCommandToService: addMessageToService(join16(path6)),
1820
+ addCommandToService: addMessageToService(join18(path7)),
1666
1821
  /**
1667
1822
  * Add a query to a service by it's id.
1668
1823
  *
@@ -1682,7 +1837,7 @@ var src_default = (path6) => {
1682
1837
  *
1683
1838
  * ```
1684
1839
  */
1685
- addQueryToService: addMessageToService(join16(path6)),
1840
+ addQueryToService: addMessageToService(join18(path7)),
1686
1841
  /**
1687
1842
  * Add an entity to a service by its id.
1688
1843
  *
@@ -1700,7 +1855,7 @@ var src_default = (path6) => {
1700
1855
  *
1701
1856
  * ```
1702
1857
  */
1703
- addEntityToService: addEntityToService(join16(path6)),
1858
+ addEntityToService: addEntityToService(join18(path7)),
1704
1859
  /**
1705
1860
  * Check to see if a service exists by it's path.
1706
1861
  *
@@ -1717,13 +1872,13 @@ var src_default = (path6) => {
1717
1872
  * @param path - The path to the service to check
1718
1873
  * @returns boolean
1719
1874
  */
1720
- isService: isService(join16(path6)),
1875
+ isService: isService(join18(path7)),
1721
1876
  /**
1722
1877
  * Converts a file to a service.
1723
1878
  * @param file - The file to convert to a service.
1724
1879
  * @returns The service.
1725
1880
  */
1726
- toService: toService(join16(path6)),
1881
+ toService: toService(join18(path7)),
1727
1882
  /**
1728
1883
  * ================================
1729
1884
  * Domains
@@ -1736,39 +1891,39 @@ var src_default = (path6) => {
1736
1891
  * @param options - Optional options to write the event
1737
1892
  *
1738
1893
  */
1739
- writeDomain: writeDomain(join16(path6, "domains")),
1894
+ writeDomain: writeDomain(join18(path7, "domains")),
1740
1895
  /**
1741
1896
  * Returns a domain from EventCatalog
1742
1897
  * @param id - The id of the domain to retrieve
1743
1898
  * @param version - Optional id of the version to get (supports semver)
1744
1899
  * @returns Domain|Undefined
1745
1900
  */
1746
- getDomain: getDomain(join16(path6, "domains")),
1901
+ getDomain: getDomain(join18(path7, "domains")),
1747
1902
  /**
1748
1903
  * Returns all domains from EventCatalog
1749
1904
  * @param latestOnly - optional boolean, set to true to get only latest versions
1750
1905
  * @returns Domain[]|Undefined
1751
1906
  */
1752
- getDomains: getDomains(join16(path6)),
1907
+ getDomains: getDomains(join18(path7)),
1753
1908
  /**
1754
1909
  * Moves a given domain id to the version directory
1755
1910
  * @param directory
1756
1911
  */
1757
- versionDomain: versionDomain(join16(path6, "domains")),
1912
+ versionDomain: versionDomain(join18(path7, "domains")),
1758
1913
  /**
1759
1914
  * Remove a domain from EventCatalog (modeled on the standard POSIX rm utility)
1760
1915
  *
1761
1916
  * @param path - The path to your domain, e.g. `/Payment`
1762
1917
  *
1763
1918
  */
1764
- rmDomain: rmDomain(join16(path6, "domains")),
1919
+ rmDomain: rmDomain(join18(path7, "domains")),
1765
1920
  /**
1766
1921
  * Remove an service by an domain id
1767
1922
  *
1768
1923
  * @param id - The id of the domain you want to remove
1769
1924
  *
1770
1925
  */
1771
- rmDomainById: rmDomainById(join16(path6, "domains")),
1926
+ rmDomainById: rmDomainById(join18(path7, "domains")),
1772
1927
  /**
1773
1928
  * Adds a file to the given domain
1774
1929
  * @param id - The id of the domain to add the file to
@@ -1776,28 +1931,28 @@ var src_default = (path6) => {
1776
1931
  * @param version - Optional version of the domain to add the file to
1777
1932
  * @returns
1778
1933
  */
1779
- addFileToDomain: addFileToDomain(join16(path6, "domains")),
1934
+ addFileToDomain: addFileToDomain(join18(path7, "domains")),
1780
1935
  /**
1781
1936
  * Adds an ubiquitous language dictionary to a domain
1782
1937
  * @param id - The id of the domain to add the ubiquitous language to
1783
1938
  * @param ubiquitousLanguageDictionary - The ubiquitous language dictionary to add
1784
1939
  * @param version - Optional version of the domain to add the ubiquitous language to
1785
1940
  */
1786
- addUbiquitousLanguageToDomain: addUbiquitousLanguageToDomain(join16(path6, "domains")),
1941
+ addUbiquitousLanguageToDomain: addUbiquitousLanguageToDomain(join18(path7, "domains")),
1787
1942
  /**
1788
1943
  * Get the ubiquitous language dictionary from a domain
1789
1944
  * @param id - The id of the domain to get the ubiquitous language from
1790
1945
  * @param version - Optional version of the domain to get the ubiquitous language from
1791
1946
  * @returns
1792
1947
  */
1793
- getUbiquitousLanguageFromDomain: getUbiquitousLanguageFromDomain(join16(path6, "domains")),
1948
+ getUbiquitousLanguageFromDomain: getUbiquitousLanguageFromDomain(join18(path7, "domains")),
1794
1949
  /**
1795
1950
  * Check to see if a domain version exists
1796
1951
  * @param id - The id of the domain
1797
1952
  * @param version - The version of the domain (supports semver)
1798
1953
  * @returns
1799
1954
  */
1800
- domainHasVersion: domainHasVersion(join16(path6)),
1955
+ domainHasVersion: domainHasVersion(join18(path7)),
1801
1956
  /**
1802
1957
  * Adds a given service to a domain
1803
1958
  * @param id - The id of the domain
@@ -1805,7 +1960,7 @@ var src_default = (path6) => {
1805
1960
  * @param version - (Optional) The version of the domain to add the service to
1806
1961
  * @returns
1807
1962
  */
1808
- addServiceToDomain: addServiceToDomain(join16(path6, "domains")),
1963
+ addServiceToDomain: addServiceToDomain(join18(path7, "domains")),
1809
1964
  /**
1810
1965
  * Adds a given subdomain to a domain
1811
1966
  * @param id - The id of the domain
@@ -1813,7 +1968,7 @@ var src_default = (path6) => {
1813
1968
  * @param version - (Optional) The version of the domain to add the subdomain to
1814
1969
  * @returns
1815
1970
  */
1816
- addSubDomainToDomain: addSubDomainToDomain(join16(path6, "domains")),
1971
+ addSubDomainToDomain: addSubDomainToDomain(join18(path7, "domains")),
1817
1972
  /**
1818
1973
  * Adds an entity to a domain
1819
1974
  * @param id - The id of the domain
@@ -1821,7 +1976,7 @@ var src_default = (path6) => {
1821
1976
  * @param version - (Optional) The version of the domain to add the entity to
1822
1977
  * @returns
1823
1978
  */
1824
- addEntityToDomain: addEntityToDomain(join16(path6, "domains")),
1979
+ addEntityToDomain: addEntityToDomain(join18(path7, "domains")),
1825
1980
  /**
1826
1981
  * Add an event to a domain by its id.
1827
1982
  *
@@ -1839,7 +1994,7 @@ var src_default = (path6) => {
1839
1994
  *
1840
1995
  * ```
1841
1996
  */
1842
- addEventToDomain: addMessageToDomain(join16(path6, "domains")),
1997
+ addEventToDomain: addMessageToDomain(join18(path7, "domains")),
1843
1998
  /**
1844
1999
  * Add a command to a domain by its id.
1845
2000
  *
@@ -1857,7 +2012,7 @@ var src_default = (path6) => {
1857
2012
  *
1858
2013
  * ```
1859
2014
  */
1860
- addCommandToDomain: addMessageToDomain(join16(path6, "domains")),
2015
+ addCommandToDomain: addMessageToDomain(join18(path7, "domains")),
1861
2016
  /**
1862
2017
  * Add a query to a domain by its id.
1863
2018
  *
@@ -1875,7 +2030,7 @@ var src_default = (path6) => {
1875
2030
  *
1876
2031
  * ```
1877
2032
  */
1878
- addQueryToDomain: addMessageToDomain(join16(path6, "domains")),
2033
+ addQueryToDomain: addMessageToDomain(join18(path7, "domains")),
1879
2034
  /**
1880
2035
  * ================================
1881
2036
  * Teams
@@ -1888,25 +2043,25 @@ var src_default = (path6) => {
1888
2043
  * @param options - Optional options to write the team
1889
2044
  *
1890
2045
  */
1891
- writeTeam: writeTeam(join16(path6, "teams")),
2046
+ writeTeam: writeTeam(join18(path7, "teams")),
1892
2047
  /**
1893
2048
  * Returns a team from EventCatalog
1894
2049
  * @param id - The id of the team to retrieve
1895
2050
  * @returns Team|Undefined
1896
2051
  */
1897
- getTeam: getTeam(join16(path6, "teams")),
2052
+ getTeam: getTeam(join18(path7, "teams")),
1898
2053
  /**
1899
2054
  * Returns all teams from EventCatalog
1900
2055
  * @returns Team[]|Undefined
1901
2056
  */
1902
- getTeams: getTeams(join16(path6, "teams")),
2057
+ getTeams: getTeams(join18(path7, "teams")),
1903
2058
  /**
1904
2059
  * Remove a team by the team id
1905
2060
  *
1906
2061
  * @param id - The id of the team you want to remove
1907
2062
  *
1908
2063
  */
1909
- rmTeamById: rmTeamById(join16(path6, "teams")),
2064
+ rmTeamById: rmTeamById(join18(path7, "teams")),
1910
2065
  /**
1911
2066
  * ================================
1912
2067
  * Users
@@ -1919,25 +2074,25 @@ var src_default = (path6) => {
1919
2074
  * @param options - Optional options to write the user
1920
2075
  *
1921
2076
  */
1922
- writeUser: writeUser(join16(path6, "users")),
2077
+ writeUser: writeUser(join18(path7, "users")),
1923
2078
  /**
1924
2079
  * Returns a user from EventCatalog
1925
2080
  * @param id - The id of the user to retrieve
1926
2081
  * @returns User|Undefined
1927
2082
  */
1928
- getUser: getUser(join16(path6, "users")),
2083
+ getUser: getUser(join18(path7, "users")),
1929
2084
  /**
1930
2085
  * Returns all user from EventCatalog
1931
2086
  * @returns User[]|Undefined
1932
2087
  */
1933
- getUsers: getUsers(join16(path6)),
2088
+ getUsers: getUsers(join18(path7)),
1934
2089
  /**
1935
2090
  * Remove a user by the user id
1936
2091
  *
1937
2092
  * @param id - The id of the user you want to remove
1938
2093
  *
1939
2094
  */
1940
- rmUserById: rmUserById(join16(path6, "users")),
2095
+ rmUserById: rmUserById(join18(path7, "users")),
1941
2096
  /**
1942
2097
  * ================================
1943
2098
  * Custom Docs
@@ -1948,32 +2103,32 @@ var src_default = (path6) => {
1948
2103
  * @param path - The path to the custom doc to retrieve
1949
2104
  * @returns CustomDoc|Undefined
1950
2105
  */
1951
- getCustomDoc: getCustomDoc(join16(path6, "docs")),
2106
+ getCustomDoc: getCustomDoc(join18(path7, "docs")),
1952
2107
  /**
1953
2108
  * Returns all custom docs from EventCatalog
1954
2109
  * @param options - Optional options to get custom docs from a specific path
1955
2110
  * @returns CustomDoc[]|Undefined
1956
2111
  */
1957
- getCustomDocs: getCustomDocs(join16(path6, "docs")),
2112
+ getCustomDocs: getCustomDocs(join18(path7, "docs")),
1958
2113
  /**
1959
2114
  * Writes a custom doc to EventCatalog
1960
2115
  * @param customDoc - The custom doc to write
1961
2116
  * @param options - Optional options to write the custom doc
1962
2117
  *
1963
2118
  */
1964
- writeCustomDoc: writeCustomDoc(join16(path6, "docs")),
2119
+ writeCustomDoc: writeCustomDoc(join18(path7, "docs")),
1965
2120
  /**
1966
2121
  * Removes a custom doc from EventCatalog
1967
2122
  * @param path - The path to the custom doc to remove
1968
2123
  *
1969
2124
  */
1970
- rmCustomDoc: rmCustomDoc(join16(path6, "docs")),
2125
+ rmCustomDoc: rmCustomDoc(join18(path7, "docs")),
1971
2126
  /**
1972
2127
  * Dumps the catalog to a JSON file.
1973
2128
  * @param directory - The directory to dump the catalog to
1974
2129
  * @returns A JSON file with the catalog
1975
2130
  */
1976
- dumpCatalog: dumpCatalog(join16(path6)),
2131
+ dumpCatalog: dumpCatalog(join18(path7)),
1977
2132
  /**
1978
2133
  * Returns the event catalog configuration file.
1979
2134
  * The event catalog configuration file is the file that contains the configuration for the event catalog.
@@ -1981,7 +2136,7 @@ var src_default = (path6) => {
1981
2136
  * @param directory - The directory of the catalog.
1982
2137
  * @returns A JSON object with the configuration for the event catalog.
1983
2138
  */
1984
- getEventCatalogConfigurationFile: getEventCatalogConfigurationFile(join16(path6)),
2139
+ getEventCatalogConfigurationFile: getEventCatalogConfigurationFile(join18(path7)),
1985
2140
  /**
1986
2141
  * ================================
1987
2142
  * Resources Utils
@@ -2006,33 +2161,33 @@ var src_default = (path6) => {
2006
2161
  * @param path - The path to the message to retrieve
2007
2162
  * @returns Message|Undefined
2008
2163
  */
2009
- getMessageBySchemaPath: getMessageBySchemaPath(join16(path6)),
2164
+ getMessageBySchemaPath: getMessageBySchemaPath(join18(path7)),
2010
2165
  /**
2011
2166
  * Returns the producers and consumers (services) for a given message
2012
2167
  * @param id - The id of the message to get the producers and consumers for
2013
2168
  * @param version - Optional version of the message
2014
2169
  * @returns { producers: Service[], consumers: Service[] }
2015
2170
  */
2016
- getProducersAndConsumersForMessage: getProducersAndConsumersForMessage(join16(path6)),
2171
+ getProducersAndConsumersForMessage: getProducersAndConsumersForMessage(join18(path7)),
2017
2172
  /**
2018
2173
  * Returns the consumers of a given schema path
2019
2174
  * @param path - The path to the schema to get the consumers for
2020
2175
  * @returns Service[]
2021
2176
  */
2022
- getConsumersOfSchema: getConsumersOfSchema(join16(path6)),
2177
+ getConsumersOfSchema: getConsumersOfSchema(join18(path7)),
2023
2178
  /**
2024
2179
  * Returns the producers of a given schema path
2025
2180
  * @param path - The path to the schema to get the producers for
2026
2181
  * @returns Service[]
2027
2182
  */
2028
- getProducersOfSchema: getProducersOfSchema(join16(path6)),
2183
+ getProducersOfSchema: getProducersOfSchema(join18(path7)),
2029
2184
  /**
2030
2185
  * Returns the owners for a given resource (e.g domain, service, event, command, query, etc.)
2031
2186
  * @param id - The id of the resource to get the owners for
2032
2187
  * @param version - Optional version of the resource
2033
2188
  * @returns { owners: User[] }
2034
2189
  */
2035
- getOwnersForResource: getOwnersForResource(join16(path6)),
2190
+ getOwnersForResource: getOwnersForResource(join18(path7)),
2036
2191
  /**
2037
2192
  * ================================
2038
2193
  * Entities
@@ -2044,13 +2199,13 @@ var src_default = (path6) => {
2044
2199
  * @param version - Optional id of the version to get (supports semver)
2045
2200
  * @returns Entity|Undefined
2046
2201
  */
2047
- getEntity: getEntity(join16(path6)),
2202
+ getEntity: getEntity(join18(path7)),
2048
2203
  /**
2049
2204
  * Returns all entities from EventCatalog
2050
2205
  * @param latestOnly - optional boolean, set to true to get only latest versions
2051
2206
  * @returns Entity[]|Undefined
2052
2207
  */
2053
- getEntities: getEntities(join16(path6)),
2208
+ getEntities: getEntities(join18(path7)),
2054
2209
  /**
2055
2210
  * Adds an entity to EventCatalog
2056
2211
  *
@@ -2058,33 +2213,33 @@ var src_default = (path6) => {
2058
2213
  * @param options - Optional options to write the entity
2059
2214
  *
2060
2215
  */
2061
- writeEntity: writeEntity(join16(path6, "entities")),
2216
+ writeEntity: writeEntity(join18(path7, "entities")),
2062
2217
  /**
2063
2218
  * Remove an entity from EventCatalog (modeled on the standard POSIX rm utility)
2064
2219
  *
2065
2220
  * @param path - The path to your entity, e.g. `/User`
2066
2221
  *
2067
2222
  */
2068
- rmEntity: rmEntity(join16(path6, "entities")),
2223
+ rmEntity: rmEntity(join18(path7, "entities")),
2069
2224
  /**
2070
2225
  * Remove an entity by an entity id
2071
2226
  *
2072
2227
  * @param id - The id of the entity you want to remove
2073
2228
  *
2074
2229
  */
2075
- rmEntityById: rmEntityById(join16(path6)),
2230
+ rmEntityById: rmEntityById(join18(path7)),
2076
2231
  /**
2077
2232
  * Moves a given entity id to the version directory
2078
2233
  * @param id - The id of the entity to version
2079
2234
  */
2080
- versionEntity: versionEntity(join16(path6)),
2235
+ versionEntity: versionEntity(join18(path7)),
2081
2236
  /**
2082
2237
  * Check to see if an entity version exists
2083
2238
  * @param id - The id of the entity
2084
2239
  * @param version - The version of the entity (supports semver)
2085
2240
  * @returns
2086
2241
  */
2087
- entityHasVersion: entityHasVersion(join16(path6)),
2242
+ entityHasVersion: entityHasVersion(join18(path7)),
2088
2243
  /**
2089
2244
  * ================================
2090
2245
  * Data Stores
@@ -2096,42 +2251,42 @@ var src_default = (path6) => {
2096
2251
  * @param options - Optional options to write the data store
2097
2252
  *
2098
2253
  */
2099
- writeDataStore: writeDataStore(join16(path6, "containers")),
2254
+ writeDataStore: writeDataStore(join18(path7, "containers")),
2100
2255
  /**
2101
2256
  * Returns a data store from EventCatalog
2102
2257
  * @param id - The id of the data store to retrieve
2103
2258
  * @param version - Optional id of the version to get (supports semver)
2104
2259
  * @returns Container|Undefined
2105
2260
  */
2106
- getDataStore: getDataStore(join16(path6)),
2261
+ getDataStore: getDataStore(join18(path7)),
2107
2262
  /**
2108
2263
  * Returns all data stores from EventCatalog
2109
2264
  * @param latestOnly - optional boolean, set to true to get only latest versions
2110
2265
  * @returns Container[]|Undefined
2111
2266
  */
2112
- getDataStores: getDataStores(join16(path6)),
2267
+ getDataStores: getDataStores(join18(path7)),
2113
2268
  /**
2114
2269
  * Version a data store by its id
2115
2270
  * @param id - The id of the data store to version
2116
2271
  */
2117
- versionDataStore: versionDataStore(join16(path6, "containers")),
2272
+ versionDataStore: versionDataStore(join18(path7, "containers")),
2118
2273
  /**
2119
2274
  * Remove a data store by its path
2120
2275
  * @param path - The path to the data store to remove
2121
2276
  */
2122
- rmDataStore: rmDataStore(join16(path6, "containers")),
2277
+ rmDataStore: rmDataStore(join18(path7, "containers")),
2123
2278
  /**
2124
2279
  * Remove a data store by its id
2125
2280
  * @param id - The id of the data store to remove
2126
2281
  */
2127
- rmDataStoreById: rmDataStoreById(join16(path6)),
2282
+ rmDataStoreById: rmDataStoreById(join18(path7)),
2128
2283
  /**
2129
2284
  * Check to see if a data store version exists
2130
2285
  * @param id - The id of the data store
2131
2286
  * @param version - The version of the data store (supports semver)
2132
2287
  * @returns
2133
2288
  */
2134
- dataStoreHasVersion: dataStoreHasVersion(join16(path6)),
2289
+ dataStoreHasVersion: dataStoreHasVersion(join18(path7)),
2135
2290
  /**
2136
2291
  * Adds a file to a data store by its id
2137
2292
  * @param id - The id of the data store to add the file to
@@ -2139,14 +2294,14 @@ var src_default = (path6) => {
2139
2294
  * @param version - Optional version of the data store to add the file to
2140
2295
  * @returns
2141
2296
  */
2142
- addFileToDataStore: addFileToDataStore(join16(path6)),
2297
+ addFileToDataStore: addFileToDataStore(join18(path7)),
2143
2298
  /**
2144
2299
  * Writes a data store to a service by its id
2145
2300
  * @param dataStore - The data store to write
2146
2301
  * @param service - The service to write the data store to
2147
2302
  * @returns
2148
2303
  */
2149
- writeDataStoreToService: writeDataStoreToService(join16(path6)),
2304
+ writeDataStoreToService: writeDataStoreToService(join18(path7)),
2150
2305
  /**
2151
2306
  * ================================
2152
2307
  * Data Products
@@ -2158,7 +2313,7 @@ var src_default = (path6) => {
2158
2313
  * @param options - Optional options to write the data product
2159
2314
  *
2160
2315
  */
2161
- writeDataProduct: writeDataProduct(join16(path6, "data-products")),
2316
+ writeDataProduct: writeDataProduct(join18(path7, "data-products")),
2162
2317
  /**
2163
2318
  * Writes a data product to a domain in EventCatalog
2164
2319
  * @param dataProduct - The data product to write
@@ -2166,43 +2321,43 @@ var src_default = (path6) => {
2166
2321
  * @param options - Optional options to write the data product
2167
2322
  *
2168
2323
  */
2169
- writeDataProductToDomain: writeDataProductToDomain(join16(path6, "domains")),
2324
+ writeDataProductToDomain: writeDataProductToDomain(join18(path7, "domains")),
2170
2325
  /**
2171
2326
  * Returns a data product from EventCatalog
2172
2327
  * @param id - The id of the data product to retrieve
2173
2328
  * @param version - Optional id of the version to get (supports semver)
2174
2329
  * @returns DataProduct|Undefined
2175
2330
  */
2176
- getDataProduct: getDataProduct(join16(path6)),
2331
+ getDataProduct: getDataProduct(join18(path7)),
2177
2332
  /**
2178
2333
  * Returns all data products from EventCatalog
2179
2334
  * @param latestOnly - optional boolean, set to true to get only latest versions
2180
2335
  * @returns DataProduct[]|Undefined
2181
2336
  */
2182
- getDataProducts: getDataProducts(join16(path6)),
2337
+ getDataProducts: getDataProducts(join18(path7)),
2183
2338
  /**
2184
2339
  * Version a data product by its id
2185
2340
  * @param id - The id of the data product to version
2186
2341
  */
2187
- versionDataProduct: versionDataProduct(join16(path6)),
2342
+ versionDataProduct: versionDataProduct(join18(path7)),
2188
2343
  /**
2189
2344
  * Remove a data product by its path
2190
2345
  * @param path - The path to the data product to remove
2191
2346
  */
2192
- rmDataProduct: rmDataProduct(join16(path6, "data-products")),
2347
+ rmDataProduct: rmDataProduct(join18(path7, "data-products")),
2193
2348
  /**
2194
2349
  * Remove a data product by its id
2195
2350
  * @param id - The id of the data product to remove
2196
2351
  * @param version - Optional version of the data product to remove
2197
2352
  */
2198
- rmDataProductById: rmDataProductById(join16(path6)),
2353
+ rmDataProductById: rmDataProductById(join18(path7)),
2199
2354
  /**
2200
2355
  * Check to see if a data product version exists
2201
2356
  * @param id - The id of the data product
2202
2357
  * @param version - The version of the data product (supports semver)
2203
2358
  * @returns
2204
2359
  */
2205
- dataProductHasVersion: dataProductHasVersion(join16(path6)),
2360
+ dataProductHasVersion: dataProductHasVersion(join18(path7)),
2206
2361
  /**
2207
2362
  * Adds a file to a data product by its id
2208
2363
  * @param id - The id of the data product to add the file to
@@ -2210,7 +2365,7 @@ var src_default = (path6) => {
2210
2365
  * @param version - Optional version of the data product to add the file to
2211
2366
  * @returns
2212
2367
  */
2213
- addFileToDataProduct: addFileToDataProduct(join16(path6)),
2368
+ addFileToDataProduct: addFileToDataProduct(join18(path7)),
2214
2369
  /**
2215
2370
  * Adds a data product to a domain
2216
2371
  * @param id - The id of the domain
@@ -2218,106 +2373,181 @@ var src_default = (path6) => {
2218
2373
  * @param version - (Optional) The version of the domain to add the data product to
2219
2374
  * @returns
2220
2375
  */
2221
- addDataProductToDomain: addDataProductToDomain(join16(path6, "domains"))
2376
+ addDataProductToDomain: addDataProductToDomain(join18(path7, "domains")),
2377
+ /**
2378
+ * ================================
2379
+ * Diagrams
2380
+ * ================================
2381
+ */
2382
+ /**
2383
+ * Returns a diagram from EventCatalog
2384
+ * @param id - The id of the diagram to retrieve
2385
+ * @param version - Optional id of the version to get (supports semver)
2386
+ * @returns Diagram|Undefined
2387
+ */
2388
+ getDiagram: getDiagram(join18(path7)),
2389
+ /**
2390
+ * Returns all diagrams from EventCatalog
2391
+ * @param latestOnly - optional boolean, set to true to get only latest versions
2392
+ * @returns Diagram[]|Undefined
2393
+ */
2394
+ getDiagrams: getDiagrams(join18(path7)),
2395
+ /**
2396
+ * Adds a diagram to EventCatalog
2397
+ *
2398
+ * @param diagram - The diagram to write
2399
+ * @param options - Optional options to write the diagram
2400
+ *
2401
+ */
2402
+ writeDiagram: writeDiagram(join18(path7, "diagrams")),
2403
+ /**
2404
+ * Remove a diagram from EventCatalog (modeled on the standard POSIX rm utility)
2405
+ *
2406
+ * @param path - The path to your diagram, e.g. `/ArchitectureDiagram`
2407
+ *
2408
+ */
2409
+ rmDiagram: rmDiagram(join18(path7, "diagrams")),
2410
+ /**
2411
+ * Remove a diagram by a diagram id
2412
+ *
2413
+ * @param id - The id of the diagram you want to remove
2414
+ *
2415
+ */
2416
+ rmDiagramById: rmDiagramById(join18(path7)),
2417
+ /**
2418
+ * Moves a given diagram id to the version directory
2419
+ * @param id - The id of the diagram to version
2420
+ */
2421
+ versionDiagram: versionDiagram(join18(path7)),
2422
+ /**
2423
+ * Check to see if a diagram version exists
2424
+ * @param id - The id of the diagram
2425
+ * @param version - The version of the diagram (supports semver)
2426
+ * @returns
2427
+ */
2428
+ diagramHasVersion: diagramHasVersion(join18(path7)),
2429
+ /**
2430
+ * Adds a file to the given diagram
2431
+ * @param id - The id of the diagram to add the file to
2432
+ * @param file - File contents to add including the content and the file name
2433
+ * @param version - Optional version of the diagram to add the file to
2434
+ * @returns
2435
+ */
2436
+ addFileToDiagram: addFileToDiagram(join18(path7))
2222
2437
  };
2223
2438
  };
2224
2439
 
2225
- // src/eventcatalog.ts
2226
- var DUMP_VERSION = "0.0.1";
2227
- var getEventCatalogVersion = async (catalogDir) => {
2440
+ // src/cli/executor.ts
2441
+ async function executeFunction(catalogDir, functionName, rawArgs) {
2442
+ if (!existsSync(catalogDir)) {
2443
+ throw new Error(`Catalog directory not found: ${catalogDir}`);
2444
+ }
2445
+ const sdk = src_default(catalogDir);
2446
+ if (!(functionName in sdk)) {
2447
+ throw new Error(`Function '${functionName}' not found. Use 'eventcatalog list' to see available functions.`);
2448
+ }
2449
+ const fn = sdk[functionName];
2450
+ if (typeof fn !== "function") {
2451
+ throw new Error(`'${functionName}' is not a callable function.`);
2452
+ }
2453
+ const parsedArgs = parseArguments(rawArgs);
2228
2454
  try {
2229
- const packageJson = fs13.readFileSync(join17(catalogDir, "package.json"), "utf8");
2230
- const packageJsonObject = JSON.parse(packageJson);
2231
- return packageJsonObject["dependencies"]["@eventcatalog/core"];
2455
+ return await fn(...parsedArgs);
2232
2456
  } catch (error) {
2233
- return "unknown";
2457
+ throw new Error(`Error executing '${functionName}': ${error instanceof Error ? error.message : String(error)}`);
2234
2458
  }
2235
- };
2236
- var hydrateResource = async (catalogDir, resources = [], { attachSchema = false } = {}) => {
2237
- return await Promise.all(
2238
- resources.map(async (resource) => {
2239
- const resourcePath = await getResourcePath(catalogDir, resource.id, resource.version);
2240
- let schema = "";
2241
- if (resource.schemaPath && resourcePath?.fullPath) {
2242
- const pathToSchema = path5.join(path5.dirname(resourcePath?.fullPath), resource.schemaPath);
2243
- if (fs13.existsSync(pathToSchema)) {
2244
- schema = fs13.readFileSync(pathToSchema, "utf8");
2245
- }
2246
- }
2247
- const eventcatalog = schema ? { directory: resourcePath?.directory, schema } : { directory: resourcePath?.directory };
2248
- return {
2249
- ...resource,
2250
- _eventcatalog: eventcatalog
2251
- };
2252
- })
2253
- );
2254
- };
2255
- var filterCollection = (collection, options) => {
2256
- return collection.map((item) => ({
2257
- ...item,
2258
- markdown: options?.includeMarkdown ? item.markdown : void 0
2259
- }));
2260
- };
2261
- var getEventCatalogConfigurationFile = (directory) => async () => {
2459
+ }
2460
+
2461
+ // src/cli/list.ts
2462
+ function listFunctions(catalogDir = ".") {
2463
+ const sdk = src_default(catalogDir);
2464
+ const functionNames = Object.keys(sdk).filter((key) => typeof sdk[key] === "function");
2465
+ const categories = {
2466
+ Events: [],
2467
+ Commands: [],
2468
+ Queries: [],
2469
+ Channels: [],
2470
+ Services: [],
2471
+ Domains: [],
2472
+ Entities: [],
2473
+ DataStores: [],
2474
+ DataProducts: [],
2475
+ Teams: [],
2476
+ Users: [],
2477
+ "Custom Docs": [],
2478
+ Messages: [],
2479
+ Utilities: []
2480
+ };
2481
+ functionNames.forEach((name) => {
2482
+ if (name.includes("Event")) categories["Events"].push(name);
2483
+ else if (name.includes("Command")) categories["Commands"].push(name);
2484
+ else if (name.includes("Query")) categories["Queries"].push(name);
2485
+ else if (name.includes("Channel")) categories["Channels"].push(name);
2486
+ else if (name.includes("Service")) categories["Services"].push(name);
2487
+ else if (name.includes("Domain")) categories["Domains"].push(name);
2488
+ else if (name.includes("Entity")) categories["Entities"].push(name);
2489
+ else if (name.includes("DataStore")) categories["DataStores"].push(name);
2490
+ else if (name.includes("DataProduct")) categories["DataProducts"].push(name);
2491
+ else if (name.includes("Team")) categories["Teams"].push(name);
2492
+ else if (name.includes("User")) categories["Users"].push(name);
2493
+ else if (name.includes("CustomDoc")) categories["Custom Docs"].push(name);
2494
+ else if (name.includes("Message") || name.includes("Producers") || name.includes("Consumers"))
2495
+ categories["Messages"].push(name);
2496
+ else categories["Utilities"].push(name);
2497
+ });
2498
+ Object.keys(categories).forEach((key) => {
2499
+ if (categories[key].length === 0) {
2500
+ delete categories[key];
2501
+ }
2502
+ });
2503
+ return categories;
2504
+ }
2505
+ function formatListOutput(functions) {
2506
+ let output = "Available EventCatalog SDK Functions:\n\n";
2507
+ Object.entries(functions).forEach(([category, names]) => {
2508
+ output += `${category}:
2509
+ `;
2510
+ names.sort().forEach((name) => {
2511
+ output += ` - ${name}
2512
+ `;
2513
+ });
2514
+ output += "\n";
2515
+ });
2516
+ return output;
2517
+ }
2518
+
2519
+ // src/cli/index.ts
2520
+ var version = "1.0.0";
2521
+ try {
2522
+ const packageJsonPath = resolve2(__dirname, "../../package.json");
2523
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
2524
+ version = packageJson.version;
2525
+ } catch {
2526
+ }
2527
+ program.name("eventcatalog").description("EventCatalog SDK Command-Line Interface").version(version).option("-d, --dir <path>", "Path to the EventCatalog directory (default: current directory)", ".");
2528
+ program.command("list").description("List all available SDK functions").action(() => {
2262
2529
  try {
2263
- const path6 = join17(directory, "eventcatalog.config.js");
2264
- const configModule = await import(path6);
2265
- return configModule.default;
2530
+ const functions = listFunctions(".");
2531
+ const output = formatListOutput(functions);
2532
+ console.log(output);
2266
2533
  } catch (error) {
2267
- console.error("Error getting event catalog configuration file", error);
2268
- return null;
2534
+ console.error("Error listing functions:", error instanceof Error ? error.message : String(error));
2535
+ process.exit(1);
2269
2536
  }
2270
- };
2271
- var dumpCatalog = (directory) => async (options) => {
2272
- const { getDomains: getDomains2, getServices: getServices2, getEvents: getEvents2, getQueries: getQueries2, getCommands: getCommands2, getChannels: getChannels2, getTeams: getTeams2, getUsers: getUsers3 } = src_default(directory);
2273
- const { includeMarkdown = true } = options || {};
2274
- const domains = await getDomains2();
2275
- const services = await getServices2();
2276
- const events = await getEvents2();
2277
- const commands = await getCommands2();
2278
- const queries = await getQueries2();
2279
- const teams = await getTeams2();
2280
- const users = await getUsers3();
2281
- const channels = await getChannels2();
2282
- const [
2283
- hydratedDomains,
2284
- hydratedServices,
2285
- hydratedEvents,
2286
- hydratedQueries,
2287
- hydratedCommands,
2288
- hydratedTeams,
2289
- hydratedUsers,
2290
- hydratedChannels
2291
- ] = await Promise.all([
2292
- hydrateResource(directory, domains),
2293
- hydrateResource(directory, services),
2294
- hydrateResource(directory, events),
2295
- hydrateResource(directory, queries),
2296
- hydrateResource(directory, commands),
2297
- hydrateResource(directory, teams),
2298
- hydrateResource(directory, users),
2299
- hydrateResource(directory, channels)
2300
- ]);
2301
- return {
2302
- version: DUMP_VERSION,
2303
- catalogVersion: await getEventCatalogVersion(directory),
2304
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2305
- resources: {
2306
- domains: filterCollection(hydratedDomains, { includeMarkdown }),
2307
- services: filterCollection(hydratedServices, { includeMarkdown }),
2308
- messages: {
2309
- events: filterCollection(hydratedEvents, { includeMarkdown }),
2310
- queries: filterCollection(hydratedQueries, { includeMarkdown }),
2311
- commands: filterCollection(hydratedCommands, { includeMarkdown })
2312
- },
2313
- teams: filterCollection(hydratedTeams, { includeMarkdown }),
2314
- users: filterCollection(hydratedUsers, { includeMarkdown }),
2315
- channels: filterCollection(hydratedChannels, { includeMarkdown })
2316
- }
2317
- };
2318
- };
2319
- export {
2320
- dumpCatalog,
2321
- getEventCatalogConfigurationFile
2322
- };
2323
- //# sourceMappingURL=eventcatalog.mjs.map
2537
+ });
2538
+ program.arguments("<function> [args...]").action(async (functionName, args) => {
2539
+ try {
2540
+ const options = program.opts();
2541
+ const dir = options.dir || ".";
2542
+ const result = await executeFunction(dir, functionName, args);
2543
+ console.log(JSON.stringify(result, null, 0));
2544
+ } catch (error) {
2545
+ console.error(error instanceof Error ? error.message : String(error));
2546
+ process.exit(1);
2547
+ }
2548
+ });
2549
+ program.parse(process.argv);
2550
+ if (process.argv.length < 3) {
2551
+ program.outputHelp();
2552
+ }
2553
+ //# sourceMappingURL=index.mjs.map