@eventcatalog/sdk 2.10.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 (108) 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} +691 -347
  5. package/dist/cli/index.js.map +1 -0
  6. package/dist/{eventcatalog.mjs → cli/index.mjs} +765 -401
  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 +504 -4
  15. package/dist/index.d.ts +504 -4
  16. package/dist/index.js +325 -108
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +325 -108
  19. package/dist/index.mjs.map +1 -1
  20. package/package.json +13 -4
  21. package/dist/channels.d.mts +0 -214
  22. package/dist/channels.d.ts +0 -214
  23. package/dist/channels.js +0 -432
  24. package/dist/channels.js.map +0 -1
  25. package/dist/channels.mjs +0 -384
  26. package/dist/channels.mjs.map +0 -1
  27. package/dist/commands.d.mts +0 -274
  28. package/dist/commands.d.ts +0 -274
  29. package/dist/commands.js +0 -394
  30. package/dist/commands.js.map +0 -1
  31. package/dist/commands.mjs +0 -350
  32. package/dist/commands.mjs.map +0 -1
  33. package/dist/containers.d.mts +0 -179
  34. package/dist/containers.d.ts +0 -179
  35. package/dist/containers.js +0 -388
  36. package/dist/containers.js.map +0 -1
  37. package/dist/containers.mjs +0 -345
  38. package/dist/containers.mjs.map +0 -1
  39. package/dist/custom-docs.d.mts +0 -89
  40. package/dist/custom-docs.d.ts +0 -89
  41. package/dist/custom-docs.js +0 -164
  42. package/dist/custom-docs.js.map +0 -1
  43. package/dist/custom-docs.mjs +0 -122
  44. package/dist/custom-docs.mjs.map +0 -1
  45. package/dist/data-stores.d.mts +0 -179
  46. package/dist/data-stores.d.ts +0 -179
  47. package/dist/data-stores.js +0 -401
  48. package/dist/data-stores.js.map +0 -1
  49. package/dist/data-stores.mjs +0 -356
  50. package/dist/data-stores.mjs.map +0 -1
  51. package/dist/domains.d.mts +0 -297
  52. package/dist/domains.d.ts +0 -297
  53. package/dist/domains.js +0 -480
  54. package/dist/domains.js.map +0 -1
  55. package/dist/domains.mjs +0 -433
  56. package/dist/domains.mjs.map +0 -1
  57. package/dist/entities.d.mts +0 -174
  58. package/dist/entities.d.ts +0 -174
  59. package/dist/entities.js +0 -348
  60. package/dist/entities.js.map +0 -1
  61. package/dist/entities.mjs +0 -307
  62. package/dist/entities.mjs.map +0 -1
  63. package/dist/eventcatalog.d.mts +0 -21
  64. package/dist/eventcatalog.d.ts +0 -21
  65. package/dist/eventcatalog.js.map +0 -1
  66. package/dist/eventcatalog.mjs.map +0 -1
  67. package/dist/events.d.mts +0 -276
  68. package/dist/events.d.ts +0 -276
  69. package/dist/events.js +0 -393
  70. package/dist/events.js.map +0 -1
  71. package/dist/events.mjs +0 -349
  72. package/dist/events.mjs.map +0 -1
  73. package/dist/messages.d.mts +0 -65
  74. package/dist/messages.d.ts +0 -65
  75. package/dist/messages.js +0 -312
  76. package/dist/messages.js.map +0 -1
  77. package/dist/messages.mjs +0 -269
  78. package/dist/messages.mjs.map +0 -1
  79. package/dist/queries.d.mts +0 -276
  80. package/dist/queries.d.ts +0 -276
  81. package/dist/queries.js +0 -394
  82. package/dist/queries.js.map +0 -1
  83. package/dist/queries.mjs +0 -350
  84. package/dist/queries.mjs.map +0 -1
  85. package/dist/services.d.mts +0 -384
  86. package/dist/services.d.ts +0 -384
  87. package/dist/services.js +0 -577
  88. package/dist/services.js.map +0 -1
  89. package/dist/services.mjs +0 -526
  90. package/dist/services.mjs.map +0 -1
  91. package/dist/teams.d.mts +0 -90
  92. package/dist/teams.d.ts +0 -90
  93. package/dist/teams.js +0 -246
  94. package/dist/teams.js.map +0 -1
  95. package/dist/teams.mjs +0 -202
  96. package/dist/teams.mjs.map +0 -1
  97. package/dist/types.d.d.mts +0 -304
  98. package/dist/types.d.d.ts +0 -304
  99. package/dist/types.d.js +0 -19
  100. package/dist/types.d.js.map +0 -1
  101. package/dist/types.d.mjs +0 -1
  102. package/dist/types.d.mjs.map +0 -1
  103. package/dist/users.d.mts +0 -83
  104. package/dist/users.d.ts +0 -83
  105. package/dist/users.js +0 -127
  106. package/dist/users.js.map +0 -1
  107. package/dist/users.mjs +0 -88
  108. package/dist/users.mjs.map +0 -1
@@ -1,9 +1,44 @@
1
- // src/eventcatalog.ts
2
- import fs12 from "fs";
3
- import path5, { join as join16 } 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 join15 } 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/**"],
@@ -655,23 +690,32 @@ var writeDomain = (directory) => async (domain, options = {
655
690
  if (Array.isArray(domain.domains)) {
656
691
  resource.domains = uniqueVersions(domain.domains);
657
692
  }
693
+ if (Array.isArray(domain.sends)) {
694
+ resource.sends = uniqueVersions(domain.sends);
695
+ }
696
+ if (Array.isArray(domain.receives)) {
697
+ resource.receives = uniqueVersions(domain.receives);
698
+ }
699
+ if (Array.isArray(domain.dataProducts)) {
700
+ resource.dataProducts = uniqueVersions(domain.dataProducts);
701
+ }
658
702
  return await writeResource(directory, resource, { ...options, type: "domain" });
659
703
  };
660
704
  var versionDomain = (directory) => async (id) => versionResource(directory, id);
661
- var rmDomain = (directory) => async (path6) => {
662
- await fs6.rm(join7(directory, path6), { recursive: true });
705
+ var rmDomain = (directory) => async (path7) => {
706
+ await fs6.rm(join7(directory, path7), { recursive: true });
663
707
  };
664
- var rmDomainById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "domain", persistFiles });
665
- var addFileToDomain = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
666
- 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) => {
667
711
  const content = matter3.stringify("", {
668
712
  ...ubiquitousLanguageDictionary
669
713
  });
670
- await addFileToResource(directory, id, { content, fileName: "ubiquitous-language.mdx" }, version);
714
+ await addFileToResource(directory, id, { content, fileName: "ubiquitous-language.mdx" }, version2);
671
715
  };
672
- var getUbiquitousLanguageFromDomain = (directory) => async (id, version) => {
673
- const pathToDomain = await findFileById(directory, id, version) || "";
674
- 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");
675
719
  const fileExists = fsSync3.existsSync(pathToUbiquitousLanguage);
676
720
  if (!fileExists) {
677
721
  return void 0;
@@ -679,14 +723,14 @@ var getUbiquitousLanguageFromDomain = (directory) => async (id, version) => {
679
723
  const content = await readMdxFile(pathToUbiquitousLanguage);
680
724
  return content;
681
725
  };
682
- var domainHasVersion = (directory) => async (id, version) => {
683
- const file = await findFileById(directory, id, version);
726
+ var domainHasVersion = (directory) => async (id, version2) => {
727
+ const file = await findFileById(directory, id, version2);
684
728
  return !!file;
685
729
  };
686
- var addServiceToDomain = (directory) => async (id, service, version) => {
687
- let domain = await getDomain(directory)(id, version);
688
- const domainPath = await getResourcePath(directory, id, version);
689
- 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 || "");
690
734
  if (domain.services === void 0) {
691
735
  domain.services = [];
692
736
  }
@@ -695,13 +739,13 @@ var addServiceToDomain = (directory) => async (id, service, version) => {
695
739
  return;
696
740
  }
697
741
  domain.services.push(service);
698
- await rmDomainById(directory)(id, version, true);
742
+ await rmDomainById(directory)(id, version2, true);
699
743
  await writeDomain(directory)(domain, { format: extension === ".md" ? "md" : "mdx" });
700
744
  };
701
- var addSubDomainToDomain = (directory) => async (id, subDomain, version) => {
702
- let domain = await getDomain(directory)(id, version);
703
- const domainPath = await getResourcePath(directory, id, version);
704
- 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 || "");
705
749
  if (domain.domains === void 0) {
706
750
  domain.domains = [];
707
751
  }
@@ -710,13 +754,13 @@ var addSubDomainToDomain = (directory) => async (id, subDomain, version) => {
710
754
  return;
711
755
  }
712
756
  domain.domains.push(subDomain);
713
- await rmDomainById(directory)(id, version, true);
757
+ await rmDomainById(directory)(id, version2, true);
714
758
  await writeDomain(directory)(domain, { format: extension === ".md" ? "md" : "mdx" });
715
759
  };
716
- var addEntityToDomain = (directory) => async (id, entity, version) => {
717
- let domain = await getDomain(directory)(id, version);
718
- const domainPath = await getResourcePath(directory, id, version);
719
- 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 || "");
720
764
  if (domain.entities === void 0) {
721
765
  domain.entities = [];
722
766
  }
@@ -725,27 +769,81 @@ var addEntityToDomain = (directory) => async (id, entity, version) => {
725
769
  return;
726
770
  }
727
771
  domain.entities.push(entity);
728
- await rmDomainById(directory)(id, version, true);
772
+ await rmDomainById(directory)(id, version2, true);
729
773
  await writeDomain(directory)(domain, { format: extension === ".md" ? "md" : "mdx" });
730
774
  };
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 || "");
779
+ if (domain.dataProducts === void 0) {
780
+ domain.dataProducts = [];
781
+ }
782
+ const dataProductExistsInList = domain.dataProducts.some(
783
+ (dp) => dp.id === dataProduct.id && dp.version === dataProduct.version
784
+ );
785
+ if (dataProductExistsInList) {
786
+ return;
787
+ }
788
+ domain.dataProducts.push(dataProduct);
789
+ await rmDomainById(directory)(id, version2, true);
790
+ await writeDomain(directory)(domain, { format: extension === ".md" ? "md" : "mdx" });
791
+ };
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 || "");
796
+ if (direction === "sends") {
797
+ if (domain.sends === void 0) {
798
+ domain.sends = [];
799
+ }
800
+ for (let i = 0; i < domain.sends.length; i++) {
801
+ if (domain.sends[i].id === message.id && domain.sends[i].version === message.version) {
802
+ return;
803
+ }
804
+ }
805
+ domain.sends.push({ id: message.id, version: message.version });
806
+ } else if (direction === "receives") {
807
+ if (domain.receives === void 0) {
808
+ domain.receives = [];
809
+ }
810
+ for (let i = 0; i < domain.receives.length; i++) {
811
+ if (domain.receives[i].id === message.id && domain.receives[i].version === message.version) {
812
+ return;
813
+ }
814
+ }
815
+ domain.receives.push({ id: message.id, version: message.version });
816
+ } else {
817
+ throw new Error(`Direction ${direction} is invalid, only 'receives' and 'sends' are supported`);
818
+ }
819
+ const existingResource = await findFileById(directory, id, version2);
820
+ if (!existingResource) {
821
+ throw new Error(`Cannot find domain ${id} in the catalog`);
822
+ }
823
+ const normalizedPath = existingResource.replace(/\\/g, "/");
824
+ const lastDomainsIndex = normalizedPath.lastIndexOf("/domains/");
825
+ const pathToResource = existingResource.substring(0, lastDomainsIndex + "/domains".length);
826
+ await rmDomainById(directory)(id, version2, true);
827
+ await writeDomain(pathToResource)(domain, { format: extension === ".md" ? "md" : "mdx" });
828
+ };
731
829
 
732
830
  // src/channels.ts
733
831
  import fs7 from "node:fs/promises";
734
832
  import { join as join8, extname as extname2 } from "node:path";
735
- 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" });
736
834
  var getChannels = (directory) => async (options) => getResources(directory, { type: "channels", ...options });
737
835
  var writeChannel = (directory) => async (channel, options = { path: "" }) => writeResource(directory, { ...channel }, { ...options, type: "channel" });
738
- var rmChannel = (directory) => async (path6) => {
739
- await fs7.rm(join8(directory, path6), { recursive: true });
836
+ var rmChannel = (directory) => async (path7) => {
837
+ await fs7.rm(join8(directory, path7), { recursive: true });
740
838
  };
741
- 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 });
742
840
  var versionChannel = (directory) => async (id) => versionResource(directory, id);
743
- var channelHasVersion = (directory) => async (id, version) => {
744
- const file = await findFileById(directory, id, version);
841
+ var channelHasVersion = (directory) => async (id, version2) => {
842
+ const file = await findFileById(directory, id, version2);
745
843
  return !!file;
746
844
  };
747
- var addMessageToChannel = (directory, collection) => async (id, _message, version) => {
748
- let channel = await getChannel(directory)(id, version);
845
+ var addMessageToChannel = (directory, collection) => async (id, _message, version2) => {
846
+ let channel = await getChannel(directory)(id, version2);
749
847
  const functions = {
750
848
  events: {
751
849
  getMessage: getEvent,
@@ -777,8 +875,8 @@ var addMessageToChannel = (directory, collection) => async (id, _message, versio
777
875
  if (!existingResource) {
778
876
  throw new Error(`Cannot find message ${id} in the catalog`);
779
877
  }
780
- const path6 = existingResource.split(`/[\\/]+${collection}`)[0];
781
- const pathToResource = join8(path6, collection);
878
+ const path7 = existingResource.split(`/[\\/]+${collection}`)[0];
879
+ const pathToResource = join8(path7, collection);
782
880
  await rmMessageById(directory)(_message.id, _message.version, true);
783
881
  await writeMessage(pathToResource)(message, { format: extension === ".md" ? "md" : "mdx" });
784
882
  };
@@ -787,8 +885,8 @@ var addMessageToChannel = (directory, collection) => async (id, _message, versio
787
885
  import { dirname as dirname5 } from "node:path";
788
886
  import matter4 from "gray-matter";
789
887
  import { satisfies as satisfies3, validRange as validRange2 } from "semver";
790
- var getMessageBySchemaPath = (directory) => async (path6, options) => {
791
- const pathToMessage = dirname5(path6);
888
+ var getMessageBySchemaPath = (directory) => async (path7, options) => {
889
+ const pathToMessage = dirname5(path7);
792
890
  try {
793
891
  const files = await getFiles(`${directory}/${pathToMessage}/index.{md,mdx}`);
794
892
  if (!files || files.length === 0) {
@@ -796,13 +894,13 @@ var getMessageBySchemaPath = (directory) => async (path6, options) => {
796
894
  }
797
895
  const messageFile = files[0];
798
896
  const { data } = matter4.read(messageFile);
799
- const { id, version } = data;
800
- if (!id || !version) {
897
+ const { id, version: version2 } = data;
898
+ if (!id || !version2) {
801
899
  throw new Error(`Message definition file at ${messageFile} is missing 'id' or 'version' in its frontmatter.`);
802
900
  }
803
- const message = await getResource(directory, id, version, { type: "message", ...options });
901
+ const message = await getResource(directory, id, version2, { type: "message", ...options });
804
902
  if (!message) {
805
- 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}.`);
806
904
  }
807
905
  return message;
808
906
  } catch (error) {
@@ -813,12 +911,12 @@ var getMessageBySchemaPath = (directory) => async (path6, options) => {
813
911
  throw new Error(`Failed to retrieve message from ${pathToMessage} due to an unknown error.`);
814
912
  }
815
913
  };
816
- var getProducersAndConsumersForMessage = (directory) => async (id, version, options) => {
914
+ var getProducersAndConsumersForMessage = (directory) => async (id, version2, options) => {
817
915
  const services = await getServices(directory)({ latestOnly: options?.latestOnly ?? true });
818
- const message = await getResource(directory, id, version, { type: "message" });
819
- 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);
820
918
  if (!message) {
821
- 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.`);
822
920
  }
823
921
  const producers = [];
824
922
  const consumers = [];
@@ -860,18 +958,18 @@ var getProducersAndConsumersForMessage = (directory) => async (id, version, opti
860
958
  }
861
959
  return { producers, consumers };
862
960
  };
863
- var getConsumersOfSchema = (directory) => async (path6) => {
961
+ var getConsumersOfSchema = (directory) => async (path7) => {
864
962
  try {
865
- const message = await getMessageBySchemaPath(directory)(path6);
963
+ const message = await getMessageBySchemaPath(directory)(path7);
866
964
  const { consumers } = await getProducersAndConsumersForMessage(directory)(message.id, message.version);
867
965
  return consumers;
868
966
  } catch (error) {
869
967
  return [];
870
968
  }
871
969
  };
872
- var getProducersOfSchema = (directory) => async (path6) => {
970
+ var getProducersOfSchema = (directory) => async (path7) => {
873
971
  try {
874
- const message = await getMessageBySchemaPath(directory)(path6);
972
+ const message = await getMessageBySchemaPath(directory)(path7);
875
973
  const { producers } = await getProducersAndConsumersForMessage(directory)(message.id, message.version);
876
974
  return producers;
877
975
  } catch (error) {
@@ -880,13 +978,13 @@ var getProducersOfSchema = (directory) => async (path6) => {
880
978
  };
881
979
 
882
980
  // src/custom-docs.ts
883
- import path3, { join as join10 } from "node:path";
981
+ import path4, { join as join10 } from "node:path";
884
982
  import fsSync4 from "node:fs";
885
983
  import fs8 from "node:fs/promises";
886
984
  import matter5 from "gray-matter";
887
985
  import slugify from "slugify";
888
986
  var getCustomDoc = (directory) => async (filePath) => {
889
- const fullPath = path3.join(directory, filePath);
987
+ const fullPath = path4.join(directory, filePath);
890
988
  const fullPathWithExtension = fullPath.endsWith(".mdx") ? fullPath : `${fullPath}.mdx`;
891
989
  const fileExists = fsSync4.existsSync(fullPathWithExtension);
892
990
  if (!fileExists) {
@@ -905,8 +1003,8 @@ var writeCustomDoc = (directory) => async (customDoc, options = { path: "" }) =>
905
1003
  const { fileName, ...rest } = customDoc;
906
1004
  const name = fileName || slugify(customDoc.title, { lower: true });
907
1005
  const withExtension = name.endsWith(".mdx") ? name : `${name}.mdx`;
908
- const fullPath = path3.join(directory, options.path || "", withExtension);
909
- fsSync4.mkdirSync(path3.dirname(fullPath), { recursive: true });
1006
+ const fullPath = path4.join(directory, options.path || "", withExtension);
1007
+ fsSync4.mkdirSync(path4.dirname(fullPath), { recursive: true });
910
1008
  const document = matter5.stringify(customDoc.markdown.trim(), rest);
911
1009
  fsSync4.writeFileSync(fullPath, document);
912
1010
  };
@@ -920,7 +1018,7 @@ import fs9 from "node:fs/promises";
920
1018
  import fsSync6 from "node:fs";
921
1019
  import { join as join12 } from "node:path";
922
1020
  import matter7 from "gray-matter";
923
- import path4 from "node:path";
1021
+ import path5 from "node:path";
924
1022
 
925
1023
  // src/users.ts
926
1024
  import fsSync5 from "node:fs";
@@ -1010,17 +1108,17 @@ var writeTeam = (catalogDir) => async (team, options = {}) => {
1010
1108
  var rmTeamById = (catalogDir) => async (id) => {
1011
1109
  await fs9.rm(join12(catalogDir, `${id}.mdx`), { recursive: true });
1012
1110
  };
1013
- var getOwnersForResource = (catalogDir) => async (id, version) => {
1014
- const resource = await getResource(catalogDir, id, version);
1111
+ var getOwnersForResource = (catalogDir) => async (id, version2) => {
1112
+ const resource = await getResource(catalogDir, id, version2);
1015
1113
  let owners = [];
1016
1114
  if (!resource) return [];
1017
1115
  if (!resource.owners) return [];
1018
1116
  for (const owner of resource.owners) {
1019
- const team = await getTeam(path4.join(catalogDir, "teams"))(owner);
1117
+ const team = await getTeam(path5.join(catalogDir, "teams"))(owner);
1020
1118
  if (team) {
1021
1119
  owners.push(team);
1022
1120
  } else {
1023
- const user = await getUser(path4.join(catalogDir, "users"))(owner);
1121
+ const user = await getUser(path5.join(catalogDir, "users"))(owner);
1024
1122
  if (user) {
1025
1123
  owners.push(user);
1026
1124
  }
@@ -1029,32 +1127,129 @@ var getOwnersForResource = (catalogDir) => async (id, version) => {
1029
1127
  return owners;
1030
1128
  };
1031
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
+
1032
1227
  // src/entities.ts
1033
- import fs10 from "node:fs/promises";
1034
- import { join as join13 } from "node:path";
1035
- 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" });
1036
1231
  var getEntities = (directory) => async (options) => getResources(directory, { type: "entities", latestOnly: options?.latestOnly });
1037
1232
  var writeEntity = (directory) => async (entity, options = {
1038
1233
  path: "",
1039
1234
  override: false,
1040
1235
  format: "mdx"
1041
1236
  }) => writeResource(directory, { ...entity }, { ...options, type: "entity" });
1042
- var rmEntity = (directory) => async (path6) => {
1043
- await fs10.rm(join13(directory, path6), { recursive: true });
1237
+ var rmEntity = (directory) => async (path7) => {
1238
+ await fs11.rm(join14(directory, path7), { recursive: true });
1044
1239
  };
1045
- var rmEntityById = (directory) => async (id, version, persistFiles) => {
1046
- 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 });
1047
1242
  };
1048
1243
  var versionEntity = (directory) => async (id) => versionResource(directory, id);
1049
- var entityHasVersion = (directory) => async (id, version) => {
1050
- const file = await findFileById(directory, id, version);
1244
+ var entityHasVersion = (directory) => async (id, version2) => {
1245
+ const file = await findFileById(directory, id, version2);
1051
1246
  return !!file;
1052
1247
  };
1053
1248
 
1054
1249
  // src/containers.ts
1055
- import fs11 from "node:fs/promises";
1056
- import { join as join14 } from "node:path";
1057
- 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" });
1058
1253
  var getContainers = (directory) => async (options) => getResources(directory, { type: "containers", latestOnly: options?.latestOnly });
1059
1254
  var writeContainer = (directory) => async (data, options = {
1060
1255
  path: "",
@@ -1062,24 +1257,24 @@ var writeContainer = (directory) => async (data, options = {
1062
1257
  format: "mdx"
1063
1258
  }) => writeResource(directory, { ...data }, { ...options, type: "container" });
1064
1259
  var versionContainer = (directory) => async (id) => versionResource(directory, id);
1065
- var rmContainer = (directory) => async (path6) => {
1066
- await fs11.rm(join14(directory, path6), { recursive: true });
1260
+ var rmContainer = (directory) => async (path7) => {
1261
+ await fs12.rm(join15(directory, path7), { recursive: true });
1067
1262
  };
1068
- var rmContainerById = (directory) => async (id, version, persistFiles) => {
1069
- 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 });
1070
1265
  };
1071
- var containerHasVersion = (directory) => async (id, version) => {
1072
- const file = await findFileById(directory, id, version);
1266
+ var containerHasVersion = (directory) => async (id, version2) => {
1267
+ const file = await findFileById(directory, id, version2);
1073
1268
  return !!file;
1074
1269
  };
1075
- 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);
1076
1271
  var writeContainerToService = (directory) => async (container, service, options = { path: "", format: "mdx", override: false }) => {
1077
1272
  const resourcePath = await getResourcePath(directory, service.id, service.version);
1078
1273
  if (!resourcePath) {
1079
1274
  throw new Error("Service not found");
1080
1275
  }
1081
1276
  let pathForContainer = service.version && service.version !== "latest" ? `${resourcePath.directory}/versioned/${service.version}/containers` : `${resourcePath.directory}/containers`;
1082
- pathForContainer = join14(pathForContainer, container.id);
1277
+ pathForContainer = join15(pathForContainer, container.id);
1083
1278
  await writeResource(directory, { ...container }, { ...options, path: pathForContainer, type: "container" });
1084
1279
  };
1085
1280
 
@@ -1094,8 +1289,36 @@ var dataStoreHasVersion = containerHasVersion;
1094
1289
  var addFileToDataStore = addFileToContainer;
1095
1290
  var writeDataStoreToService = writeContainerToService;
1096
1291
 
1292
+ // src/data-products.ts
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" });
1296
+ var getDataProducts = (directory) => async (options) => getResources(directory, { type: "data-products", latestOnly: options?.latestOnly });
1297
+ var writeDataProduct = (directory) => async (dataProduct, options = {
1298
+ path: "",
1299
+ override: false,
1300
+ format: "mdx"
1301
+ }) => writeResource(directory, { ...dataProduct }, { ...options, type: "data-product" });
1302
+ var writeDataProductToDomain = (directory) => async (dataProduct, domain, options = { path: "", format: "mdx", override: false }) => {
1303
+ let pathForDataProduct = domain.version && domain.version !== "latest" ? `/${domain.id}/versioned/${domain.version}/data-products` : `/${domain.id}/data-products`;
1304
+ pathForDataProduct = join16(pathForDataProduct, dataProduct.id);
1305
+ await writeResource(directory, { ...dataProduct }, { ...options, path: pathForDataProduct, type: "data-product" });
1306
+ };
1307
+ var rmDataProduct = (directory) => async (path7) => {
1308
+ await fs13.rm(join16(directory, path7), { recursive: true });
1309
+ };
1310
+ var rmDataProductById = (directory) => async (id, version2, persistFiles) => {
1311
+ await rmResourceById(directory, id, version2, { type: "data-product", persistFiles });
1312
+ };
1313
+ var versionDataProduct = (directory) => async (id) => versionResource(directory, id);
1314
+ var dataProductHasVersion = (directory) => async (id, version2) => {
1315
+ const file = await findFileById(directory, id, version2);
1316
+ return !!file;
1317
+ };
1318
+ var addFileToDataProduct = (directory) => async (id, file, version2) => addFileToResource(directory, id, file, version2);
1319
+
1097
1320
  // src/index.ts
1098
- var src_default = (path6) => {
1321
+ var src_default = (path7) => {
1099
1322
  return {
1100
1323
  /**
1101
1324
  * Returns an events from EventCatalog
@@ -1103,13 +1326,13 @@ var src_default = (path6) => {
1103
1326
  * @param version - Optional id of the version to get (supports semver)
1104
1327
  * @returns Event|Undefined
1105
1328
  */
1106
- getEvent: getEvent(join15(path6)),
1329
+ getEvent: getEvent(join17(path7)),
1107
1330
  /**
1108
1331
  * Returns all events from EventCatalog
1109
1332
  * @param latestOnly - optional boolean, set to true to get only latest versions
1110
1333
  * @returns Event[]|Undefined
1111
1334
  */
1112
- getEvents: getEvents(join15(path6)),
1335
+ getEvents: getEvents(join17(path7)),
1113
1336
  /**
1114
1337
  * Adds an event to EventCatalog
1115
1338
  *
@@ -1117,7 +1340,7 @@ var src_default = (path6) => {
1117
1340
  * @param options - Optional options to write the event
1118
1341
  *
1119
1342
  */
1120
- writeEvent: writeEvent(join15(path6, "events")),
1343
+ writeEvent: writeEvent(join17(path7, "events")),
1121
1344
  /**
1122
1345
  * Adds an event to a service in EventCatalog
1123
1346
  *
@@ -1126,26 +1349,26 @@ var src_default = (path6) => {
1126
1349
  * @param options - Optional options to write the event
1127
1350
  *
1128
1351
  */
1129
- writeEventToService: writeEventToService(join15(path6)),
1352
+ writeEventToService: writeEventToService(join17(path7)),
1130
1353
  /**
1131
1354
  * Remove an event to EventCatalog (modeled on the standard POSIX rm utility)
1132
1355
  *
1133
1356
  * @param path - The path to your event, e.g. `/Inventory/InventoryAdjusted`
1134
1357
  *
1135
1358
  */
1136
- rmEvent: rmEvent(join15(path6, "events")),
1359
+ rmEvent: rmEvent(join17(path7, "events")),
1137
1360
  /**
1138
1361
  * Remove an event by an Event id
1139
1362
  *
1140
1363
  * @param id - The id of the event you want to remove
1141
1364
  *
1142
1365
  */
1143
- rmEventById: rmEventById(join15(path6)),
1366
+ rmEventById: rmEventById(join17(path7)),
1144
1367
  /**
1145
1368
  * Moves a given event id to the version directory
1146
1369
  * @param directory
1147
1370
  */
1148
- versionEvent: versionEvent(join15(path6)),
1371
+ versionEvent: versionEvent(join17(path7)),
1149
1372
  /**
1150
1373
  * Adds a file to the given event
1151
1374
  * @param id - The id of the event to add the file to
@@ -1153,7 +1376,7 @@ var src_default = (path6) => {
1153
1376
  * @param version - Optional version of the event to add the file to
1154
1377
  * @returns
1155
1378
  */
1156
- addFileToEvent: addFileToEvent(join15(path6)),
1379
+ addFileToEvent: addFileToEvent(join17(path7)),
1157
1380
  /**
1158
1381
  * Adds a schema to the given event
1159
1382
  * @param id - The id of the event to add the schema to
@@ -1161,14 +1384,14 @@ var src_default = (path6) => {
1161
1384
  * @param version - Optional version of the event to add the schema to
1162
1385
  * @returns
1163
1386
  */
1164
- addSchemaToEvent: addSchemaToEvent(join15(path6)),
1387
+ addSchemaToEvent: addSchemaToEvent(join17(path7)),
1165
1388
  /**
1166
1389
  * Check to see if an event version exists
1167
1390
  * @param id - The id of the event
1168
1391
  * @param version - The version of the event (supports semver)
1169
1392
  * @returns
1170
1393
  */
1171
- eventHasVersion: eventHasVersion(join15(path6)),
1394
+ eventHasVersion: eventHasVersion(join17(path7)),
1172
1395
  /**
1173
1396
  * ================================
1174
1397
  * Commands
@@ -1180,13 +1403,13 @@ var src_default = (path6) => {
1180
1403
  * @param version - Optional id of the version to get (supports semver)
1181
1404
  * @returns Command|Undefined
1182
1405
  */
1183
- getCommand: getCommand(join15(path6)),
1406
+ getCommand: getCommand(join17(path7)),
1184
1407
  /**
1185
1408
  * Returns all commands from EventCatalog
1186
1409
  * @param latestOnly - optional boolean, set to true to get only latest versions
1187
1410
  * @returns Command[]|Undefined
1188
1411
  */
1189
- getCommands: getCommands(join15(path6)),
1412
+ getCommands: getCommands(join17(path7)),
1190
1413
  /**
1191
1414
  * Adds an command to EventCatalog
1192
1415
  *
@@ -1194,7 +1417,7 @@ var src_default = (path6) => {
1194
1417
  * @param options - Optional options to write the command
1195
1418
  *
1196
1419
  */
1197
- writeCommand: writeCommand(join15(path6, "commands")),
1420
+ writeCommand: writeCommand(join17(path7, "commands")),
1198
1421
  /**
1199
1422
  * Adds a command to a service in EventCatalog
1200
1423
  *
@@ -1203,26 +1426,26 @@ var src_default = (path6) => {
1203
1426
  * @param options - Optional options to write the command
1204
1427
  *
1205
1428
  */
1206
- writeCommandToService: writeCommandToService(join15(path6)),
1429
+ writeCommandToService: writeCommandToService(join17(path7)),
1207
1430
  /**
1208
1431
  * Remove an command to EventCatalog (modeled on the standard POSIX rm utility)
1209
1432
  *
1210
1433
  * @param path - The path to your command, e.g. `/Inventory/InventoryAdjusted`
1211
1434
  *
1212
1435
  */
1213
- rmCommand: rmCommand(join15(path6, "commands")),
1436
+ rmCommand: rmCommand(join17(path7, "commands")),
1214
1437
  /**
1215
1438
  * Remove an command by an Event id
1216
1439
  *
1217
1440
  * @param id - The id of the command you want to remove
1218
1441
  *
1219
1442
  */
1220
- rmCommandById: rmCommandById(join15(path6)),
1443
+ rmCommandById: rmCommandById(join17(path7)),
1221
1444
  /**
1222
1445
  * Moves a given command id to the version directory
1223
1446
  * @param directory
1224
1447
  */
1225
- versionCommand: versionCommand(join15(path6)),
1448
+ versionCommand: versionCommand(join17(path7)),
1226
1449
  /**
1227
1450
  * Adds a file to the given command
1228
1451
  * @param id - The id of the command to add the file to
@@ -1230,7 +1453,7 @@ var src_default = (path6) => {
1230
1453
  * @param version - Optional version of the command to add the file to
1231
1454
  * @returns
1232
1455
  */
1233
- addFileToCommand: addFileToCommand(join15(path6)),
1456
+ addFileToCommand: addFileToCommand(join17(path7)),
1234
1457
  /**
1235
1458
  * Adds a schema to the given command
1236
1459
  * @param id - The id of the command to add the schema to
@@ -1238,14 +1461,14 @@ var src_default = (path6) => {
1238
1461
  * @param version - Optional version of the command to add the schema to
1239
1462
  * @returns
1240
1463
  */
1241
- addSchemaToCommand: addSchemaToCommand(join15(path6)),
1464
+ addSchemaToCommand: addSchemaToCommand(join17(path7)),
1242
1465
  /**
1243
1466
  * Check to see if a command version exists
1244
1467
  * @param id - The id of the command
1245
1468
  * @param version - The version of the command (supports semver)
1246
1469
  * @returns
1247
1470
  */
1248
- commandHasVersion: commandHasVersion(join15(path6)),
1471
+ commandHasVersion: commandHasVersion(join17(path7)),
1249
1472
  /**
1250
1473
  * ================================
1251
1474
  * Queries
@@ -1257,13 +1480,13 @@ var src_default = (path6) => {
1257
1480
  * @param version - Optional id of the version to get (supports semver)
1258
1481
  * @returns Query|Undefined
1259
1482
  */
1260
- getQuery: getQuery(join15(path6)),
1483
+ getQuery: getQuery(join17(path7)),
1261
1484
  /**
1262
1485
  * Returns all queries from EventCatalog
1263
1486
  * @param latestOnly - optional boolean, set to true to get only latest versions
1264
1487
  * @returns Query[]|Undefined
1265
1488
  */
1266
- getQueries: getQueries(join15(path6)),
1489
+ getQueries: getQueries(join17(path7)),
1267
1490
  /**
1268
1491
  * Adds a query to EventCatalog
1269
1492
  *
@@ -1271,7 +1494,7 @@ var src_default = (path6) => {
1271
1494
  * @param options - Optional options to write the event
1272
1495
  *
1273
1496
  */
1274
- writeQuery: writeQuery(join15(path6, "queries")),
1497
+ writeQuery: writeQuery(join17(path7, "queries")),
1275
1498
  /**
1276
1499
  * Adds a query to a service in EventCatalog
1277
1500
  *
@@ -1280,26 +1503,26 @@ var src_default = (path6) => {
1280
1503
  * @param options - Optional options to write the query
1281
1504
  *
1282
1505
  */
1283
- writeQueryToService: writeQueryToService(join15(path6)),
1506
+ writeQueryToService: writeQueryToService(join17(path7)),
1284
1507
  /**
1285
1508
  * Remove an query to EventCatalog (modeled on the standard POSIX rm utility)
1286
1509
  *
1287
1510
  * @param path - The path to your query, e.g. `/Orders/GetOrder`
1288
1511
  *
1289
1512
  */
1290
- rmQuery: rmQuery(join15(path6, "queries")),
1513
+ rmQuery: rmQuery(join17(path7, "queries")),
1291
1514
  /**
1292
1515
  * Remove a query by a Query id
1293
1516
  *
1294
1517
  * @param id - The id of the query you want to remove
1295
1518
  *
1296
1519
  */
1297
- rmQueryById: rmQueryById(join15(path6)),
1520
+ rmQueryById: rmQueryById(join17(path7)),
1298
1521
  /**
1299
1522
  * Moves a given query id to the version directory
1300
1523
  * @param directory
1301
1524
  */
1302
- versionQuery: versionQuery(join15(path6)),
1525
+ versionQuery: versionQuery(join17(path7)),
1303
1526
  /**
1304
1527
  * Adds a file to the given query
1305
1528
  * @param id - The id of the query to add the file to
@@ -1307,7 +1530,7 @@ var src_default = (path6) => {
1307
1530
  * @param version - Optional version of the query to add the file to
1308
1531
  * @returns
1309
1532
  */
1310
- addFileToQuery: addFileToQuery(join15(path6)),
1533
+ addFileToQuery: addFileToQuery(join17(path7)),
1311
1534
  /**
1312
1535
  * Adds a schema to the given query
1313
1536
  * @param id - The id of the query to add the schema to
@@ -1315,14 +1538,14 @@ var src_default = (path6) => {
1315
1538
  * @param version - Optional version of the query to add the schema to
1316
1539
  * @returns
1317
1540
  */
1318
- addSchemaToQuery: addSchemaToQuery(join15(path6)),
1541
+ addSchemaToQuery: addSchemaToQuery(join17(path7)),
1319
1542
  /**
1320
1543
  * Check to see if an query version exists
1321
1544
  * @param id - The id of the query
1322
1545
  * @param version - The version of the query (supports semver)
1323
1546
  * @returns
1324
1547
  */
1325
- queryHasVersion: queryHasVersion(join15(path6)),
1548
+ queryHasVersion: queryHasVersion(join17(path7)),
1326
1549
  /**
1327
1550
  * ================================
1328
1551
  * Channels
@@ -1334,13 +1557,13 @@ var src_default = (path6) => {
1334
1557
  * @param version - Optional id of the version to get (supports semver)
1335
1558
  * @returns Channel|Undefined
1336
1559
  */
1337
- getChannel: getChannel(join15(path6)),
1560
+ getChannel: getChannel(join17(path7)),
1338
1561
  /**
1339
1562
  * Returns all channels from EventCatalog
1340
1563
  * @param latestOnly - optional boolean, set to true to get only latest versions
1341
1564
  * @returns Channel[]|Undefined
1342
1565
  */
1343
- getChannels: getChannels(join15(path6)),
1566
+ getChannels: getChannels(join17(path7)),
1344
1567
  /**
1345
1568
  * Adds an channel to EventCatalog
1346
1569
  *
@@ -1348,33 +1571,33 @@ var src_default = (path6) => {
1348
1571
  * @param options - Optional options to write the channel
1349
1572
  *
1350
1573
  */
1351
- writeChannel: writeChannel(join15(path6, "channels")),
1574
+ writeChannel: writeChannel(join17(path7, "channels")),
1352
1575
  /**
1353
1576
  * Remove an channel to EventCatalog (modeled on the standard POSIX rm utility)
1354
1577
  *
1355
1578
  * @param path - The path to your channel, e.g. `/Inventory/InventoryAdjusted`
1356
1579
  *
1357
1580
  */
1358
- rmChannel: rmChannel(join15(path6, "channels")),
1581
+ rmChannel: rmChannel(join17(path7, "channels")),
1359
1582
  /**
1360
1583
  * Remove an channel by an Event id
1361
1584
  *
1362
1585
  * @param id - The id of the channel you want to remove
1363
1586
  *
1364
1587
  */
1365
- rmChannelById: rmChannelById(join15(path6)),
1588
+ rmChannelById: rmChannelById(join17(path7)),
1366
1589
  /**
1367
1590
  * Moves a given channel id to the version directory
1368
1591
  * @param directory
1369
1592
  */
1370
- versionChannel: versionChannel(join15(path6)),
1593
+ versionChannel: versionChannel(join17(path7)),
1371
1594
  /**
1372
1595
  * Check to see if a channel version exists
1373
1596
  * @param id - The id of the channel
1374
1597
  * @param version - The version of the channel (supports semver)
1375
1598
  * @returns
1376
1599
  */
1377
- channelHasVersion: channelHasVersion(join15(path6)),
1600
+ channelHasVersion: channelHasVersion(join17(path7)),
1378
1601
  /**
1379
1602
  * Add a channel to an event
1380
1603
  *
@@ -1391,7 +1614,7 @@ var src_default = (path6) => {
1391
1614
  *
1392
1615
  * ```
1393
1616
  */
1394
- addEventToChannel: addMessageToChannel(join15(path6), "events"),
1617
+ addEventToChannel: addMessageToChannel(join17(path7), "events"),
1395
1618
  /**
1396
1619
  * Add a channel to an command
1397
1620
  *
@@ -1408,7 +1631,7 @@ var src_default = (path6) => {
1408
1631
  *
1409
1632
  * ```
1410
1633
  */
1411
- addCommandToChannel: addMessageToChannel(join15(path6), "commands"),
1634
+ addCommandToChannel: addMessageToChannel(join17(path7), "commands"),
1412
1635
  /**
1413
1636
  * Add a channel to an query
1414
1637
  *
@@ -1425,7 +1648,7 @@ var src_default = (path6) => {
1425
1648
  *
1426
1649
  * ```
1427
1650
  */
1428
- addQueryToChannel: addMessageToChannel(join15(path6), "queries"),
1651
+ addQueryToChannel: addMessageToChannel(join17(path7), "queries"),
1429
1652
  /**
1430
1653
  * ================================
1431
1654
  * SERVICES
@@ -1438,14 +1661,14 @@ var src_default = (path6) => {
1438
1661
  * @param options - Optional options to write the event
1439
1662
  *
1440
1663
  */
1441
- writeService: writeService(join15(path6, "services")),
1664
+ writeService: writeService(join17(path7, "services")),
1442
1665
  /**
1443
1666
  * Adds a versioned service to EventCatalog
1444
1667
  *
1445
1668
  * @param service - The service to write
1446
1669
  *
1447
1670
  */
1448
- writeVersionedService: writeVersionedService(join15(path6, "services")),
1671
+ writeVersionedService: writeVersionedService(join17(path7, "services")),
1449
1672
  /**
1450
1673
  * Adds a service to a domain in EventCatalog
1451
1674
  *
@@ -1454,45 +1677,45 @@ var src_default = (path6) => {
1454
1677
  * @param options - Optional options to write the event
1455
1678
  *
1456
1679
  */
1457
- writeServiceToDomain: writeServiceToDomain(join15(path6, "domains")),
1680
+ writeServiceToDomain: writeServiceToDomain(join17(path7, "domains")),
1458
1681
  /**
1459
1682
  * Returns a service from EventCatalog
1460
1683
  * @param id - The id of the service to retrieve
1461
1684
  * @param version - Optional id of the version to get (supports semver)
1462
1685
  * @returns Service|Undefined
1463
1686
  */
1464
- getService: getService(join15(path6)),
1687
+ getService: getService(join17(path7)),
1465
1688
  /**
1466
1689
  * Returns a service from EventCatalog by it's path.
1467
1690
  * @param path - The path to the service to retrieve
1468
1691
  * @returns Service|Undefined
1469
1692
  */
1470
- getServiceByPath: getServiceByPath(join15(path6)),
1693
+ getServiceByPath: getServiceByPath(join17(path7)),
1471
1694
  /**
1472
1695
  * Returns all services from EventCatalog
1473
1696
  * @param latestOnly - optional boolean, set to true to get only latest versions
1474
1697
  * @returns Service[]|Undefined
1475
1698
  */
1476
- getServices: getServices(join15(path6)),
1699
+ getServices: getServices(join17(path7)),
1477
1700
  /**
1478
1701
  * Moves a given service id to the version directory
1479
1702
  * @param directory
1480
1703
  */
1481
- versionService: versionService(join15(path6)),
1704
+ versionService: versionService(join17(path7)),
1482
1705
  /**
1483
1706
  * Remove a service from EventCatalog (modeled on the standard POSIX rm utility)
1484
1707
  *
1485
1708
  * @param path - The path to your service, e.g. `/InventoryService`
1486
1709
  *
1487
1710
  */
1488
- rmService: rmService(join15(path6, "services")),
1711
+ rmService: rmService(join17(path7, "services")),
1489
1712
  /**
1490
1713
  * Remove an service by an service id
1491
1714
  *
1492
1715
  * @param id - The id of the service you want to remove
1493
1716
  *
1494
1717
  */
1495
- rmServiceById: rmServiceById(join15(path6)),
1718
+ rmServiceById: rmServiceById(join17(path7)),
1496
1719
  /**
1497
1720
  * Adds a file to the given service
1498
1721
  * @param id - The id of the service to add the file to
@@ -1500,21 +1723,21 @@ var src_default = (path6) => {
1500
1723
  * @param version - Optional version of the service to add the file to
1501
1724
  * @returns
1502
1725
  */
1503
- addFileToService: addFileToService(join15(path6)),
1726
+ addFileToService: addFileToService(join17(path7)),
1504
1727
  /**
1505
1728
  * Returns the specifications for a given service
1506
1729
  * @param id - The id of the service to retrieve the specifications for
1507
1730
  * @param version - Optional version of the service
1508
1731
  * @returns
1509
1732
  */
1510
- getSpecificationFilesForService: getSpecificationFilesForService(join15(path6)),
1733
+ getSpecificationFilesForService: getSpecificationFilesForService(join17(path7)),
1511
1734
  /**
1512
1735
  * Check to see if a service version exists
1513
1736
  * @param id - The id of the service
1514
1737
  * @param version - The version of the service (supports semver)
1515
1738
  * @returns
1516
1739
  */
1517
- serviceHasVersion: serviceHasVersion(join15(path6)),
1740
+ serviceHasVersion: serviceHasVersion(join17(path7)),
1518
1741
  /**
1519
1742
  * Add an event to a service by it's id.
1520
1743
  *
@@ -1534,7 +1757,7 @@ var src_default = (path6) => {
1534
1757
  *
1535
1758
  * ```
1536
1759
  */
1537
- addEventToService: addMessageToService(join15(path6)),
1760
+ addEventToService: addMessageToService(join17(path7)),
1538
1761
  /**
1539
1762
  * Add a data store to a service by it's id.
1540
1763
  *
@@ -1551,7 +1774,7 @@ var src_default = (path6) => {
1551
1774
  *
1552
1775
  * ```
1553
1776
  */
1554
- addDataStoreToService: addDataStoreToService(join15(path6)),
1777
+ addDataStoreToService: addDataStoreToService(join17(path7)),
1555
1778
  /**
1556
1779
  * Add a command to a service by it's id.
1557
1780
  *
@@ -1571,7 +1794,7 @@ var src_default = (path6) => {
1571
1794
  *
1572
1795
  * ```
1573
1796
  */
1574
- addCommandToService: addMessageToService(join15(path6)),
1797
+ addCommandToService: addMessageToService(join17(path7)),
1575
1798
  /**
1576
1799
  * Add a query to a service by it's id.
1577
1800
  *
@@ -1591,7 +1814,7 @@ var src_default = (path6) => {
1591
1814
  *
1592
1815
  * ```
1593
1816
  */
1594
- addQueryToService: addMessageToService(join15(path6)),
1817
+ addQueryToService: addMessageToService(join17(path7)),
1595
1818
  /**
1596
1819
  * Add an entity to a service by its id.
1597
1820
  *
@@ -1609,7 +1832,7 @@ var src_default = (path6) => {
1609
1832
  *
1610
1833
  * ```
1611
1834
  */
1612
- addEntityToService: addEntityToService(join15(path6)),
1835
+ addEntityToService: addEntityToService(join17(path7)),
1613
1836
  /**
1614
1837
  * Check to see if a service exists by it's path.
1615
1838
  *
@@ -1626,13 +1849,13 @@ var src_default = (path6) => {
1626
1849
  * @param path - The path to the service to check
1627
1850
  * @returns boolean
1628
1851
  */
1629
- isService: isService(join15(path6)),
1852
+ isService: isService(join17(path7)),
1630
1853
  /**
1631
1854
  * Converts a file to a service.
1632
1855
  * @param file - The file to convert to a service.
1633
1856
  * @returns The service.
1634
1857
  */
1635
- toService: toService(join15(path6)),
1858
+ toService: toService(join17(path7)),
1636
1859
  /**
1637
1860
  * ================================
1638
1861
  * Domains
@@ -1645,39 +1868,39 @@ var src_default = (path6) => {
1645
1868
  * @param options - Optional options to write the event
1646
1869
  *
1647
1870
  */
1648
- writeDomain: writeDomain(join15(path6, "domains")),
1871
+ writeDomain: writeDomain(join17(path7, "domains")),
1649
1872
  /**
1650
1873
  * Returns a domain from EventCatalog
1651
1874
  * @param id - The id of the domain to retrieve
1652
1875
  * @param version - Optional id of the version to get (supports semver)
1653
1876
  * @returns Domain|Undefined
1654
1877
  */
1655
- getDomain: getDomain(join15(path6, "domains")),
1878
+ getDomain: getDomain(join17(path7, "domains")),
1656
1879
  /**
1657
1880
  * Returns all domains from EventCatalog
1658
1881
  * @param latestOnly - optional boolean, set to true to get only latest versions
1659
1882
  * @returns Domain[]|Undefined
1660
1883
  */
1661
- getDomains: getDomains(join15(path6)),
1884
+ getDomains: getDomains(join17(path7)),
1662
1885
  /**
1663
1886
  * Moves a given domain id to the version directory
1664
1887
  * @param directory
1665
1888
  */
1666
- versionDomain: versionDomain(join15(path6, "domains")),
1889
+ versionDomain: versionDomain(join17(path7, "domains")),
1667
1890
  /**
1668
1891
  * Remove a domain from EventCatalog (modeled on the standard POSIX rm utility)
1669
1892
  *
1670
1893
  * @param path - The path to your domain, e.g. `/Payment`
1671
1894
  *
1672
1895
  */
1673
- rmDomain: rmDomain(join15(path6, "domains")),
1896
+ rmDomain: rmDomain(join17(path7, "domains")),
1674
1897
  /**
1675
1898
  * Remove an service by an domain id
1676
1899
  *
1677
1900
  * @param id - The id of the domain you want to remove
1678
1901
  *
1679
1902
  */
1680
- rmDomainById: rmDomainById(join15(path6, "domains")),
1903
+ rmDomainById: rmDomainById(join17(path7, "domains")),
1681
1904
  /**
1682
1905
  * Adds a file to the given domain
1683
1906
  * @param id - The id of the domain to add the file to
@@ -1685,28 +1908,28 @@ var src_default = (path6) => {
1685
1908
  * @param version - Optional version of the domain to add the file to
1686
1909
  * @returns
1687
1910
  */
1688
- addFileToDomain: addFileToDomain(join15(path6, "domains")),
1911
+ addFileToDomain: addFileToDomain(join17(path7, "domains")),
1689
1912
  /**
1690
1913
  * Adds an ubiquitous language dictionary to a domain
1691
1914
  * @param id - The id of the domain to add the ubiquitous language to
1692
1915
  * @param ubiquitousLanguageDictionary - The ubiquitous language dictionary to add
1693
1916
  * @param version - Optional version of the domain to add the ubiquitous language to
1694
1917
  */
1695
- addUbiquitousLanguageToDomain: addUbiquitousLanguageToDomain(join15(path6, "domains")),
1918
+ addUbiquitousLanguageToDomain: addUbiquitousLanguageToDomain(join17(path7, "domains")),
1696
1919
  /**
1697
1920
  * Get the ubiquitous language dictionary from a domain
1698
1921
  * @param id - The id of the domain to get the ubiquitous language from
1699
1922
  * @param version - Optional version of the domain to get the ubiquitous language from
1700
1923
  * @returns
1701
1924
  */
1702
- getUbiquitousLanguageFromDomain: getUbiquitousLanguageFromDomain(join15(path6, "domains")),
1925
+ getUbiquitousLanguageFromDomain: getUbiquitousLanguageFromDomain(join17(path7, "domains")),
1703
1926
  /**
1704
1927
  * Check to see if a domain version exists
1705
1928
  * @param id - The id of the domain
1706
1929
  * @param version - The version of the domain (supports semver)
1707
1930
  * @returns
1708
1931
  */
1709
- domainHasVersion: domainHasVersion(join15(path6)),
1932
+ domainHasVersion: domainHasVersion(join17(path7)),
1710
1933
  /**
1711
1934
  * Adds a given service to a domain
1712
1935
  * @param id - The id of the domain
@@ -1714,7 +1937,7 @@ var src_default = (path6) => {
1714
1937
  * @param version - (Optional) The version of the domain to add the service to
1715
1938
  * @returns
1716
1939
  */
1717
- addServiceToDomain: addServiceToDomain(join15(path6, "domains")),
1940
+ addServiceToDomain: addServiceToDomain(join17(path7, "domains")),
1718
1941
  /**
1719
1942
  * Adds a given subdomain to a domain
1720
1943
  * @param id - The id of the domain
@@ -1722,7 +1945,7 @@ var src_default = (path6) => {
1722
1945
  * @param version - (Optional) The version of the domain to add the subdomain to
1723
1946
  * @returns
1724
1947
  */
1725
- addSubDomainToDomain: addSubDomainToDomain(join15(path6, "domains")),
1948
+ addSubDomainToDomain: addSubDomainToDomain(join17(path7, "domains")),
1726
1949
  /**
1727
1950
  * Adds an entity to a domain
1728
1951
  * @param id - The id of the domain
@@ -1730,7 +1953,61 @@ var src_default = (path6) => {
1730
1953
  * @param version - (Optional) The version of the domain to add the entity to
1731
1954
  * @returns
1732
1955
  */
1733
- addEntityToDomain: addEntityToDomain(join15(path6, "domains")),
1956
+ addEntityToDomain: addEntityToDomain(join17(path7, "domains")),
1957
+ /**
1958
+ * Add an event to a domain by its id.
1959
+ *
1960
+ * @example
1961
+ * ```ts
1962
+ * import utils from '@eventcatalog/utils';
1963
+ *
1964
+ * const { addEventToDomain } = utils('/path/to/eventcatalog');
1965
+ *
1966
+ * // adds a new event (OrderCreated) that the Orders domain will send
1967
+ * await addEventToDomain('Orders', 'sends', { id: 'OrderCreated', version: '2.0.0' });
1968
+ *
1969
+ * // adds a new event (PaymentProcessed) that the Orders domain will receive
1970
+ * await addEventToDomain('Orders', 'receives', { id: 'PaymentProcessed', version: '2.0.0' });
1971
+ *
1972
+ * ```
1973
+ */
1974
+ addEventToDomain: addMessageToDomain(join17(path7, "domains")),
1975
+ /**
1976
+ * Add a command to a domain by its id.
1977
+ *
1978
+ * @example
1979
+ * ```ts
1980
+ * import utils from '@eventcatalog/utils';
1981
+ *
1982
+ * const { addCommandToDomain } = utils('/path/to/eventcatalog');
1983
+ *
1984
+ * // adds a new command (ProcessOrder) that the Orders domain will send
1985
+ * await addCommandToDomain('Orders', 'sends', { id: 'ProcessOrder', version: '2.0.0' });
1986
+ *
1987
+ * // adds a new command (CancelOrder) that the Orders domain will receive
1988
+ * await addCommandToDomain('Orders', 'receives', { id: 'CancelOrder', version: '2.0.0' });
1989
+ *
1990
+ * ```
1991
+ */
1992
+ addCommandToDomain: addMessageToDomain(join17(path7, "domains")),
1993
+ /**
1994
+ * Add a query to a domain by its id.
1995
+ *
1996
+ * @example
1997
+ * ```ts
1998
+ * import utils from '@eventcatalog/utils';
1999
+ *
2000
+ * const { addQueryToDomain } = utils('/path/to/eventcatalog');
2001
+ *
2002
+ * // adds a new query (GetOrderStatus) that the Orders domain will send
2003
+ * await addQueryToDomain('Orders', 'sends', { id: 'GetOrderStatus', version: '2.0.0' });
2004
+ *
2005
+ * // adds a new query (GetInventory) that the Orders domain will receive
2006
+ * await addQueryToDomain('Orders', 'receives', { id: 'GetInventory', version: '2.0.0' });
2007
+ *
2008
+ * ```
2009
+ */
2010
+ addQueryToDomain: addMessageToDomain(join17(path7, "domains")),
1734
2011
  /**
1735
2012
  * ================================
1736
2013
  * Teams
@@ -1743,25 +2020,25 @@ var src_default = (path6) => {
1743
2020
  * @param options - Optional options to write the team
1744
2021
  *
1745
2022
  */
1746
- writeTeam: writeTeam(join15(path6, "teams")),
2023
+ writeTeam: writeTeam(join17(path7, "teams")),
1747
2024
  /**
1748
2025
  * Returns a team from EventCatalog
1749
2026
  * @param id - The id of the team to retrieve
1750
2027
  * @returns Team|Undefined
1751
2028
  */
1752
- getTeam: getTeam(join15(path6, "teams")),
2029
+ getTeam: getTeam(join17(path7, "teams")),
1753
2030
  /**
1754
2031
  * Returns all teams from EventCatalog
1755
2032
  * @returns Team[]|Undefined
1756
2033
  */
1757
- getTeams: getTeams(join15(path6, "teams")),
2034
+ getTeams: getTeams(join17(path7, "teams")),
1758
2035
  /**
1759
2036
  * Remove a team by the team id
1760
2037
  *
1761
2038
  * @param id - The id of the team you want to remove
1762
2039
  *
1763
2040
  */
1764
- rmTeamById: rmTeamById(join15(path6, "teams")),
2041
+ rmTeamById: rmTeamById(join17(path7, "teams")),
1765
2042
  /**
1766
2043
  * ================================
1767
2044
  * Users
@@ -1774,25 +2051,25 @@ var src_default = (path6) => {
1774
2051
  * @param options - Optional options to write the user
1775
2052
  *
1776
2053
  */
1777
- writeUser: writeUser(join15(path6, "users")),
2054
+ writeUser: writeUser(join17(path7, "users")),
1778
2055
  /**
1779
2056
  * Returns a user from EventCatalog
1780
2057
  * @param id - The id of the user to retrieve
1781
2058
  * @returns User|Undefined
1782
2059
  */
1783
- getUser: getUser(join15(path6, "users")),
2060
+ getUser: getUser(join17(path7, "users")),
1784
2061
  /**
1785
2062
  * Returns all user from EventCatalog
1786
2063
  * @returns User[]|Undefined
1787
2064
  */
1788
- getUsers: getUsers(join15(path6)),
2065
+ getUsers: getUsers(join17(path7)),
1789
2066
  /**
1790
2067
  * Remove a user by the user id
1791
2068
  *
1792
2069
  * @param id - The id of the user you want to remove
1793
2070
  *
1794
2071
  */
1795
- rmUserById: rmUserById(join15(path6, "users")),
2072
+ rmUserById: rmUserById(join17(path7, "users")),
1796
2073
  /**
1797
2074
  * ================================
1798
2075
  * Custom Docs
@@ -1803,32 +2080,32 @@ var src_default = (path6) => {
1803
2080
  * @param path - The path to the custom doc to retrieve
1804
2081
  * @returns CustomDoc|Undefined
1805
2082
  */
1806
- getCustomDoc: getCustomDoc(join15(path6, "docs")),
2083
+ getCustomDoc: getCustomDoc(join17(path7, "docs")),
1807
2084
  /**
1808
2085
  * Returns all custom docs from EventCatalog
1809
2086
  * @param options - Optional options to get custom docs from a specific path
1810
2087
  * @returns CustomDoc[]|Undefined
1811
2088
  */
1812
- getCustomDocs: getCustomDocs(join15(path6, "docs")),
2089
+ getCustomDocs: getCustomDocs(join17(path7, "docs")),
1813
2090
  /**
1814
2091
  * Writes a custom doc to EventCatalog
1815
2092
  * @param customDoc - The custom doc to write
1816
2093
  * @param options - Optional options to write the custom doc
1817
2094
  *
1818
2095
  */
1819
- writeCustomDoc: writeCustomDoc(join15(path6, "docs")),
2096
+ writeCustomDoc: writeCustomDoc(join17(path7, "docs")),
1820
2097
  /**
1821
2098
  * Removes a custom doc from EventCatalog
1822
2099
  * @param path - The path to the custom doc to remove
1823
2100
  *
1824
2101
  */
1825
- rmCustomDoc: rmCustomDoc(join15(path6, "docs")),
2102
+ rmCustomDoc: rmCustomDoc(join17(path7, "docs")),
1826
2103
  /**
1827
2104
  * Dumps the catalog to a JSON file.
1828
2105
  * @param directory - The directory to dump the catalog to
1829
2106
  * @returns A JSON file with the catalog
1830
2107
  */
1831
- dumpCatalog: dumpCatalog(join15(path6)),
2108
+ dumpCatalog: dumpCatalog(join17(path7)),
1832
2109
  /**
1833
2110
  * Returns the event catalog configuration file.
1834
2111
  * The event catalog configuration file is the file that contains the configuration for the event catalog.
@@ -1836,7 +2113,7 @@ var src_default = (path6) => {
1836
2113
  * @param directory - The directory of the catalog.
1837
2114
  * @returns A JSON object with the configuration for the event catalog.
1838
2115
  */
1839
- getEventCatalogConfigurationFile: getEventCatalogConfigurationFile(join15(path6)),
2116
+ getEventCatalogConfigurationFile: getEventCatalogConfigurationFile(join17(path7)),
1840
2117
  /**
1841
2118
  * ================================
1842
2119
  * Resources Utils
@@ -1861,33 +2138,33 @@ var src_default = (path6) => {
1861
2138
  * @param path - The path to the message to retrieve
1862
2139
  * @returns Message|Undefined
1863
2140
  */
1864
- getMessageBySchemaPath: getMessageBySchemaPath(join15(path6)),
2141
+ getMessageBySchemaPath: getMessageBySchemaPath(join17(path7)),
1865
2142
  /**
1866
2143
  * Returns the producers and consumers (services) for a given message
1867
2144
  * @param id - The id of the message to get the producers and consumers for
1868
2145
  * @param version - Optional version of the message
1869
2146
  * @returns { producers: Service[], consumers: Service[] }
1870
2147
  */
1871
- getProducersAndConsumersForMessage: getProducersAndConsumersForMessage(join15(path6)),
2148
+ getProducersAndConsumersForMessage: getProducersAndConsumersForMessage(join17(path7)),
1872
2149
  /**
1873
2150
  * Returns the consumers of a given schema path
1874
2151
  * @param path - The path to the schema to get the consumers for
1875
2152
  * @returns Service[]
1876
2153
  */
1877
- getConsumersOfSchema: getConsumersOfSchema(join15(path6)),
2154
+ getConsumersOfSchema: getConsumersOfSchema(join17(path7)),
1878
2155
  /**
1879
2156
  * Returns the producers of a given schema path
1880
2157
  * @param path - The path to the schema to get the producers for
1881
2158
  * @returns Service[]
1882
2159
  */
1883
- getProducersOfSchema: getProducersOfSchema(join15(path6)),
2160
+ getProducersOfSchema: getProducersOfSchema(join17(path7)),
1884
2161
  /**
1885
2162
  * Returns the owners for a given resource (e.g domain, service, event, command, query, etc.)
1886
2163
  * @param id - The id of the resource to get the owners for
1887
2164
  * @param version - Optional version of the resource
1888
2165
  * @returns { owners: User[] }
1889
2166
  */
1890
- getOwnersForResource: getOwnersForResource(join15(path6)),
2167
+ getOwnersForResource: getOwnersForResource(join17(path7)),
1891
2168
  /**
1892
2169
  * ================================
1893
2170
  * Entities
@@ -1899,13 +2176,13 @@ var src_default = (path6) => {
1899
2176
  * @param version - Optional id of the version to get (supports semver)
1900
2177
  * @returns Entity|Undefined
1901
2178
  */
1902
- getEntity: getEntity(join15(path6)),
2179
+ getEntity: getEntity(join17(path7)),
1903
2180
  /**
1904
2181
  * Returns all entities from EventCatalog
1905
2182
  * @param latestOnly - optional boolean, set to true to get only latest versions
1906
2183
  * @returns Entity[]|Undefined
1907
2184
  */
1908
- getEntities: getEntities(join15(path6)),
2185
+ getEntities: getEntities(join17(path7)),
1909
2186
  /**
1910
2187
  * Adds an entity to EventCatalog
1911
2188
  *
@@ -1913,33 +2190,33 @@ var src_default = (path6) => {
1913
2190
  * @param options - Optional options to write the entity
1914
2191
  *
1915
2192
  */
1916
- writeEntity: writeEntity(join15(path6, "entities")),
2193
+ writeEntity: writeEntity(join17(path7, "entities")),
1917
2194
  /**
1918
2195
  * Remove an entity from EventCatalog (modeled on the standard POSIX rm utility)
1919
2196
  *
1920
2197
  * @param path - The path to your entity, e.g. `/User`
1921
2198
  *
1922
2199
  */
1923
- rmEntity: rmEntity(join15(path6, "entities")),
2200
+ rmEntity: rmEntity(join17(path7, "entities")),
1924
2201
  /**
1925
2202
  * Remove an entity by an entity id
1926
2203
  *
1927
2204
  * @param id - The id of the entity you want to remove
1928
2205
  *
1929
2206
  */
1930
- rmEntityById: rmEntityById(join15(path6)),
2207
+ rmEntityById: rmEntityById(join17(path7)),
1931
2208
  /**
1932
2209
  * Moves a given entity id to the version directory
1933
2210
  * @param id - The id of the entity to version
1934
2211
  */
1935
- versionEntity: versionEntity(join15(path6)),
2212
+ versionEntity: versionEntity(join17(path7)),
1936
2213
  /**
1937
2214
  * Check to see if an entity version exists
1938
2215
  * @param id - The id of the entity
1939
2216
  * @param version - The version of the entity (supports semver)
1940
2217
  * @returns
1941
2218
  */
1942
- entityHasVersion: entityHasVersion(join15(path6)),
2219
+ entityHasVersion: entityHasVersion(join17(path7)),
1943
2220
  /**
1944
2221
  * ================================
1945
2222
  * Data Stores
@@ -1951,42 +2228,42 @@ var src_default = (path6) => {
1951
2228
  * @param options - Optional options to write the data store
1952
2229
  *
1953
2230
  */
1954
- writeDataStore: writeDataStore(join15(path6, "containers")),
2231
+ writeDataStore: writeDataStore(join17(path7, "containers")),
1955
2232
  /**
1956
2233
  * Returns a data store from EventCatalog
1957
2234
  * @param id - The id of the data store to retrieve
1958
2235
  * @param version - Optional id of the version to get (supports semver)
1959
2236
  * @returns Container|Undefined
1960
2237
  */
1961
- getDataStore: getDataStore(join15(path6)),
2238
+ getDataStore: getDataStore(join17(path7)),
1962
2239
  /**
1963
2240
  * Returns all data stores from EventCatalog
1964
2241
  * @param latestOnly - optional boolean, set to true to get only latest versions
1965
2242
  * @returns Container[]|Undefined
1966
2243
  */
1967
- getDataStores: getDataStores(join15(path6)),
2244
+ getDataStores: getDataStores(join17(path7)),
1968
2245
  /**
1969
2246
  * Version a data store by its id
1970
2247
  * @param id - The id of the data store to version
1971
2248
  */
1972
- versionDataStore: versionDataStore(join15(path6, "containers")),
2249
+ versionDataStore: versionDataStore(join17(path7, "containers")),
1973
2250
  /**
1974
2251
  * Remove a data store by its path
1975
2252
  * @param path - The path to the data store to remove
1976
2253
  */
1977
- rmDataStore: rmDataStore(join15(path6, "containers")),
2254
+ rmDataStore: rmDataStore(join17(path7, "containers")),
1978
2255
  /**
1979
2256
  * Remove a data store by its id
1980
2257
  * @param id - The id of the data store to remove
1981
2258
  */
1982
- rmDataStoreById: rmDataStoreById(join15(path6)),
2259
+ rmDataStoreById: rmDataStoreById(join17(path7)),
1983
2260
  /**
1984
2261
  * Check to see if a data store version exists
1985
2262
  * @param id - The id of the data store
1986
2263
  * @param version - The version of the data store (supports semver)
1987
2264
  * @returns
1988
2265
  */
1989
- dataStoreHasVersion: dataStoreHasVersion(join15(path6)),
2266
+ dataStoreHasVersion: dataStoreHasVersion(join17(path7)),
1990
2267
  /**
1991
2268
  * Adds a file to a data store by its id
1992
2269
  * @param id - The id of the data store to add the file to
@@ -1994,113 +2271,200 @@ var src_default = (path6) => {
1994
2271
  * @param version - Optional version of the data store to add the file to
1995
2272
  * @returns
1996
2273
  */
1997
- addFileToDataStore: addFileToDataStore(join15(path6)),
2274
+ addFileToDataStore: addFileToDataStore(join17(path7)),
1998
2275
  /**
1999
2276
  * Writes a data store to a service by its id
2000
2277
  * @param dataStore - The data store to write
2001
2278
  * @param service - The service to write the data store to
2002
2279
  * @returns
2003
2280
  */
2004
- writeDataStoreToService: writeDataStoreToService(join15(path6))
2281
+ writeDataStoreToService: writeDataStoreToService(join17(path7)),
2282
+ /**
2283
+ * ================================
2284
+ * Data Products
2285
+ * ================================
2286
+ */
2287
+ /**
2288
+ * Adds a data product to EventCatalog
2289
+ * @param dataProduct - The data product to write
2290
+ * @param options - Optional options to write the data product
2291
+ *
2292
+ */
2293
+ writeDataProduct: writeDataProduct(join17(path7, "data-products")),
2294
+ /**
2295
+ * Writes a data product to a domain in EventCatalog
2296
+ * @param dataProduct - The data product to write
2297
+ * @param domain - The domain to write the data product to
2298
+ * @param options - Optional options to write the data product
2299
+ *
2300
+ */
2301
+ writeDataProductToDomain: writeDataProductToDomain(join17(path7, "domains")),
2302
+ /**
2303
+ * Returns a data product from EventCatalog
2304
+ * @param id - The id of the data product to retrieve
2305
+ * @param version - Optional id of the version to get (supports semver)
2306
+ * @returns DataProduct|Undefined
2307
+ */
2308
+ getDataProduct: getDataProduct(join17(path7)),
2309
+ /**
2310
+ * Returns all data products from EventCatalog
2311
+ * @param latestOnly - optional boolean, set to true to get only latest versions
2312
+ * @returns DataProduct[]|Undefined
2313
+ */
2314
+ getDataProducts: getDataProducts(join17(path7)),
2315
+ /**
2316
+ * Version a data product by its id
2317
+ * @param id - The id of the data product to version
2318
+ */
2319
+ versionDataProduct: versionDataProduct(join17(path7)),
2320
+ /**
2321
+ * Remove a data product by its path
2322
+ * @param path - The path to the data product to remove
2323
+ */
2324
+ rmDataProduct: rmDataProduct(join17(path7, "data-products")),
2325
+ /**
2326
+ * Remove a data product by its id
2327
+ * @param id - The id of the data product to remove
2328
+ * @param version - Optional version of the data product to remove
2329
+ */
2330
+ rmDataProductById: rmDataProductById(join17(path7)),
2331
+ /**
2332
+ * Check to see if a data product version exists
2333
+ * @param id - The id of the data product
2334
+ * @param version - The version of the data product (supports semver)
2335
+ * @returns
2336
+ */
2337
+ dataProductHasVersion: dataProductHasVersion(join17(path7)),
2338
+ /**
2339
+ * Adds a file to a data product by its id
2340
+ * @param id - The id of the data product to add the file to
2341
+ * @param file - File contents to add including the content and the file name
2342
+ * @param version - Optional version of the data product to add the file to
2343
+ * @returns
2344
+ */
2345
+ addFileToDataProduct: addFileToDataProduct(join17(path7)),
2346
+ /**
2347
+ * Adds a data product to a domain
2348
+ * @param id - The id of the domain
2349
+ * @param dataProduct - The id and version of the data product to add
2350
+ * @param version - (Optional) The version of the domain to add the data product to
2351
+ * @returns
2352
+ */
2353
+ addDataProductToDomain: addDataProductToDomain(join17(path7, "domains"))
2005
2354
  };
2006
2355
  };
2007
2356
 
2008
- // src/eventcatalog.ts
2009
- var DUMP_VERSION = "0.0.1";
2010
- 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);
2011
2371
  try {
2012
- const packageJson = fs12.readFileSync(join16(catalogDir, "package.json"), "utf8");
2013
- const packageJsonObject = JSON.parse(packageJson);
2014
- return packageJsonObject["dependencies"]["@eventcatalog/core"];
2372
+ return await fn(...parsedArgs);
2015
2373
  } catch (error) {
2016
- return "unknown";
2374
+ throw new Error(`Error executing '${functionName}': ${error instanceof Error ? error.message : String(error)}`);
2017
2375
  }
2018
- };
2019
- var hydrateResource = async (catalogDir, resources = [], { attachSchema = false } = {}) => {
2020
- return await Promise.all(
2021
- resources.map(async (resource) => {
2022
- const resourcePath = await getResourcePath(catalogDir, resource.id, resource.version);
2023
- let schema = "";
2024
- if (resource.schemaPath && resourcePath?.fullPath) {
2025
- const pathToSchema = path5.join(path5.dirname(resourcePath?.fullPath), resource.schemaPath);
2026
- if (fs12.existsSync(pathToSchema)) {
2027
- schema = fs12.readFileSync(pathToSchema, "utf8");
2028
- }
2029
- }
2030
- const eventcatalog = schema ? { directory: resourcePath?.directory, schema } : { directory: resourcePath?.directory };
2031
- return {
2032
- ...resource,
2033
- _eventcatalog: eventcatalog
2034
- };
2035
- })
2036
- );
2037
- };
2038
- var filterCollection = (collection, options) => {
2039
- return collection.map((item) => ({
2040
- ...item,
2041
- markdown: options?.includeMarkdown ? item.markdown : void 0
2042
- }));
2043
- };
2044
- 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(() => {
2045
2446
  try {
2046
- const path6 = join16(directory, "eventcatalog.config.js");
2047
- const configModule = await import(path6);
2048
- return configModule.default;
2447
+ const functions = listFunctions(".");
2448
+ const output = formatListOutput(functions);
2449
+ console.log(output);
2049
2450
  } catch (error) {
2050
- console.error("Error getting event catalog configuration file", error);
2051
- return null;
2451
+ console.error("Error listing functions:", error instanceof Error ? error.message : String(error));
2452
+ process.exit(1);
2052
2453
  }
2053
- };
2054
- var dumpCatalog = (directory) => async (options) => {
2055
- const { getDomains: getDomains2, getServices: getServices2, getEvents: getEvents2, getQueries: getQueries2, getCommands: getCommands2, getChannels: getChannels2, getTeams: getTeams2, getUsers: getUsers3 } = src_default(directory);
2056
- const { includeMarkdown = true } = options || {};
2057
- const domains = await getDomains2();
2058
- const services = await getServices2();
2059
- const events = await getEvents2();
2060
- const commands = await getCommands2();
2061
- const queries = await getQueries2();
2062
- const teams = await getTeams2();
2063
- const users = await getUsers3();
2064
- const channels = await getChannels2();
2065
- const [
2066
- hydratedDomains,
2067
- hydratedServices,
2068
- hydratedEvents,
2069
- hydratedQueries,
2070
- hydratedCommands,
2071
- hydratedTeams,
2072
- hydratedUsers,
2073
- hydratedChannels
2074
- ] = await Promise.all([
2075
- hydrateResource(directory, domains),
2076
- hydrateResource(directory, services),
2077
- hydrateResource(directory, events),
2078
- hydrateResource(directory, queries),
2079
- hydrateResource(directory, commands),
2080
- hydrateResource(directory, teams),
2081
- hydrateResource(directory, users),
2082
- hydrateResource(directory, channels)
2083
- ]);
2084
- return {
2085
- version: DUMP_VERSION,
2086
- catalogVersion: await getEventCatalogVersion(directory),
2087
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2088
- resources: {
2089
- domains: filterCollection(hydratedDomains, { includeMarkdown }),
2090
- services: filterCollection(hydratedServices, { includeMarkdown }),
2091
- messages: {
2092
- events: filterCollection(hydratedEvents, { includeMarkdown }),
2093
- queries: filterCollection(hydratedQueries, { includeMarkdown }),
2094
- commands: filterCollection(hydratedCommands, { includeMarkdown })
2095
- },
2096
- teams: filterCollection(hydratedTeams, { includeMarkdown }),
2097
- users: filterCollection(hydratedUsers, { includeMarkdown }),
2098
- channels: filterCollection(hydratedChannels, { includeMarkdown })
2099
- }
2100
- };
2101
- };
2102
- export {
2103
- dumpCatalog,
2104
- getEventCatalogConfigurationFile
2105
- };
2106
- //# 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