@eventcatalog/sdk 2.11.0 → 2.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/README.md +86 -1
  2. package/dist/cli/index.d.mts +1 -0
  3. package/dist/cli/index.d.ts +1 -0
  4. package/dist/{eventcatalog.js → cli/index.js} +505 -378
  5. package/dist/cli/index.js.map +1 -0
  6. package/dist/{eventcatalog.mjs → cli/index.mjs} +583 -436
  7. package/dist/cli/index.mjs.map +1 -0
  8. package/dist/cli-docs.d.mts +43 -0
  9. package/dist/cli-docs.d.ts +43 -0
  10. package/dist/cli-docs.js +1513 -0
  11. package/dist/cli-docs.js.map +1 -0
  12. package/dist/cli-docs.mjs +1485 -0
  13. package/dist/cli-docs.mjs.map +1 -0
  14. package/dist/index.d.mts +330 -3
  15. package/dist/index.d.ts +330 -3
  16. package/package.json +13 -4
  17. package/dist/channels.d.mts +0 -214
  18. package/dist/channels.d.ts +0 -214
  19. package/dist/channels.js +0 -432
  20. package/dist/channels.js.map +0 -1
  21. package/dist/channels.mjs +0 -384
  22. package/dist/channels.mjs.map +0 -1
  23. package/dist/commands.d.mts +0 -274
  24. package/dist/commands.d.ts +0 -274
  25. package/dist/commands.js +0 -394
  26. package/dist/commands.js.map +0 -1
  27. package/dist/commands.mjs +0 -350
  28. package/dist/commands.mjs.map +0 -1
  29. package/dist/containers.d.mts +0 -179
  30. package/dist/containers.d.ts +0 -179
  31. package/dist/containers.js +0 -388
  32. package/dist/containers.js.map +0 -1
  33. package/dist/containers.mjs +0 -345
  34. package/dist/containers.mjs.map +0 -1
  35. package/dist/custom-docs.d.mts +0 -89
  36. package/dist/custom-docs.d.ts +0 -89
  37. package/dist/custom-docs.js +0 -164
  38. package/dist/custom-docs.js.map +0 -1
  39. package/dist/custom-docs.mjs +0 -122
  40. package/dist/custom-docs.mjs.map +0 -1
  41. package/dist/data-products.d.mts +0 -225
  42. package/dist/data-products.d.ts +0 -225
  43. package/dist/data-products.js +0 -375
  44. package/dist/data-products.js.map +0 -1
  45. package/dist/data-products.mjs +0 -332
  46. package/dist/data-products.mjs.map +0 -1
  47. package/dist/data-stores.d.mts +0 -179
  48. package/dist/data-stores.d.ts +0 -179
  49. package/dist/data-stores.js +0 -401
  50. package/dist/data-stores.js.map +0 -1
  51. package/dist/data-stores.mjs +0 -356
  52. package/dist/data-stores.mjs.map +0 -1
  53. package/dist/domains.d.mts +0 -347
  54. package/dist/domains.d.ts +0 -347
  55. package/dist/domains.js +0 -547
  56. package/dist/domains.js.map +0 -1
  57. package/dist/domains.mjs +0 -498
  58. package/dist/domains.mjs.map +0 -1
  59. package/dist/entities.d.mts +0 -174
  60. package/dist/entities.d.ts +0 -174
  61. package/dist/entities.js +0 -348
  62. package/dist/entities.js.map +0 -1
  63. package/dist/entities.mjs +0 -307
  64. package/dist/entities.mjs.map +0 -1
  65. package/dist/eventcatalog.d.mts +0 -21
  66. package/dist/eventcatalog.d.ts +0 -21
  67. package/dist/eventcatalog.js.map +0 -1
  68. package/dist/eventcatalog.mjs.map +0 -1
  69. package/dist/events.d.mts +0 -276
  70. package/dist/events.d.ts +0 -276
  71. package/dist/events.js +0 -393
  72. package/dist/events.js.map +0 -1
  73. package/dist/events.mjs +0 -349
  74. package/dist/events.mjs.map +0 -1
  75. package/dist/messages.d.mts +0 -65
  76. package/dist/messages.d.ts +0 -65
  77. package/dist/messages.js +0 -312
  78. package/dist/messages.js.map +0 -1
  79. package/dist/messages.mjs +0 -269
  80. package/dist/messages.mjs.map +0 -1
  81. package/dist/queries.d.mts +0 -276
  82. package/dist/queries.d.ts +0 -276
  83. package/dist/queries.js +0 -394
  84. package/dist/queries.js.map +0 -1
  85. package/dist/queries.mjs +0 -350
  86. package/dist/queries.mjs.map +0 -1
  87. package/dist/services.d.mts +0 -384
  88. package/dist/services.d.ts +0 -384
  89. package/dist/services.js +0 -577
  90. package/dist/services.js.map +0 -1
  91. package/dist/services.mjs +0 -526
  92. package/dist/services.mjs.map +0 -1
  93. package/dist/teams.d.mts +0 -90
  94. package/dist/teams.d.ts +0 -90
  95. package/dist/teams.js +0 -246
  96. package/dist/teams.js.map +0 -1
  97. package/dist/teams.mjs +0 -202
  98. package/dist/teams.mjs.map +0 -1
  99. package/dist/types.d.d.mts +0 -331
  100. package/dist/types.d.d.ts +0 -331
  101. package/dist/types.d.js +0 -19
  102. package/dist/types.d.js.map +0 -1
  103. package/dist/types.d.mjs +0 -1
  104. package/dist/types.d.mjs.map +0 -1
  105. package/dist/users.d.mts +0 -83
  106. package/dist/users.d.ts +0 -83
  107. package/dist/users.js +0 -127
  108. package/dist/users.js.map +0 -1
  109. package/dist/users.mjs +0 -88
  110. package/dist/users.mjs.map +0 -1
@@ -1,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 join17 } 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,24 @@ 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);
1187
1319
 
1188
1320
  // src/index.ts
1189
- var src_default = (path6) => {
1321
+ var src_default = (path7) => {
1190
1322
  return {
1191
1323
  /**
1192
1324
  * Returns an events from EventCatalog
@@ -1194,13 +1326,13 @@ var src_default = (path6) => {
1194
1326
  * @param version - Optional id of the version to get (supports semver)
1195
1327
  * @returns Event|Undefined
1196
1328
  */
1197
- getEvent: getEvent(join16(path6)),
1329
+ getEvent: getEvent(join17(path7)),
1198
1330
  /**
1199
1331
  * Returns all events from EventCatalog
1200
1332
  * @param latestOnly - optional boolean, set to true to get only latest versions
1201
1333
  * @returns Event[]|Undefined
1202
1334
  */
1203
- getEvents: getEvents(join16(path6)),
1335
+ getEvents: getEvents(join17(path7)),
1204
1336
  /**
1205
1337
  * Adds an event to EventCatalog
1206
1338
  *
@@ -1208,7 +1340,7 @@ var src_default = (path6) => {
1208
1340
  * @param options - Optional options to write the event
1209
1341
  *
1210
1342
  */
1211
- writeEvent: writeEvent(join16(path6, "events")),
1343
+ writeEvent: writeEvent(join17(path7, "events")),
1212
1344
  /**
1213
1345
  * Adds an event to a service in EventCatalog
1214
1346
  *
@@ -1217,26 +1349,26 @@ var src_default = (path6) => {
1217
1349
  * @param options - Optional options to write the event
1218
1350
  *
1219
1351
  */
1220
- writeEventToService: writeEventToService(join16(path6)),
1352
+ writeEventToService: writeEventToService(join17(path7)),
1221
1353
  /**
1222
1354
  * Remove an event to EventCatalog (modeled on the standard POSIX rm utility)
1223
1355
  *
1224
1356
  * @param path - The path to your event, e.g. `/Inventory/InventoryAdjusted`
1225
1357
  *
1226
1358
  */
1227
- rmEvent: rmEvent(join16(path6, "events")),
1359
+ rmEvent: rmEvent(join17(path7, "events")),
1228
1360
  /**
1229
1361
  * Remove an event by an Event id
1230
1362
  *
1231
1363
  * @param id - The id of the event you want to remove
1232
1364
  *
1233
1365
  */
1234
- rmEventById: rmEventById(join16(path6)),
1366
+ rmEventById: rmEventById(join17(path7)),
1235
1367
  /**
1236
1368
  * Moves a given event id to the version directory
1237
1369
  * @param directory
1238
1370
  */
1239
- versionEvent: versionEvent(join16(path6)),
1371
+ versionEvent: versionEvent(join17(path7)),
1240
1372
  /**
1241
1373
  * Adds a file to the given event
1242
1374
  * @param id - The id of the event to add the file to
@@ -1244,7 +1376,7 @@ var src_default = (path6) => {
1244
1376
  * @param version - Optional version of the event to add the file to
1245
1377
  * @returns
1246
1378
  */
1247
- addFileToEvent: addFileToEvent(join16(path6)),
1379
+ addFileToEvent: addFileToEvent(join17(path7)),
1248
1380
  /**
1249
1381
  * Adds a schema to the given event
1250
1382
  * @param id - The id of the event to add the schema to
@@ -1252,14 +1384,14 @@ var src_default = (path6) => {
1252
1384
  * @param version - Optional version of the event to add the schema to
1253
1385
  * @returns
1254
1386
  */
1255
- addSchemaToEvent: addSchemaToEvent(join16(path6)),
1387
+ addSchemaToEvent: addSchemaToEvent(join17(path7)),
1256
1388
  /**
1257
1389
  * Check to see if an event version exists
1258
1390
  * @param id - The id of the event
1259
1391
  * @param version - The version of the event (supports semver)
1260
1392
  * @returns
1261
1393
  */
1262
- eventHasVersion: eventHasVersion(join16(path6)),
1394
+ eventHasVersion: eventHasVersion(join17(path7)),
1263
1395
  /**
1264
1396
  * ================================
1265
1397
  * Commands
@@ -1271,13 +1403,13 @@ var src_default = (path6) => {
1271
1403
  * @param version - Optional id of the version to get (supports semver)
1272
1404
  * @returns Command|Undefined
1273
1405
  */
1274
- getCommand: getCommand(join16(path6)),
1406
+ getCommand: getCommand(join17(path7)),
1275
1407
  /**
1276
1408
  * Returns all commands from EventCatalog
1277
1409
  * @param latestOnly - optional boolean, set to true to get only latest versions
1278
1410
  * @returns Command[]|Undefined
1279
1411
  */
1280
- getCommands: getCommands(join16(path6)),
1412
+ getCommands: getCommands(join17(path7)),
1281
1413
  /**
1282
1414
  * Adds an command to EventCatalog
1283
1415
  *
@@ -1285,7 +1417,7 @@ var src_default = (path6) => {
1285
1417
  * @param options - Optional options to write the command
1286
1418
  *
1287
1419
  */
1288
- writeCommand: writeCommand(join16(path6, "commands")),
1420
+ writeCommand: writeCommand(join17(path7, "commands")),
1289
1421
  /**
1290
1422
  * Adds a command to a service in EventCatalog
1291
1423
  *
@@ -1294,26 +1426,26 @@ var src_default = (path6) => {
1294
1426
  * @param options - Optional options to write the command
1295
1427
  *
1296
1428
  */
1297
- writeCommandToService: writeCommandToService(join16(path6)),
1429
+ writeCommandToService: writeCommandToService(join17(path7)),
1298
1430
  /**
1299
1431
  * Remove an command to EventCatalog (modeled on the standard POSIX rm utility)
1300
1432
  *
1301
1433
  * @param path - The path to your command, e.g. `/Inventory/InventoryAdjusted`
1302
1434
  *
1303
1435
  */
1304
- rmCommand: rmCommand(join16(path6, "commands")),
1436
+ rmCommand: rmCommand(join17(path7, "commands")),
1305
1437
  /**
1306
1438
  * Remove an command by an Event id
1307
1439
  *
1308
1440
  * @param id - The id of the command you want to remove
1309
1441
  *
1310
1442
  */
1311
- rmCommandById: rmCommandById(join16(path6)),
1443
+ rmCommandById: rmCommandById(join17(path7)),
1312
1444
  /**
1313
1445
  * Moves a given command id to the version directory
1314
1446
  * @param directory
1315
1447
  */
1316
- versionCommand: versionCommand(join16(path6)),
1448
+ versionCommand: versionCommand(join17(path7)),
1317
1449
  /**
1318
1450
  * Adds a file to the given command
1319
1451
  * @param id - The id of the command to add the file to
@@ -1321,7 +1453,7 @@ var src_default = (path6) => {
1321
1453
  * @param version - Optional version of the command to add the file to
1322
1454
  * @returns
1323
1455
  */
1324
- addFileToCommand: addFileToCommand(join16(path6)),
1456
+ addFileToCommand: addFileToCommand(join17(path7)),
1325
1457
  /**
1326
1458
  * Adds a schema to the given command
1327
1459
  * @param id - The id of the command to add the schema to
@@ -1329,14 +1461,14 @@ var src_default = (path6) => {
1329
1461
  * @param version - Optional version of the command to add the schema to
1330
1462
  * @returns
1331
1463
  */
1332
- addSchemaToCommand: addSchemaToCommand(join16(path6)),
1464
+ addSchemaToCommand: addSchemaToCommand(join17(path7)),
1333
1465
  /**
1334
1466
  * Check to see if a command version exists
1335
1467
  * @param id - The id of the command
1336
1468
  * @param version - The version of the command (supports semver)
1337
1469
  * @returns
1338
1470
  */
1339
- commandHasVersion: commandHasVersion(join16(path6)),
1471
+ commandHasVersion: commandHasVersion(join17(path7)),
1340
1472
  /**
1341
1473
  * ================================
1342
1474
  * Queries
@@ -1348,13 +1480,13 @@ var src_default = (path6) => {
1348
1480
  * @param version - Optional id of the version to get (supports semver)
1349
1481
  * @returns Query|Undefined
1350
1482
  */
1351
- getQuery: getQuery(join16(path6)),
1483
+ getQuery: getQuery(join17(path7)),
1352
1484
  /**
1353
1485
  * Returns all queries from EventCatalog
1354
1486
  * @param latestOnly - optional boolean, set to true to get only latest versions
1355
1487
  * @returns Query[]|Undefined
1356
1488
  */
1357
- getQueries: getQueries(join16(path6)),
1489
+ getQueries: getQueries(join17(path7)),
1358
1490
  /**
1359
1491
  * Adds a query to EventCatalog
1360
1492
  *
@@ -1362,7 +1494,7 @@ var src_default = (path6) => {
1362
1494
  * @param options - Optional options to write the event
1363
1495
  *
1364
1496
  */
1365
- writeQuery: writeQuery(join16(path6, "queries")),
1497
+ writeQuery: writeQuery(join17(path7, "queries")),
1366
1498
  /**
1367
1499
  * Adds a query to a service in EventCatalog
1368
1500
  *
@@ -1371,26 +1503,26 @@ var src_default = (path6) => {
1371
1503
  * @param options - Optional options to write the query
1372
1504
  *
1373
1505
  */
1374
- writeQueryToService: writeQueryToService(join16(path6)),
1506
+ writeQueryToService: writeQueryToService(join17(path7)),
1375
1507
  /**
1376
1508
  * Remove an query to EventCatalog (modeled on the standard POSIX rm utility)
1377
1509
  *
1378
1510
  * @param path - The path to your query, e.g. `/Orders/GetOrder`
1379
1511
  *
1380
1512
  */
1381
- rmQuery: rmQuery(join16(path6, "queries")),
1513
+ rmQuery: rmQuery(join17(path7, "queries")),
1382
1514
  /**
1383
1515
  * Remove a query by a Query id
1384
1516
  *
1385
1517
  * @param id - The id of the query you want to remove
1386
1518
  *
1387
1519
  */
1388
- rmQueryById: rmQueryById(join16(path6)),
1520
+ rmQueryById: rmQueryById(join17(path7)),
1389
1521
  /**
1390
1522
  * Moves a given query id to the version directory
1391
1523
  * @param directory
1392
1524
  */
1393
- versionQuery: versionQuery(join16(path6)),
1525
+ versionQuery: versionQuery(join17(path7)),
1394
1526
  /**
1395
1527
  * Adds a file to the given query
1396
1528
  * @param id - The id of the query to add the file to
@@ -1398,7 +1530,7 @@ var src_default = (path6) => {
1398
1530
  * @param version - Optional version of the query to add the file to
1399
1531
  * @returns
1400
1532
  */
1401
- addFileToQuery: addFileToQuery(join16(path6)),
1533
+ addFileToQuery: addFileToQuery(join17(path7)),
1402
1534
  /**
1403
1535
  * Adds a schema to the given query
1404
1536
  * @param id - The id of the query to add the schema to
@@ -1406,14 +1538,14 @@ var src_default = (path6) => {
1406
1538
  * @param version - Optional version of the query to add the schema to
1407
1539
  * @returns
1408
1540
  */
1409
- addSchemaToQuery: addSchemaToQuery(join16(path6)),
1541
+ addSchemaToQuery: addSchemaToQuery(join17(path7)),
1410
1542
  /**
1411
1543
  * Check to see if an query version exists
1412
1544
  * @param id - The id of the query
1413
1545
  * @param version - The version of the query (supports semver)
1414
1546
  * @returns
1415
1547
  */
1416
- queryHasVersion: queryHasVersion(join16(path6)),
1548
+ queryHasVersion: queryHasVersion(join17(path7)),
1417
1549
  /**
1418
1550
  * ================================
1419
1551
  * Channels
@@ -1425,13 +1557,13 @@ var src_default = (path6) => {
1425
1557
  * @param version - Optional id of the version to get (supports semver)
1426
1558
  * @returns Channel|Undefined
1427
1559
  */
1428
- getChannel: getChannel(join16(path6)),
1560
+ getChannel: getChannel(join17(path7)),
1429
1561
  /**
1430
1562
  * Returns all channels from EventCatalog
1431
1563
  * @param latestOnly - optional boolean, set to true to get only latest versions
1432
1564
  * @returns Channel[]|Undefined
1433
1565
  */
1434
- getChannels: getChannels(join16(path6)),
1566
+ getChannels: getChannels(join17(path7)),
1435
1567
  /**
1436
1568
  * Adds an channel to EventCatalog
1437
1569
  *
@@ -1439,33 +1571,33 @@ var src_default = (path6) => {
1439
1571
  * @param options - Optional options to write the channel
1440
1572
  *
1441
1573
  */
1442
- writeChannel: writeChannel(join16(path6, "channels")),
1574
+ writeChannel: writeChannel(join17(path7, "channels")),
1443
1575
  /**
1444
1576
  * Remove an channel to EventCatalog (modeled on the standard POSIX rm utility)
1445
1577
  *
1446
1578
  * @param path - The path to your channel, e.g. `/Inventory/InventoryAdjusted`
1447
1579
  *
1448
1580
  */
1449
- rmChannel: rmChannel(join16(path6, "channels")),
1581
+ rmChannel: rmChannel(join17(path7, "channels")),
1450
1582
  /**
1451
1583
  * Remove an channel by an Event id
1452
1584
  *
1453
1585
  * @param id - The id of the channel you want to remove
1454
1586
  *
1455
1587
  */
1456
- rmChannelById: rmChannelById(join16(path6)),
1588
+ rmChannelById: rmChannelById(join17(path7)),
1457
1589
  /**
1458
1590
  * Moves a given channel id to the version directory
1459
1591
  * @param directory
1460
1592
  */
1461
- versionChannel: versionChannel(join16(path6)),
1593
+ versionChannel: versionChannel(join17(path7)),
1462
1594
  /**
1463
1595
  * Check to see if a channel version exists
1464
1596
  * @param id - The id of the channel
1465
1597
  * @param version - The version of the channel (supports semver)
1466
1598
  * @returns
1467
1599
  */
1468
- channelHasVersion: channelHasVersion(join16(path6)),
1600
+ channelHasVersion: channelHasVersion(join17(path7)),
1469
1601
  /**
1470
1602
  * Add a channel to an event
1471
1603
  *
@@ -1482,7 +1614,7 @@ var src_default = (path6) => {
1482
1614
  *
1483
1615
  * ```
1484
1616
  */
1485
- addEventToChannel: addMessageToChannel(join16(path6), "events"),
1617
+ addEventToChannel: addMessageToChannel(join17(path7), "events"),
1486
1618
  /**
1487
1619
  * Add a channel to an command
1488
1620
  *
@@ -1499,7 +1631,7 @@ var src_default = (path6) => {
1499
1631
  *
1500
1632
  * ```
1501
1633
  */
1502
- addCommandToChannel: addMessageToChannel(join16(path6), "commands"),
1634
+ addCommandToChannel: addMessageToChannel(join17(path7), "commands"),
1503
1635
  /**
1504
1636
  * Add a channel to an query
1505
1637
  *
@@ -1516,7 +1648,7 @@ var src_default = (path6) => {
1516
1648
  *
1517
1649
  * ```
1518
1650
  */
1519
- addQueryToChannel: addMessageToChannel(join16(path6), "queries"),
1651
+ addQueryToChannel: addMessageToChannel(join17(path7), "queries"),
1520
1652
  /**
1521
1653
  * ================================
1522
1654
  * SERVICES
@@ -1529,14 +1661,14 @@ var src_default = (path6) => {
1529
1661
  * @param options - Optional options to write the event
1530
1662
  *
1531
1663
  */
1532
- writeService: writeService(join16(path6, "services")),
1664
+ writeService: writeService(join17(path7, "services")),
1533
1665
  /**
1534
1666
  * Adds a versioned service to EventCatalog
1535
1667
  *
1536
1668
  * @param service - The service to write
1537
1669
  *
1538
1670
  */
1539
- writeVersionedService: writeVersionedService(join16(path6, "services")),
1671
+ writeVersionedService: writeVersionedService(join17(path7, "services")),
1540
1672
  /**
1541
1673
  * Adds a service to a domain in EventCatalog
1542
1674
  *
@@ -1545,45 +1677,45 @@ var src_default = (path6) => {
1545
1677
  * @param options - Optional options to write the event
1546
1678
  *
1547
1679
  */
1548
- writeServiceToDomain: writeServiceToDomain(join16(path6, "domains")),
1680
+ writeServiceToDomain: writeServiceToDomain(join17(path7, "domains")),
1549
1681
  /**
1550
1682
  * Returns a service from EventCatalog
1551
1683
  * @param id - The id of the service to retrieve
1552
1684
  * @param version - Optional id of the version to get (supports semver)
1553
1685
  * @returns Service|Undefined
1554
1686
  */
1555
- getService: getService(join16(path6)),
1687
+ getService: getService(join17(path7)),
1556
1688
  /**
1557
1689
  * Returns a service from EventCatalog by it's path.
1558
1690
  * @param path - The path to the service to retrieve
1559
1691
  * @returns Service|Undefined
1560
1692
  */
1561
- getServiceByPath: getServiceByPath(join16(path6)),
1693
+ getServiceByPath: getServiceByPath(join17(path7)),
1562
1694
  /**
1563
1695
  * Returns all services from EventCatalog
1564
1696
  * @param latestOnly - optional boolean, set to true to get only latest versions
1565
1697
  * @returns Service[]|Undefined
1566
1698
  */
1567
- getServices: getServices(join16(path6)),
1699
+ getServices: getServices(join17(path7)),
1568
1700
  /**
1569
1701
  * Moves a given service id to the version directory
1570
1702
  * @param directory
1571
1703
  */
1572
- versionService: versionService(join16(path6)),
1704
+ versionService: versionService(join17(path7)),
1573
1705
  /**
1574
1706
  * Remove a service from EventCatalog (modeled on the standard POSIX rm utility)
1575
1707
  *
1576
1708
  * @param path - The path to your service, e.g. `/InventoryService`
1577
1709
  *
1578
1710
  */
1579
- rmService: rmService(join16(path6, "services")),
1711
+ rmService: rmService(join17(path7, "services")),
1580
1712
  /**
1581
1713
  * Remove an service by an service id
1582
1714
  *
1583
1715
  * @param id - The id of the service you want to remove
1584
1716
  *
1585
1717
  */
1586
- rmServiceById: rmServiceById(join16(path6)),
1718
+ rmServiceById: rmServiceById(join17(path7)),
1587
1719
  /**
1588
1720
  * Adds a file to the given service
1589
1721
  * @param id - The id of the service to add the file to
@@ -1591,21 +1723,21 @@ var src_default = (path6) => {
1591
1723
  * @param version - Optional version of the service to add the file to
1592
1724
  * @returns
1593
1725
  */
1594
- addFileToService: addFileToService(join16(path6)),
1726
+ addFileToService: addFileToService(join17(path7)),
1595
1727
  /**
1596
1728
  * Returns the specifications for a given service
1597
1729
  * @param id - The id of the service to retrieve the specifications for
1598
1730
  * @param version - Optional version of the service
1599
1731
  * @returns
1600
1732
  */
1601
- getSpecificationFilesForService: getSpecificationFilesForService(join16(path6)),
1733
+ getSpecificationFilesForService: getSpecificationFilesForService(join17(path7)),
1602
1734
  /**
1603
1735
  * Check to see if a service version exists
1604
1736
  * @param id - The id of the service
1605
1737
  * @param version - The version of the service (supports semver)
1606
1738
  * @returns
1607
1739
  */
1608
- serviceHasVersion: serviceHasVersion(join16(path6)),
1740
+ serviceHasVersion: serviceHasVersion(join17(path7)),
1609
1741
  /**
1610
1742
  * Add an event to a service by it's id.
1611
1743
  *
@@ -1625,7 +1757,7 @@ var src_default = (path6) => {
1625
1757
  *
1626
1758
  * ```
1627
1759
  */
1628
- addEventToService: addMessageToService(join16(path6)),
1760
+ addEventToService: addMessageToService(join17(path7)),
1629
1761
  /**
1630
1762
  * Add a data store to a service by it's id.
1631
1763
  *
@@ -1642,7 +1774,7 @@ var src_default = (path6) => {
1642
1774
  *
1643
1775
  * ```
1644
1776
  */
1645
- addDataStoreToService: addDataStoreToService(join16(path6)),
1777
+ addDataStoreToService: addDataStoreToService(join17(path7)),
1646
1778
  /**
1647
1779
  * Add a command to a service by it's id.
1648
1780
  *
@@ -1662,7 +1794,7 @@ var src_default = (path6) => {
1662
1794
  *
1663
1795
  * ```
1664
1796
  */
1665
- addCommandToService: addMessageToService(join16(path6)),
1797
+ addCommandToService: addMessageToService(join17(path7)),
1666
1798
  /**
1667
1799
  * Add a query to a service by it's id.
1668
1800
  *
@@ -1682,7 +1814,7 @@ var src_default = (path6) => {
1682
1814
  *
1683
1815
  * ```
1684
1816
  */
1685
- addQueryToService: addMessageToService(join16(path6)),
1817
+ addQueryToService: addMessageToService(join17(path7)),
1686
1818
  /**
1687
1819
  * Add an entity to a service by its id.
1688
1820
  *
@@ -1700,7 +1832,7 @@ var src_default = (path6) => {
1700
1832
  *
1701
1833
  * ```
1702
1834
  */
1703
- addEntityToService: addEntityToService(join16(path6)),
1835
+ addEntityToService: addEntityToService(join17(path7)),
1704
1836
  /**
1705
1837
  * Check to see if a service exists by it's path.
1706
1838
  *
@@ -1717,13 +1849,13 @@ var src_default = (path6) => {
1717
1849
  * @param path - The path to the service to check
1718
1850
  * @returns boolean
1719
1851
  */
1720
- isService: isService(join16(path6)),
1852
+ isService: isService(join17(path7)),
1721
1853
  /**
1722
1854
  * Converts a file to a service.
1723
1855
  * @param file - The file to convert to a service.
1724
1856
  * @returns The service.
1725
1857
  */
1726
- toService: toService(join16(path6)),
1858
+ toService: toService(join17(path7)),
1727
1859
  /**
1728
1860
  * ================================
1729
1861
  * Domains
@@ -1736,39 +1868,39 @@ var src_default = (path6) => {
1736
1868
  * @param options - Optional options to write the event
1737
1869
  *
1738
1870
  */
1739
- writeDomain: writeDomain(join16(path6, "domains")),
1871
+ writeDomain: writeDomain(join17(path7, "domains")),
1740
1872
  /**
1741
1873
  * Returns a domain from EventCatalog
1742
1874
  * @param id - The id of the domain to retrieve
1743
1875
  * @param version - Optional id of the version to get (supports semver)
1744
1876
  * @returns Domain|Undefined
1745
1877
  */
1746
- getDomain: getDomain(join16(path6, "domains")),
1878
+ getDomain: getDomain(join17(path7, "domains")),
1747
1879
  /**
1748
1880
  * Returns all domains from EventCatalog
1749
1881
  * @param latestOnly - optional boolean, set to true to get only latest versions
1750
1882
  * @returns Domain[]|Undefined
1751
1883
  */
1752
- getDomains: getDomains(join16(path6)),
1884
+ getDomains: getDomains(join17(path7)),
1753
1885
  /**
1754
1886
  * Moves a given domain id to the version directory
1755
1887
  * @param directory
1756
1888
  */
1757
- versionDomain: versionDomain(join16(path6, "domains")),
1889
+ versionDomain: versionDomain(join17(path7, "domains")),
1758
1890
  /**
1759
1891
  * Remove a domain from EventCatalog (modeled on the standard POSIX rm utility)
1760
1892
  *
1761
1893
  * @param path - The path to your domain, e.g. `/Payment`
1762
1894
  *
1763
1895
  */
1764
- rmDomain: rmDomain(join16(path6, "domains")),
1896
+ rmDomain: rmDomain(join17(path7, "domains")),
1765
1897
  /**
1766
1898
  * Remove an service by an domain id
1767
1899
  *
1768
1900
  * @param id - The id of the domain you want to remove
1769
1901
  *
1770
1902
  */
1771
- rmDomainById: rmDomainById(join16(path6, "domains")),
1903
+ rmDomainById: rmDomainById(join17(path7, "domains")),
1772
1904
  /**
1773
1905
  * Adds a file to the given domain
1774
1906
  * @param id - The id of the domain to add the file to
@@ -1776,28 +1908,28 @@ var src_default = (path6) => {
1776
1908
  * @param version - Optional version of the domain to add the file to
1777
1909
  * @returns
1778
1910
  */
1779
- addFileToDomain: addFileToDomain(join16(path6, "domains")),
1911
+ addFileToDomain: addFileToDomain(join17(path7, "domains")),
1780
1912
  /**
1781
1913
  * Adds an ubiquitous language dictionary to a domain
1782
1914
  * @param id - The id of the domain to add the ubiquitous language to
1783
1915
  * @param ubiquitousLanguageDictionary - The ubiquitous language dictionary to add
1784
1916
  * @param version - Optional version of the domain to add the ubiquitous language to
1785
1917
  */
1786
- addUbiquitousLanguageToDomain: addUbiquitousLanguageToDomain(join16(path6, "domains")),
1918
+ addUbiquitousLanguageToDomain: addUbiquitousLanguageToDomain(join17(path7, "domains")),
1787
1919
  /**
1788
1920
  * Get the ubiquitous language dictionary from a domain
1789
1921
  * @param id - The id of the domain to get the ubiquitous language from
1790
1922
  * @param version - Optional version of the domain to get the ubiquitous language from
1791
1923
  * @returns
1792
1924
  */
1793
- getUbiquitousLanguageFromDomain: getUbiquitousLanguageFromDomain(join16(path6, "domains")),
1925
+ getUbiquitousLanguageFromDomain: getUbiquitousLanguageFromDomain(join17(path7, "domains")),
1794
1926
  /**
1795
1927
  * Check to see if a domain version exists
1796
1928
  * @param id - The id of the domain
1797
1929
  * @param version - The version of the domain (supports semver)
1798
1930
  * @returns
1799
1931
  */
1800
- domainHasVersion: domainHasVersion(join16(path6)),
1932
+ domainHasVersion: domainHasVersion(join17(path7)),
1801
1933
  /**
1802
1934
  * Adds a given service to a domain
1803
1935
  * @param id - The id of the domain
@@ -1805,7 +1937,7 @@ var src_default = (path6) => {
1805
1937
  * @param version - (Optional) The version of the domain to add the service to
1806
1938
  * @returns
1807
1939
  */
1808
- addServiceToDomain: addServiceToDomain(join16(path6, "domains")),
1940
+ addServiceToDomain: addServiceToDomain(join17(path7, "domains")),
1809
1941
  /**
1810
1942
  * Adds a given subdomain to a domain
1811
1943
  * @param id - The id of the domain
@@ -1813,7 +1945,7 @@ var src_default = (path6) => {
1813
1945
  * @param version - (Optional) The version of the domain to add the subdomain to
1814
1946
  * @returns
1815
1947
  */
1816
- addSubDomainToDomain: addSubDomainToDomain(join16(path6, "domains")),
1948
+ addSubDomainToDomain: addSubDomainToDomain(join17(path7, "domains")),
1817
1949
  /**
1818
1950
  * Adds an entity to a domain
1819
1951
  * @param id - The id of the domain
@@ -1821,7 +1953,7 @@ var src_default = (path6) => {
1821
1953
  * @param version - (Optional) The version of the domain to add the entity to
1822
1954
  * @returns
1823
1955
  */
1824
- addEntityToDomain: addEntityToDomain(join16(path6, "domains")),
1956
+ addEntityToDomain: addEntityToDomain(join17(path7, "domains")),
1825
1957
  /**
1826
1958
  * Add an event to a domain by its id.
1827
1959
  *
@@ -1839,7 +1971,7 @@ var src_default = (path6) => {
1839
1971
  *
1840
1972
  * ```
1841
1973
  */
1842
- addEventToDomain: addMessageToDomain(join16(path6, "domains")),
1974
+ addEventToDomain: addMessageToDomain(join17(path7, "domains")),
1843
1975
  /**
1844
1976
  * Add a command to a domain by its id.
1845
1977
  *
@@ -1857,7 +1989,7 @@ var src_default = (path6) => {
1857
1989
  *
1858
1990
  * ```
1859
1991
  */
1860
- addCommandToDomain: addMessageToDomain(join16(path6, "domains")),
1992
+ addCommandToDomain: addMessageToDomain(join17(path7, "domains")),
1861
1993
  /**
1862
1994
  * Add a query to a domain by its id.
1863
1995
  *
@@ -1875,7 +2007,7 @@ var src_default = (path6) => {
1875
2007
  *
1876
2008
  * ```
1877
2009
  */
1878
- addQueryToDomain: addMessageToDomain(join16(path6, "domains")),
2010
+ addQueryToDomain: addMessageToDomain(join17(path7, "domains")),
1879
2011
  /**
1880
2012
  * ================================
1881
2013
  * Teams
@@ -1888,25 +2020,25 @@ var src_default = (path6) => {
1888
2020
  * @param options - Optional options to write the team
1889
2021
  *
1890
2022
  */
1891
- writeTeam: writeTeam(join16(path6, "teams")),
2023
+ writeTeam: writeTeam(join17(path7, "teams")),
1892
2024
  /**
1893
2025
  * Returns a team from EventCatalog
1894
2026
  * @param id - The id of the team to retrieve
1895
2027
  * @returns Team|Undefined
1896
2028
  */
1897
- getTeam: getTeam(join16(path6, "teams")),
2029
+ getTeam: getTeam(join17(path7, "teams")),
1898
2030
  /**
1899
2031
  * Returns all teams from EventCatalog
1900
2032
  * @returns Team[]|Undefined
1901
2033
  */
1902
- getTeams: getTeams(join16(path6, "teams")),
2034
+ getTeams: getTeams(join17(path7, "teams")),
1903
2035
  /**
1904
2036
  * Remove a team by the team id
1905
2037
  *
1906
2038
  * @param id - The id of the team you want to remove
1907
2039
  *
1908
2040
  */
1909
- rmTeamById: rmTeamById(join16(path6, "teams")),
2041
+ rmTeamById: rmTeamById(join17(path7, "teams")),
1910
2042
  /**
1911
2043
  * ================================
1912
2044
  * Users
@@ -1919,25 +2051,25 @@ var src_default = (path6) => {
1919
2051
  * @param options - Optional options to write the user
1920
2052
  *
1921
2053
  */
1922
- writeUser: writeUser(join16(path6, "users")),
2054
+ writeUser: writeUser(join17(path7, "users")),
1923
2055
  /**
1924
2056
  * Returns a user from EventCatalog
1925
2057
  * @param id - The id of the user to retrieve
1926
2058
  * @returns User|Undefined
1927
2059
  */
1928
- getUser: getUser(join16(path6, "users")),
2060
+ getUser: getUser(join17(path7, "users")),
1929
2061
  /**
1930
2062
  * Returns all user from EventCatalog
1931
2063
  * @returns User[]|Undefined
1932
2064
  */
1933
- getUsers: getUsers(join16(path6)),
2065
+ getUsers: getUsers(join17(path7)),
1934
2066
  /**
1935
2067
  * Remove a user by the user id
1936
2068
  *
1937
2069
  * @param id - The id of the user you want to remove
1938
2070
  *
1939
2071
  */
1940
- rmUserById: rmUserById(join16(path6, "users")),
2072
+ rmUserById: rmUserById(join17(path7, "users")),
1941
2073
  /**
1942
2074
  * ================================
1943
2075
  * Custom Docs
@@ -1948,32 +2080,32 @@ var src_default = (path6) => {
1948
2080
  * @param path - The path to the custom doc to retrieve
1949
2081
  * @returns CustomDoc|Undefined
1950
2082
  */
1951
- getCustomDoc: getCustomDoc(join16(path6, "docs")),
2083
+ getCustomDoc: getCustomDoc(join17(path7, "docs")),
1952
2084
  /**
1953
2085
  * Returns all custom docs from EventCatalog
1954
2086
  * @param options - Optional options to get custom docs from a specific path
1955
2087
  * @returns CustomDoc[]|Undefined
1956
2088
  */
1957
- getCustomDocs: getCustomDocs(join16(path6, "docs")),
2089
+ getCustomDocs: getCustomDocs(join17(path7, "docs")),
1958
2090
  /**
1959
2091
  * Writes a custom doc to EventCatalog
1960
2092
  * @param customDoc - The custom doc to write
1961
2093
  * @param options - Optional options to write the custom doc
1962
2094
  *
1963
2095
  */
1964
- writeCustomDoc: writeCustomDoc(join16(path6, "docs")),
2096
+ writeCustomDoc: writeCustomDoc(join17(path7, "docs")),
1965
2097
  /**
1966
2098
  * Removes a custom doc from EventCatalog
1967
2099
  * @param path - The path to the custom doc to remove
1968
2100
  *
1969
2101
  */
1970
- rmCustomDoc: rmCustomDoc(join16(path6, "docs")),
2102
+ rmCustomDoc: rmCustomDoc(join17(path7, "docs")),
1971
2103
  /**
1972
2104
  * Dumps the catalog to a JSON file.
1973
2105
  * @param directory - The directory to dump the catalog to
1974
2106
  * @returns A JSON file with the catalog
1975
2107
  */
1976
- dumpCatalog: dumpCatalog(join16(path6)),
2108
+ dumpCatalog: dumpCatalog(join17(path7)),
1977
2109
  /**
1978
2110
  * Returns the event catalog configuration file.
1979
2111
  * The event catalog configuration file is the file that contains the configuration for the event catalog.
@@ -1981,7 +2113,7 @@ var src_default = (path6) => {
1981
2113
  * @param directory - The directory of the catalog.
1982
2114
  * @returns A JSON object with the configuration for the event catalog.
1983
2115
  */
1984
- getEventCatalogConfigurationFile: getEventCatalogConfigurationFile(join16(path6)),
2116
+ getEventCatalogConfigurationFile: getEventCatalogConfigurationFile(join17(path7)),
1985
2117
  /**
1986
2118
  * ================================
1987
2119
  * Resources Utils
@@ -2006,33 +2138,33 @@ var src_default = (path6) => {
2006
2138
  * @param path - The path to the message to retrieve
2007
2139
  * @returns Message|Undefined
2008
2140
  */
2009
- getMessageBySchemaPath: getMessageBySchemaPath(join16(path6)),
2141
+ getMessageBySchemaPath: getMessageBySchemaPath(join17(path7)),
2010
2142
  /**
2011
2143
  * Returns the producers and consumers (services) for a given message
2012
2144
  * @param id - The id of the message to get the producers and consumers for
2013
2145
  * @param version - Optional version of the message
2014
2146
  * @returns { producers: Service[], consumers: Service[] }
2015
2147
  */
2016
- getProducersAndConsumersForMessage: getProducersAndConsumersForMessage(join16(path6)),
2148
+ getProducersAndConsumersForMessage: getProducersAndConsumersForMessage(join17(path7)),
2017
2149
  /**
2018
2150
  * Returns the consumers of a given schema path
2019
2151
  * @param path - The path to the schema to get the consumers for
2020
2152
  * @returns Service[]
2021
2153
  */
2022
- getConsumersOfSchema: getConsumersOfSchema(join16(path6)),
2154
+ getConsumersOfSchema: getConsumersOfSchema(join17(path7)),
2023
2155
  /**
2024
2156
  * Returns the producers of a given schema path
2025
2157
  * @param path - The path to the schema to get the producers for
2026
2158
  * @returns Service[]
2027
2159
  */
2028
- getProducersOfSchema: getProducersOfSchema(join16(path6)),
2160
+ getProducersOfSchema: getProducersOfSchema(join17(path7)),
2029
2161
  /**
2030
2162
  * Returns the owners for a given resource (e.g domain, service, event, command, query, etc.)
2031
2163
  * @param id - The id of the resource to get the owners for
2032
2164
  * @param version - Optional version of the resource
2033
2165
  * @returns { owners: User[] }
2034
2166
  */
2035
- getOwnersForResource: getOwnersForResource(join16(path6)),
2167
+ getOwnersForResource: getOwnersForResource(join17(path7)),
2036
2168
  /**
2037
2169
  * ================================
2038
2170
  * Entities
@@ -2044,13 +2176,13 @@ var src_default = (path6) => {
2044
2176
  * @param version - Optional id of the version to get (supports semver)
2045
2177
  * @returns Entity|Undefined
2046
2178
  */
2047
- getEntity: getEntity(join16(path6)),
2179
+ getEntity: getEntity(join17(path7)),
2048
2180
  /**
2049
2181
  * Returns all entities from EventCatalog
2050
2182
  * @param latestOnly - optional boolean, set to true to get only latest versions
2051
2183
  * @returns Entity[]|Undefined
2052
2184
  */
2053
- getEntities: getEntities(join16(path6)),
2185
+ getEntities: getEntities(join17(path7)),
2054
2186
  /**
2055
2187
  * Adds an entity to EventCatalog
2056
2188
  *
@@ -2058,33 +2190,33 @@ var src_default = (path6) => {
2058
2190
  * @param options - Optional options to write the entity
2059
2191
  *
2060
2192
  */
2061
- writeEntity: writeEntity(join16(path6, "entities")),
2193
+ writeEntity: writeEntity(join17(path7, "entities")),
2062
2194
  /**
2063
2195
  * Remove an entity from EventCatalog (modeled on the standard POSIX rm utility)
2064
2196
  *
2065
2197
  * @param path - The path to your entity, e.g. `/User`
2066
2198
  *
2067
2199
  */
2068
- rmEntity: rmEntity(join16(path6, "entities")),
2200
+ rmEntity: rmEntity(join17(path7, "entities")),
2069
2201
  /**
2070
2202
  * Remove an entity by an entity id
2071
2203
  *
2072
2204
  * @param id - The id of the entity you want to remove
2073
2205
  *
2074
2206
  */
2075
- rmEntityById: rmEntityById(join16(path6)),
2207
+ rmEntityById: rmEntityById(join17(path7)),
2076
2208
  /**
2077
2209
  * Moves a given entity id to the version directory
2078
2210
  * @param id - The id of the entity to version
2079
2211
  */
2080
- versionEntity: versionEntity(join16(path6)),
2212
+ versionEntity: versionEntity(join17(path7)),
2081
2213
  /**
2082
2214
  * Check to see if an entity version exists
2083
2215
  * @param id - The id of the entity
2084
2216
  * @param version - The version of the entity (supports semver)
2085
2217
  * @returns
2086
2218
  */
2087
- entityHasVersion: entityHasVersion(join16(path6)),
2219
+ entityHasVersion: entityHasVersion(join17(path7)),
2088
2220
  /**
2089
2221
  * ================================
2090
2222
  * Data Stores
@@ -2096,42 +2228,42 @@ var src_default = (path6) => {
2096
2228
  * @param options - Optional options to write the data store
2097
2229
  *
2098
2230
  */
2099
- writeDataStore: writeDataStore(join16(path6, "containers")),
2231
+ writeDataStore: writeDataStore(join17(path7, "containers")),
2100
2232
  /**
2101
2233
  * Returns a data store from EventCatalog
2102
2234
  * @param id - The id of the data store to retrieve
2103
2235
  * @param version - Optional id of the version to get (supports semver)
2104
2236
  * @returns Container|Undefined
2105
2237
  */
2106
- getDataStore: getDataStore(join16(path6)),
2238
+ getDataStore: getDataStore(join17(path7)),
2107
2239
  /**
2108
2240
  * Returns all data stores from EventCatalog
2109
2241
  * @param latestOnly - optional boolean, set to true to get only latest versions
2110
2242
  * @returns Container[]|Undefined
2111
2243
  */
2112
- getDataStores: getDataStores(join16(path6)),
2244
+ getDataStores: getDataStores(join17(path7)),
2113
2245
  /**
2114
2246
  * Version a data store by its id
2115
2247
  * @param id - The id of the data store to version
2116
2248
  */
2117
- versionDataStore: versionDataStore(join16(path6, "containers")),
2249
+ versionDataStore: versionDataStore(join17(path7, "containers")),
2118
2250
  /**
2119
2251
  * Remove a data store by its path
2120
2252
  * @param path - The path to the data store to remove
2121
2253
  */
2122
- rmDataStore: rmDataStore(join16(path6, "containers")),
2254
+ rmDataStore: rmDataStore(join17(path7, "containers")),
2123
2255
  /**
2124
2256
  * Remove a data store by its id
2125
2257
  * @param id - The id of the data store to remove
2126
2258
  */
2127
- rmDataStoreById: rmDataStoreById(join16(path6)),
2259
+ rmDataStoreById: rmDataStoreById(join17(path7)),
2128
2260
  /**
2129
2261
  * Check to see if a data store version exists
2130
2262
  * @param id - The id of the data store
2131
2263
  * @param version - The version of the data store (supports semver)
2132
2264
  * @returns
2133
2265
  */
2134
- dataStoreHasVersion: dataStoreHasVersion(join16(path6)),
2266
+ dataStoreHasVersion: dataStoreHasVersion(join17(path7)),
2135
2267
  /**
2136
2268
  * Adds a file to a data store by its id
2137
2269
  * @param id - The id of the data store to add the file to
@@ -2139,14 +2271,14 @@ var src_default = (path6) => {
2139
2271
  * @param version - Optional version of the data store to add the file to
2140
2272
  * @returns
2141
2273
  */
2142
- addFileToDataStore: addFileToDataStore(join16(path6)),
2274
+ addFileToDataStore: addFileToDataStore(join17(path7)),
2143
2275
  /**
2144
2276
  * Writes a data store to a service by its id
2145
2277
  * @param dataStore - The data store to write
2146
2278
  * @param service - The service to write the data store to
2147
2279
  * @returns
2148
2280
  */
2149
- writeDataStoreToService: writeDataStoreToService(join16(path6)),
2281
+ writeDataStoreToService: writeDataStoreToService(join17(path7)),
2150
2282
  /**
2151
2283
  * ================================
2152
2284
  * Data Products
@@ -2158,7 +2290,7 @@ var src_default = (path6) => {
2158
2290
  * @param options - Optional options to write the data product
2159
2291
  *
2160
2292
  */
2161
- writeDataProduct: writeDataProduct(join16(path6, "data-products")),
2293
+ writeDataProduct: writeDataProduct(join17(path7, "data-products")),
2162
2294
  /**
2163
2295
  * Writes a data product to a domain in EventCatalog
2164
2296
  * @param dataProduct - The data product to write
@@ -2166,43 +2298,43 @@ var src_default = (path6) => {
2166
2298
  * @param options - Optional options to write the data product
2167
2299
  *
2168
2300
  */
2169
- writeDataProductToDomain: writeDataProductToDomain(join16(path6, "domains")),
2301
+ writeDataProductToDomain: writeDataProductToDomain(join17(path7, "domains")),
2170
2302
  /**
2171
2303
  * Returns a data product from EventCatalog
2172
2304
  * @param id - The id of the data product to retrieve
2173
2305
  * @param version - Optional id of the version to get (supports semver)
2174
2306
  * @returns DataProduct|Undefined
2175
2307
  */
2176
- getDataProduct: getDataProduct(join16(path6)),
2308
+ getDataProduct: getDataProduct(join17(path7)),
2177
2309
  /**
2178
2310
  * Returns all data products from EventCatalog
2179
2311
  * @param latestOnly - optional boolean, set to true to get only latest versions
2180
2312
  * @returns DataProduct[]|Undefined
2181
2313
  */
2182
- getDataProducts: getDataProducts(join16(path6)),
2314
+ getDataProducts: getDataProducts(join17(path7)),
2183
2315
  /**
2184
2316
  * Version a data product by its id
2185
2317
  * @param id - The id of the data product to version
2186
2318
  */
2187
- versionDataProduct: versionDataProduct(join16(path6)),
2319
+ versionDataProduct: versionDataProduct(join17(path7)),
2188
2320
  /**
2189
2321
  * Remove a data product by its path
2190
2322
  * @param path - The path to the data product to remove
2191
2323
  */
2192
- rmDataProduct: rmDataProduct(join16(path6, "data-products")),
2324
+ rmDataProduct: rmDataProduct(join17(path7, "data-products")),
2193
2325
  /**
2194
2326
  * Remove a data product by its id
2195
2327
  * @param id - The id of the data product to remove
2196
2328
  * @param version - Optional version of the data product to remove
2197
2329
  */
2198
- rmDataProductById: rmDataProductById(join16(path6)),
2330
+ rmDataProductById: rmDataProductById(join17(path7)),
2199
2331
  /**
2200
2332
  * Check to see if a data product version exists
2201
2333
  * @param id - The id of the data product
2202
2334
  * @param version - The version of the data product (supports semver)
2203
2335
  * @returns
2204
2336
  */
2205
- dataProductHasVersion: dataProductHasVersion(join16(path6)),
2337
+ dataProductHasVersion: dataProductHasVersion(join17(path7)),
2206
2338
  /**
2207
2339
  * Adds a file to a data product by its id
2208
2340
  * @param id - The id of the data product to add the file to
@@ -2210,7 +2342,7 @@ var src_default = (path6) => {
2210
2342
  * @param version - Optional version of the data product to add the file to
2211
2343
  * @returns
2212
2344
  */
2213
- addFileToDataProduct: addFileToDataProduct(join16(path6)),
2345
+ addFileToDataProduct: addFileToDataProduct(join17(path7)),
2214
2346
  /**
2215
2347
  * Adds a data product to a domain
2216
2348
  * @param id - The id of the domain
@@ -2218,106 +2350,121 @@ var src_default = (path6) => {
2218
2350
  * @param version - (Optional) The version of the domain to add the data product to
2219
2351
  * @returns
2220
2352
  */
2221
- addDataProductToDomain: addDataProductToDomain(join16(path6, "domains"))
2353
+ addDataProductToDomain: addDataProductToDomain(join17(path7, "domains"))
2222
2354
  };
2223
2355
  };
2224
2356
 
2225
- // src/eventcatalog.ts
2226
- var DUMP_VERSION = "0.0.1";
2227
- var getEventCatalogVersion = async (catalogDir) => {
2357
+ // src/cli/executor.ts
2358
+ async function executeFunction(catalogDir, functionName, rawArgs) {
2359
+ if (!existsSync(catalogDir)) {
2360
+ throw new Error(`Catalog directory not found: ${catalogDir}`);
2361
+ }
2362
+ const sdk = src_default(catalogDir);
2363
+ if (!(functionName in sdk)) {
2364
+ throw new Error(`Function '${functionName}' not found. Use 'eventcatalog list' to see available functions.`);
2365
+ }
2366
+ const fn = sdk[functionName];
2367
+ if (typeof fn !== "function") {
2368
+ throw new Error(`'${functionName}' is not a callable function.`);
2369
+ }
2370
+ const parsedArgs = parseArguments(rawArgs);
2228
2371
  try {
2229
- const packageJson = fs13.readFileSync(join17(catalogDir, "package.json"), "utf8");
2230
- const packageJsonObject = JSON.parse(packageJson);
2231
- return packageJsonObject["dependencies"]["@eventcatalog/core"];
2372
+ return await fn(...parsedArgs);
2232
2373
  } catch (error) {
2233
- return "unknown";
2374
+ throw new Error(`Error executing '${functionName}': ${error instanceof Error ? error.message : String(error)}`);
2234
2375
  }
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 () => {
2376
+ }
2377
+
2378
+ // src/cli/list.ts
2379
+ function listFunctions(catalogDir = ".") {
2380
+ const sdk = src_default(catalogDir);
2381
+ const functionNames = Object.keys(sdk).filter((key) => typeof sdk[key] === "function");
2382
+ const categories = {
2383
+ Events: [],
2384
+ Commands: [],
2385
+ Queries: [],
2386
+ Channels: [],
2387
+ Services: [],
2388
+ Domains: [],
2389
+ Entities: [],
2390
+ DataStores: [],
2391
+ DataProducts: [],
2392
+ Teams: [],
2393
+ Users: [],
2394
+ "Custom Docs": [],
2395
+ Messages: [],
2396
+ Utilities: []
2397
+ };
2398
+ functionNames.forEach((name) => {
2399
+ if (name.includes("Event")) categories["Events"].push(name);
2400
+ else if (name.includes("Command")) categories["Commands"].push(name);
2401
+ else if (name.includes("Query")) categories["Queries"].push(name);
2402
+ else if (name.includes("Channel")) categories["Channels"].push(name);
2403
+ else if (name.includes("Service")) categories["Services"].push(name);
2404
+ else if (name.includes("Domain")) categories["Domains"].push(name);
2405
+ else if (name.includes("Entity")) categories["Entities"].push(name);
2406
+ else if (name.includes("DataStore")) categories["DataStores"].push(name);
2407
+ else if (name.includes("DataProduct")) categories["DataProducts"].push(name);
2408
+ else if (name.includes("Team")) categories["Teams"].push(name);
2409
+ else if (name.includes("User")) categories["Users"].push(name);
2410
+ else if (name.includes("CustomDoc")) categories["Custom Docs"].push(name);
2411
+ else if (name.includes("Message") || name.includes("Producers") || name.includes("Consumers"))
2412
+ categories["Messages"].push(name);
2413
+ else categories["Utilities"].push(name);
2414
+ });
2415
+ Object.keys(categories).forEach((key) => {
2416
+ if (categories[key].length === 0) {
2417
+ delete categories[key];
2418
+ }
2419
+ });
2420
+ return categories;
2421
+ }
2422
+ function formatListOutput(functions) {
2423
+ let output = "Available EventCatalog SDK Functions:\n\n";
2424
+ Object.entries(functions).forEach(([category, names]) => {
2425
+ output += `${category}:
2426
+ `;
2427
+ names.sort().forEach((name) => {
2428
+ output += ` - ${name}
2429
+ `;
2430
+ });
2431
+ output += "\n";
2432
+ });
2433
+ return output;
2434
+ }
2435
+
2436
+ // src/cli/index.ts
2437
+ var version = "1.0.0";
2438
+ try {
2439
+ const packageJsonPath = resolve2(__dirname, "../../package.json");
2440
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
2441
+ version = packageJson.version;
2442
+ } catch {
2443
+ }
2444
+ program.name("eventcatalog").description("EventCatalog SDK Command-Line Interface").version(version).option("-d, --dir <path>", "Path to the EventCatalog directory (default: current directory)", ".");
2445
+ program.command("list").description("List all available SDK functions").action(() => {
2262
2446
  try {
2263
- const path6 = join17(directory, "eventcatalog.config.js");
2264
- const configModule = await import(path6);
2265
- return configModule.default;
2447
+ const functions = listFunctions(".");
2448
+ const output = formatListOutput(functions);
2449
+ console.log(output);
2266
2450
  } catch (error) {
2267
- console.error("Error getting event catalog configuration file", error);
2268
- return null;
2451
+ console.error("Error listing functions:", error instanceof Error ? error.message : String(error));
2452
+ process.exit(1);
2269
2453
  }
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
2454
+ });
2455
+ program.arguments("<function> [args...]").action(async (functionName, args) => {
2456
+ try {
2457
+ const options = program.opts();
2458
+ const dir = options.dir || ".";
2459
+ const result = await executeFunction(dir, functionName, args);
2460
+ console.log(JSON.stringify(result, null, 0));
2461
+ } catch (error) {
2462
+ console.error(error instanceof Error ? error.message : String(error));
2463
+ process.exit(1);
2464
+ }
2465
+ });
2466
+ program.parse(process.argv);
2467
+ if (process.argv.length < 3) {
2468
+ program.outputHelp();
2469
+ }
2470
+ //# sourceMappingURL=index.mjs.map