@eventcatalog/sdk 2.2.0 → 2.2.2

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.
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/index.ts
2
- import { join as join12 } from "node:path";
2
+ import { join as join13 } from "node:path";
3
3
 
4
4
  // src/events.ts
5
5
  import fs2 from "node:fs/promises";
@@ -20,13 +20,13 @@ var versionExists = async (catalogDir, id, version) => {
20
20
  var findFileById = async (catalogDir, id, version) => {
21
21
  const files = await getFiles(`${catalogDir}/**/index.{md,mdx}`);
22
22
  const matchedFiles = await searchFilesForId(files, id) || [];
23
- const latestVersion = matchedFiles.find((path3) => !path3.includes("versioned"));
23
+ const latestVersion = matchedFiles.find((path4) => !path4.includes("versioned"));
24
24
  if (!version) {
25
25
  return latestVersion;
26
26
  }
27
- const parsedFiles = matchedFiles.map((path3) => {
28
- const { data } = matter.read(path3);
29
- return { ...data, path: path3 };
27
+ const parsedFiles = matchedFiles.map((path4) => {
28
+ const { data } = matter.read(path4);
29
+ return { ...data, path: path4 };
30
30
  });
31
31
  const semverRange = validRange(version);
32
32
  if (semverRange && valid(version)) {
@@ -50,8 +50,8 @@ var getFiles = async (pattern, ignore = "") => {
50
50
  throw new Error(`Error finding files: ${error}`);
51
51
  }
52
52
  };
53
- var readMdxFile = async (path3) => {
54
- const { data } = matter.read(path3);
53
+ var readMdxFile = async (path4) => {
54
+ const { data } = matter.read(path4);
55
55
  const { markdown, ...frontmatter } = data;
56
56
  return { ...frontmatter, markdown };
57
57
  };
@@ -132,8 +132,8 @@ var writeResource = async (catalogDir, resource, options = {
132
132
  override: false,
133
133
  versionExistingContent: false
134
134
  }) => {
135
- const path3 = options.path || `/${resource.id}`;
136
- const fullPath = join2(catalogDir, path3);
135
+ const path4 = options.path || `/${resource.id}`;
136
+ const fullPath = join2(catalogDir, path4);
137
137
  fsSync2.mkdirSync(fullPath, { recursive: true });
138
138
  const lockPath = join2(fullPath, "index.mdx");
139
139
  if (!fsSync2.existsSync(lockPath)) {
@@ -253,8 +253,8 @@ var writeEventToService = (directory) => async (event, service, options = { path
253
253
  pathForEvent = join3(pathForEvent, event.id);
254
254
  await writeResource(directory, { ...event }, { ...options, path: pathForEvent, type: "event" });
255
255
  };
256
- var rmEvent = (directory) => async (path3) => {
257
- await fs2.rm(join3(directory, path3), { recursive: true });
256
+ var rmEvent = (directory) => async (path4) => {
257
+ await fs2.rm(join3(directory, path4), { recursive: true });
258
258
  };
259
259
  var rmEventById = (directory) => async (id, version, persistFiles) => {
260
260
  await rmResourceById(directory, id, version, { type: "event", persistFiles });
@@ -284,8 +284,8 @@ var writeCommandToService = (directory) => async (command, service, options = {
284
284
  pathForCommand = join4(pathForCommand, command.id);
285
285
  await writeResource(directory, { ...command }, { ...options, path: pathForCommand, type: "command" });
286
286
  };
287
- var rmCommand = (directory) => async (path3) => {
288
- await fs3.rm(join4(directory, path3), { recursive: true });
287
+ var rmCommand = (directory) => async (path4) => {
288
+ await fs3.rm(join4(directory, path4), { recursive: true });
289
289
  };
290
290
  var rmCommandById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "command", persistFiles });
291
291
  var versionCommand = (directory) => async (id) => versionResource(directory, id);
@@ -313,8 +313,8 @@ var writeQueryToService = (directory) => async (query, service, options = { path
313
313
  pathForQuery = join5(pathForQuery, query.id);
314
314
  await writeResource(directory, { ...query }, { ...options, path: pathForQuery, type: "query" });
315
315
  };
316
- var rmQuery = (directory) => async (path3) => {
317
- await fs4.rm(join5(directory, path3), { recursive: true });
316
+ var rmQuery = (directory) => async (path4) => {
317
+ await fs4.rm(join5(directory, path4), { recursive: true });
318
318
  };
319
319
  var rmQueryById = (directory) => async (id, version, persistFiles) => {
320
320
  await rmResourceById(directory, id, version, { type: "query", persistFiles });
@@ -350,8 +350,8 @@ var writeService = (directory) => async (service, options = { path: "" }) => {
350
350
  };
351
351
  var writeVersionedService = (directory) => async (service) => {
352
352
  const resource = { ...service };
353
- const path3 = getVersionedDirectory(service.id, service.version);
354
- return await writeService(directory)(resource, { path: path3 });
353
+ const path4 = getVersionedDirectory(service.id, service.version);
354
+ return await writeService(directory)(resource, { path: path4 });
355
355
  };
356
356
  var writeServiceToDomain = (directory) => async (service, domain, options = { path: "" }) => {
357
357
  let pathForService = domain.version && domain.version !== "latest" ? `/${domain.id}/versioned/${domain.version}/services` : `/${domain.id}/services`;
@@ -359,8 +359,8 @@ var writeServiceToDomain = (directory) => async (service, domain, options = { pa
359
359
  await writeResource(directory, { ...service }, { ...options, path: pathForService, type: "service" });
360
360
  };
361
361
  var versionService = (directory) => async (id) => versionResource(directory, id);
362
- var rmService = (directory) => async (path3) => {
363
- await fs5.rm(join6(directory, path3), { recursive: true });
362
+ var rmService = (directory) => async (path4) => {
363
+ await fs5.rm(join6(directory, path4), { recursive: true });
364
364
  };
365
365
  var rmServiceById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "service", persistFiles });
366
366
  var addFileToService = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
@@ -413,8 +413,8 @@ var addMessageToService = (directory) => async (id, direction, event, version) =
413
413
  if (!existingResource) {
414
414
  throw new Error(`Cannot find service ${id} in the catalog`);
415
415
  }
416
- const path3 = existingResource.split("/services")[0];
417
- const pathToResource = join6(path3, "services");
416
+ const path4 = existingResource.split("/services")[0];
417
+ const pathToResource = join6(path4, "services");
418
418
  await rmServiceById(directory)(id, version);
419
419
  await writeService(pathToResource)(service);
420
420
  };
@@ -442,8 +442,8 @@ var writeDomain = (directory) => async (domain, options = { path: "" }) => {
442
442
  return await writeResource(directory, resource, { ...options, type: "domain" });
443
443
  };
444
444
  var versionDomain = (directory) => async (id) => versionResource(directory, id);
445
- var rmDomain = (directory) => async (path3) => {
446
- await fs6.rm(join7(directory, path3), { recursive: true });
445
+ var rmDomain = (directory) => async (path4) => {
446
+ await fs6.rm(join7(directory, path4), { recursive: true });
447
447
  };
448
448
  var rmDomainById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "domain", persistFiles });
449
449
  var addFileToDomain = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
@@ -487,8 +487,8 @@ import { join as join8 } from "node:path";
487
487
  var getChannel = (directory) => async (id, version) => getResource(directory, id, version, { type: "channel" });
488
488
  var getChannels = (directory) => async (options) => getResources(directory, { type: "channels", ...options });
489
489
  var writeChannel = (directory) => async (channel, options = { path: "" }) => writeResource(directory, { ...channel }, { ...options, type: "channel" });
490
- var rmChannel = (directory) => async (path3) => {
491
- await fs7.rm(join8(directory, path3), { recursive: true });
490
+ var rmChannel = (directory) => async (path4) => {
491
+ await fs7.rm(join8(directory, path4), { recursive: true });
492
492
  };
493
493
  var rmChannelById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "channel", persistFiles });
494
494
  var versionChannel = (directory) => async (id) => versionResource(directory, id);
@@ -527,20 +527,103 @@ var addMessageToChannel = (directory, collection) => async (id, _message, versio
527
527
  if (!existingResource) {
528
528
  throw new Error(`Cannot find message ${id} in the catalog`);
529
529
  }
530
- const path3 = existingResource.split(`/${collection}`)[0];
531
- const pathToResource = join8(path3, collection);
530
+ const path4 = existingResource.split(`/${collection}`)[0];
531
+ const pathToResource = join8(path4, collection);
532
532
  await rmMessageById(directory)(_message.id, _message.version, true);
533
533
  await writeMessage(pathToResource)(message);
534
534
  };
535
535
 
536
- // src/custom-docs.ts
536
+ // src/eventcatalog.ts
537
+ import fs8 from "fs";
537
538
  import path2, { join as join9 } from "node:path";
539
+ var DUMP_VERSION = "0.0.1";
540
+ var getEventCatalogVersion = async (catalogDir) => {
541
+ const packageJson = fs8.readFileSync(join9(catalogDir, "package.json"), "utf8");
542
+ const packageJsonObject = JSON.parse(packageJson);
543
+ return packageJsonObject["dependencies"]["@eventcatalog/core"];
544
+ };
545
+ var hydrateResource = async (catalogDir, resources, { attachSchema = false } = {}) => {
546
+ return await Promise.all(
547
+ resources.map(async (resource) => {
548
+ const resourcePath = await getResourcePath(catalogDir, resource.id, resource.version);
549
+ let schema = "";
550
+ if (resource.schemaPath && resourcePath?.fullPath) {
551
+ const pathToSchema = path2.join(path2.dirname(resourcePath?.fullPath), resource.schemaPath);
552
+ if (fs8.existsSync(pathToSchema)) {
553
+ schema = fs8.readFileSync(pathToSchema, "utf8");
554
+ }
555
+ }
556
+ const eventcatalog = schema ? { directory: resourcePath?.directory, schema } : { directory: resourcePath?.directory };
557
+ return {
558
+ ...resource,
559
+ _eventcatalog: eventcatalog
560
+ };
561
+ })
562
+ );
563
+ };
564
+ var filterCollection = (collection, options) => {
565
+ return collection.map((item) => ({
566
+ ...item,
567
+ markdown: options?.includeMarkdown ? item.markdown : void 0
568
+ }));
569
+ };
570
+ var dumpCatalog = (directory) => async (options) => {
571
+ const { getDomains: getDomains2, getServices: getServices2, getEvents: getEvents2, getQueries: getQueries2, getCommands: getCommands2, getChannels: getChannels2, getTeams: getTeams2, getUsers: getUsers2 } = index_default(directory);
572
+ const { includeMarkdown = true } = options || {};
573
+ const domains = await getDomains2();
574
+ const services = await getServices2();
575
+ const events = await getEvents2();
576
+ const commands = await getCommands2();
577
+ const queries = await getQueries2();
578
+ const teams = await getTeams2();
579
+ const users = await getUsers2();
580
+ const channels = await getChannels2();
581
+ const [
582
+ hydratedDomains,
583
+ hydratedServices,
584
+ hydratedEvents,
585
+ hydratedQueries,
586
+ hydratedCommands,
587
+ hydratedTeams,
588
+ hydratedUsers,
589
+ hydratedChannels
590
+ ] = await Promise.all([
591
+ hydrateResource(directory, domains),
592
+ hydrateResource(directory, services),
593
+ hydrateResource(directory, events),
594
+ hydrateResource(directory, queries),
595
+ hydrateResource(directory, commands),
596
+ hydrateResource(directory, teams),
597
+ hydrateResource(directory, users),
598
+ hydrateResource(directory, channels)
599
+ ]);
600
+ return {
601
+ version: DUMP_VERSION,
602
+ catalogVersion: await getEventCatalogVersion(directory),
603
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
604
+ resources: {
605
+ domains: filterCollection(hydratedDomains, { includeMarkdown }),
606
+ services: filterCollection(hydratedServices, { includeMarkdown }),
607
+ messages: {
608
+ events: filterCollection(hydratedEvents, { includeMarkdown }),
609
+ queries: filterCollection(hydratedQueries, { includeMarkdown }),
610
+ commands: filterCollection(hydratedCommands, { includeMarkdown })
611
+ },
612
+ teams: filterCollection(hydratedTeams, { includeMarkdown }),
613
+ users: filterCollection(hydratedUsers, { includeMarkdown }),
614
+ channels: filterCollection(hydratedChannels, { includeMarkdown })
615
+ }
616
+ };
617
+ };
618
+
619
+ // src/custom-docs.ts
620
+ import path3, { join as join10 } from "node:path";
538
621
  import fsSync4 from "node:fs";
539
- import fs8 from "node:fs/promises";
622
+ import fs9 from "node:fs/promises";
540
623
  import matter4 from "gray-matter";
541
624
  import slugify from "slugify";
542
625
  var getCustomDoc = (directory) => async (filePath) => {
543
- const fullPath = path2.join(directory, filePath);
626
+ const fullPath = path3.join(directory, filePath);
544
627
  const fullPathWithExtension = fullPath.endsWith(".mdx") ? fullPath : `${fullPath}.mdx`;
545
628
  const fileExists = fsSync4.existsSync(fullPathWithExtension);
546
629
  if (!fileExists) {
@@ -559,23 +642,23 @@ var writeCustomDoc = (directory) => async (customDoc, options = { path: "" }) =>
559
642
  const { fileName, ...rest } = customDoc;
560
643
  const name = fileName || slugify(customDoc.title, { lower: true });
561
644
  const withExtension = name.endsWith(".mdx") ? name : `${name}.mdx`;
562
- const fullPath = path2.join(directory, options.path || "", withExtension);
563
- fsSync4.mkdirSync(path2.dirname(fullPath), { recursive: true });
645
+ const fullPath = path3.join(directory, options.path || "", withExtension);
646
+ fsSync4.mkdirSync(path3.dirname(fullPath), { recursive: true });
564
647
  const document = matter4.stringify(customDoc.markdown.trim(), rest);
565
648
  fsSync4.writeFileSync(fullPath, document);
566
649
  };
567
650
  var rmCustomDoc = (directory) => async (filePath) => {
568
651
  const withExtension = filePath.endsWith(".mdx") ? filePath : `${filePath}.mdx`;
569
- await fs8.rm(join9(directory, withExtension), { recursive: true });
652
+ await fs9.rm(join10(directory, withExtension), { recursive: true });
570
653
  };
571
654
 
572
655
  // src/teams.ts
573
- import fs9 from "node:fs/promises";
656
+ import fs10 from "node:fs/promises";
574
657
  import fsSync5 from "node:fs";
575
- import { join as join10 } from "node:path";
658
+ import { join as join11 } from "node:path";
576
659
  import matter5 from "gray-matter";
577
660
  var getTeam = (catalogDir) => async (id) => {
578
- const files = await getFiles(`${catalogDir}/${id}.md`);
661
+ const files = await getFiles(`${catalogDir}/${id}.{md,mdx}`);
579
662
  if (files.length == 0) return void 0;
580
663
  const file = files[0];
581
664
  const { data, content } = matter5.read(file);
@@ -587,7 +670,7 @@ var getTeam = (catalogDir) => async (id) => {
587
670
  };
588
671
  };
589
672
  var getTeams = (catalogDir) => async (options) => {
590
- const files = await getFiles(`${catalogDir}/teams/*.md`);
673
+ const files = await getFiles(`${catalogDir}/teams/*.{md,mdx}`);
591
674
  if (files.length === 0) return [];
592
675
  return files.map((file) => {
593
676
  const { data, content } = matter5.read(file);
@@ -608,19 +691,19 @@ var writeTeam = (catalogDir) => async (team, options = {}) => {
608
691
  }
609
692
  const { markdown, ...frontmatter } = resource;
610
693
  const document = matter5.stringify(markdown, frontmatter);
611
- fsSync5.mkdirSync(join10(catalogDir, ""), { recursive: true });
612
- fsSync5.writeFileSync(join10(catalogDir, "", `${resource.id}.md`), document);
694
+ fsSync5.mkdirSync(join11(catalogDir, ""), { recursive: true });
695
+ fsSync5.writeFileSync(join11(catalogDir, "", `${resource.id}.mdx`), document);
613
696
  };
614
697
  var rmTeamById = (catalogDir) => async (id) => {
615
- await fs9.rm(join10(catalogDir, `${id}.md`), { recursive: true });
698
+ await fs10.rm(join11(catalogDir, `${id}.mdx`), { recursive: true });
616
699
  };
617
700
 
618
701
  // src/users.ts
619
702
  import fsSync6 from "node:fs";
620
- import { join as join11 } from "node:path";
703
+ import { join as join12 } from "node:path";
621
704
  import matter6 from "gray-matter";
622
705
  var getUser = (catalogDir) => async (id) => {
623
- const files = await getFiles(`${catalogDir}/${id}.md`);
706
+ const files = await getFiles(`${catalogDir}/${id}.{md,mdx}`);
624
707
  if (files.length == 0) return void 0;
625
708
  const file = files[0];
626
709
  const { data, content } = matter6.read(file);
@@ -633,7 +716,7 @@ var getUser = (catalogDir) => async (id) => {
633
716
  };
634
717
  };
635
718
  var getUsers = (catalogDir) => async (options) => {
636
- const files = await getFiles(`${catalogDir}/users/*.md`);
719
+ const files = await getFiles(`${catalogDir}/users/*.{md,mdx}`);
637
720
  if (files.length === 0) return [];
638
721
  return files.map((file) => {
639
722
  const { data, content } = matter6.read(file);
@@ -655,15 +738,15 @@ var writeUser = (catalogDir) => async (user, options = {}) => {
655
738
  }
656
739
  const { markdown, ...frontmatter } = resource;
657
740
  const document = matter6.stringify(markdown, frontmatter);
658
- fsSync6.mkdirSync(join11(catalogDir, ""), { recursive: true });
659
- fsSync6.writeFileSync(join11(catalogDir, "", `${resource.id}.md`), document);
741
+ fsSync6.mkdirSync(join12(catalogDir, ""), { recursive: true });
742
+ fsSync6.writeFileSync(join12(catalogDir, "", `${resource.id}.mdx`), document);
660
743
  };
661
744
  var rmUserById = (catalogDir) => async (id) => {
662
- fsSync6.rmSync(join11(catalogDir, `${id}.md`), { recursive: true });
745
+ fsSync6.rmSync(join12(catalogDir, `${id}.mdx`), { recursive: true });
663
746
  };
664
747
 
665
748
  // src/index.ts
666
- var index_default = (path3) => {
749
+ var index_default = (path4) => {
667
750
  return {
668
751
  /**
669
752
  * Returns an events from EventCatalog
@@ -671,13 +754,13 @@ var index_default = (path3) => {
671
754
  * @param version - Optional id of the version to get (supports semver)
672
755
  * @returns Event|Undefined
673
756
  */
674
- getEvent: getEvent(join12(path3)),
757
+ getEvent: getEvent(join13(path4)),
675
758
  /**
676
759
  * Returns all events from EventCatalog
677
760
  * @param latestOnly - optional boolean, set to true to get only latest versions
678
761
  * @returns Event[]|Undefined
679
762
  */
680
- getEvents: getEvents(join12(path3)),
763
+ getEvents: getEvents(join13(path4)),
681
764
  /**
682
765
  * Adds an event to EventCatalog
683
766
  *
@@ -685,7 +768,7 @@ var index_default = (path3) => {
685
768
  * @param options - Optional options to write the event
686
769
  *
687
770
  */
688
- writeEvent: writeEvent(join12(path3, "events")),
771
+ writeEvent: writeEvent(join13(path4, "events")),
689
772
  /**
690
773
  * Adds an event to a service in EventCatalog
691
774
  *
@@ -694,26 +777,26 @@ var index_default = (path3) => {
694
777
  * @param options - Optional options to write the event
695
778
  *
696
779
  */
697
- writeEventToService: writeEventToService(join12(path3)),
780
+ writeEventToService: writeEventToService(join13(path4)),
698
781
  /**
699
782
  * Remove an event to EventCatalog (modeled on the standard POSIX rm utility)
700
783
  *
701
784
  * @param path - The path to your event, e.g. `/Inventory/InventoryAdjusted`
702
785
  *
703
786
  */
704
- rmEvent: rmEvent(join12(path3, "events")),
787
+ rmEvent: rmEvent(join13(path4, "events")),
705
788
  /**
706
789
  * Remove an event by an Event id
707
790
  *
708
791
  * @param id - The id of the event you want to remove
709
792
  *
710
793
  */
711
- rmEventById: rmEventById(join12(path3)),
794
+ rmEventById: rmEventById(join13(path4)),
712
795
  /**
713
796
  * Moves a given event id to the version directory
714
797
  * @param directory
715
798
  */
716
- versionEvent: versionEvent(join12(path3)),
799
+ versionEvent: versionEvent(join13(path4)),
717
800
  /**
718
801
  * Adds a file to the given event
719
802
  * @param id - The id of the event to add the file to
@@ -721,7 +804,7 @@ var index_default = (path3) => {
721
804
  * @param version - Optional version of the event to add the file to
722
805
  * @returns
723
806
  */
724
- addFileToEvent: addFileToEvent(join12(path3)),
807
+ addFileToEvent: addFileToEvent(join13(path4)),
725
808
  /**
726
809
  * Adds a schema to the given event
727
810
  * @param id - The id of the event to add the schema to
@@ -729,14 +812,14 @@ var index_default = (path3) => {
729
812
  * @param version - Optional version of the event to add the schema to
730
813
  * @returns
731
814
  */
732
- addSchemaToEvent: addSchemaToEvent(join12(path3)),
815
+ addSchemaToEvent: addSchemaToEvent(join13(path4)),
733
816
  /**
734
817
  * Check to see if an event version exists
735
818
  * @param id - The id of the event
736
819
  * @param version - The version of the event (supports semver)
737
820
  * @returns
738
821
  */
739
- eventHasVersion: eventHasVersion(join12(path3)),
822
+ eventHasVersion: eventHasVersion(join13(path4)),
740
823
  /**
741
824
  * ================================
742
825
  * Commands
@@ -748,13 +831,13 @@ var index_default = (path3) => {
748
831
  * @param version - Optional id of the version to get (supports semver)
749
832
  * @returns Command|Undefined
750
833
  */
751
- getCommand: getCommand(join12(path3)),
834
+ getCommand: getCommand(join13(path4)),
752
835
  /**
753
836
  * Returns all commands from EventCatalog
754
837
  * @param latestOnly - optional boolean, set to true to get only latest versions
755
838
  * @returns Command[]|Undefined
756
839
  */
757
- getCommands: getCommands(join12(path3)),
840
+ getCommands: getCommands(join13(path4)),
758
841
  /**
759
842
  * Adds an command to EventCatalog
760
843
  *
@@ -762,7 +845,7 @@ var index_default = (path3) => {
762
845
  * @param options - Optional options to write the command
763
846
  *
764
847
  */
765
- writeCommand: writeCommand(join12(path3, "commands")),
848
+ writeCommand: writeCommand(join13(path4, "commands")),
766
849
  /**
767
850
  * Adds a command to a service in EventCatalog
768
851
  *
@@ -771,26 +854,26 @@ var index_default = (path3) => {
771
854
  * @param options - Optional options to write the command
772
855
  *
773
856
  */
774
- writeCommandToService: writeCommandToService(join12(path3)),
857
+ writeCommandToService: writeCommandToService(join13(path4)),
775
858
  /**
776
859
  * Remove an command to EventCatalog (modeled on the standard POSIX rm utility)
777
860
  *
778
861
  * @param path - The path to your command, e.g. `/Inventory/InventoryAdjusted`
779
862
  *
780
863
  */
781
- rmCommand: rmCommand(join12(path3, "commands")),
864
+ rmCommand: rmCommand(join13(path4, "commands")),
782
865
  /**
783
866
  * Remove an command by an Event id
784
867
  *
785
868
  * @param id - The id of the command you want to remove
786
869
  *
787
870
  */
788
- rmCommandById: rmCommandById(join12(path3)),
871
+ rmCommandById: rmCommandById(join13(path4)),
789
872
  /**
790
873
  * Moves a given command id to the version directory
791
874
  * @param directory
792
875
  */
793
- versionCommand: versionCommand(join12(path3)),
876
+ versionCommand: versionCommand(join13(path4)),
794
877
  /**
795
878
  * Adds a file to the given command
796
879
  * @param id - The id of the command to add the file to
@@ -798,7 +881,7 @@ var index_default = (path3) => {
798
881
  * @param version - Optional version of the command to add the file to
799
882
  * @returns
800
883
  */
801
- addFileToCommand: addFileToCommand(join12(path3)),
884
+ addFileToCommand: addFileToCommand(join13(path4)),
802
885
  /**
803
886
  * Adds a schema to the given command
804
887
  * @param id - The id of the command to add the schema to
@@ -806,14 +889,14 @@ var index_default = (path3) => {
806
889
  * @param version - Optional version of the command to add the schema to
807
890
  * @returns
808
891
  */
809
- addSchemaToCommand: addSchemaToCommand(join12(path3)),
892
+ addSchemaToCommand: addSchemaToCommand(join13(path4)),
810
893
  /**
811
894
  * Check to see if a command version exists
812
895
  * @param id - The id of the command
813
896
  * @param version - The version of the command (supports semver)
814
897
  * @returns
815
898
  */
816
- commandHasVersion: commandHasVersion(join12(path3)),
899
+ commandHasVersion: commandHasVersion(join13(path4)),
817
900
  /**
818
901
  * ================================
819
902
  * Queries
@@ -825,13 +908,13 @@ var index_default = (path3) => {
825
908
  * @param version - Optional id of the version to get (supports semver)
826
909
  * @returns Query|Undefined
827
910
  */
828
- getQuery: getQuery(join12(path3)),
911
+ getQuery: getQuery(join13(path4)),
829
912
  /**
830
913
  * Returns all queries from EventCatalog
831
914
  * @param latestOnly - optional boolean, set to true to get only latest versions
832
915
  * @returns Query[]|Undefined
833
916
  */
834
- getQueries: getQueries(join12(path3)),
917
+ getQueries: getQueries(join13(path4)),
835
918
  /**
836
919
  * Adds a query to EventCatalog
837
920
  *
@@ -839,7 +922,7 @@ var index_default = (path3) => {
839
922
  * @param options - Optional options to write the event
840
923
  *
841
924
  */
842
- writeQuery: writeQuery(join12(path3, "queries")),
925
+ writeQuery: writeQuery(join13(path4, "queries")),
843
926
  /**
844
927
  * Adds a query to a service in EventCatalog
845
928
  *
@@ -848,26 +931,26 @@ var index_default = (path3) => {
848
931
  * @param options - Optional options to write the query
849
932
  *
850
933
  */
851
- writeQueryToService: writeQueryToService(join12(path3)),
934
+ writeQueryToService: writeQueryToService(join13(path4)),
852
935
  /**
853
936
  * Remove an query to EventCatalog (modeled on the standard POSIX rm utility)
854
937
  *
855
938
  * @param path - The path to your query, e.g. `/Orders/GetOrder`
856
939
  *
857
940
  */
858
- rmQuery: rmQuery(join12(path3, "queries")),
941
+ rmQuery: rmQuery(join13(path4, "queries")),
859
942
  /**
860
943
  * Remove a query by a Query id
861
944
  *
862
945
  * @param id - The id of the query you want to remove
863
946
  *
864
947
  */
865
- rmQueryById: rmQueryById(join12(path3)),
948
+ rmQueryById: rmQueryById(join13(path4)),
866
949
  /**
867
950
  * Moves a given query id to the version directory
868
951
  * @param directory
869
952
  */
870
- versionQuery: versionQuery(join12(path3)),
953
+ versionQuery: versionQuery(join13(path4)),
871
954
  /**
872
955
  * Adds a file to the given query
873
956
  * @param id - The id of the query to add the file to
@@ -875,7 +958,7 @@ var index_default = (path3) => {
875
958
  * @param version - Optional version of the query to add the file to
876
959
  * @returns
877
960
  */
878
- addFileToQuery: addFileToQuery(join12(path3)),
961
+ addFileToQuery: addFileToQuery(join13(path4)),
879
962
  /**
880
963
  * Adds a schema to the given query
881
964
  * @param id - The id of the query to add the schema to
@@ -883,14 +966,14 @@ var index_default = (path3) => {
883
966
  * @param version - Optional version of the query to add the schema to
884
967
  * @returns
885
968
  */
886
- addSchemaToQuery: addSchemaToQuery(join12(path3)),
969
+ addSchemaToQuery: addSchemaToQuery(join13(path4)),
887
970
  /**
888
971
  * Check to see if an query version exists
889
972
  * @param id - The id of the query
890
973
  * @param version - The version of the query (supports semver)
891
974
  * @returns
892
975
  */
893
- queryHasVersion: queryHasVersion(join12(path3)),
976
+ queryHasVersion: queryHasVersion(join13(path4)),
894
977
  /**
895
978
  * ================================
896
979
  * Channels
@@ -902,13 +985,13 @@ var index_default = (path3) => {
902
985
  * @param version - Optional id of the version to get (supports semver)
903
986
  * @returns Channel|Undefined
904
987
  */
905
- getChannel: getChannel(join12(path3)),
988
+ getChannel: getChannel(join13(path4)),
906
989
  /**
907
990
  * Returns all channels from EventCatalog
908
991
  * @param latestOnly - optional boolean, set to true to get only latest versions
909
992
  * @returns Channel[]|Undefined
910
993
  */
911
- getChannels: getChannels(join12(path3)),
994
+ getChannels: getChannels(join13(path4)),
912
995
  /**
913
996
  * Adds an channel to EventCatalog
914
997
  *
@@ -916,33 +999,33 @@ var index_default = (path3) => {
916
999
  * @param options - Optional options to write the channel
917
1000
  *
918
1001
  */
919
- writeChannel: writeChannel(join12(path3, "channels")),
1002
+ writeChannel: writeChannel(join13(path4, "channels")),
920
1003
  /**
921
1004
  * Remove an channel to EventCatalog (modeled on the standard POSIX rm utility)
922
1005
  *
923
1006
  * @param path - The path to your channel, e.g. `/Inventory/InventoryAdjusted`
924
1007
  *
925
1008
  */
926
- rmChannel: rmChannel(join12(path3, "channels")),
1009
+ rmChannel: rmChannel(join13(path4, "channels")),
927
1010
  /**
928
1011
  * Remove an channel by an Event id
929
1012
  *
930
1013
  * @param id - The id of the channel you want to remove
931
1014
  *
932
1015
  */
933
- rmChannelById: rmChannelById(join12(path3)),
1016
+ rmChannelById: rmChannelById(join13(path4)),
934
1017
  /**
935
1018
  * Moves a given channel id to the version directory
936
1019
  * @param directory
937
1020
  */
938
- versionChannel: versionChannel(join12(path3)),
1021
+ versionChannel: versionChannel(join13(path4)),
939
1022
  /**
940
1023
  * Check to see if a channel version exists
941
1024
  * @param id - The id of the channel
942
1025
  * @param version - The version of the channel (supports semver)
943
1026
  * @returns
944
1027
  */
945
- channelHasVersion: channelHasVersion(join12(path3)),
1028
+ channelHasVersion: channelHasVersion(join13(path4)),
946
1029
  /**
947
1030
  * Add a channel to an event
948
1031
  *
@@ -959,7 +1042,7 @@ var index_default = (path3) => {
959
1042
  *
960
1043
  * ```
961
1044
  */
962
- addEventToChannel: addMessageToChannel(join12(path3), "events"),
1045
+ addEventToChannel: addMessageToChannel(join13(path4), "events"),
963
1046
  /**
964
1047
  * Add a channel to an command
965
1048
  *
@@ -976,7 +1059,7 @@ var index_default = (path3) => {
976
1059
  *
977
1060
  * ```
978
1061
  */
979
- addCommandToChannel: addMessageToChannel(join12(path3), "commands"),
1062
+ addCommandToChannel: addMessageToChannel(join13(path4), "commands"),
980
1063
  /**
981
1064
  * Add a channel to an query
982
1065
  *
@@ -993,7 +1076,7 @@ var index_default = (path3) => {
993
1076
  *
994
1077
  * ```
995
1078
  */
996
- addQueryToChannel: addMessageToChannel(join12(path3), "queries"),
1079
+ addQueryToChannel: addMessageToChannel(join13(path4), "queries"),
997
1080
  /**
998
1081
  * ================================
999
1082
  * SERVICES
@@ -1006,14 +1089,14 @@ var index_default = (path3) => {
1006
1089
  * @param options - Optional options to write the event
1007
1090
  *
1008
1091
  */
1009
- writeService: writeService(join12(path3, "services")),
1092
+ writeService: writeService(join13(path4, "services")),
1010
1093
  /**
1011
1094
  * Adds a versioned service to EventCatalog
1012
1095
  *
1013
1096
  * @param service - The service to write
1014
1097
  *
1015
1098
  */
1016
- writeVersionedService: writeVersionedService(join12(path3, "services")),
1099
+ writeVersionedService: writeVersionedService(join13(path4, "services")),
1017
1100
  /**
1018
1101
  * Adds a service to a domain in EventCatalog
1019
1102
  *
@@ -1022,39 +1105,39 @@ var index_default = (path3) => {
1022
1105
  * @param options - Optional options to write the event
1023
1106
  *
1024
1107
  */
1025
- writeServiceToDomain: writeServiceToDomain(join12(path3, "domains")),
1108
+ writeServiceToDomain: writeServiceToDomain(join13(path4, "domains")),
1026
1109
  /**
1027
1110
  * Returns a service from EventCatalog
1028
1111
  * @param id - The id of the service to retrieve
1029
1112
  * @param version - Optional id of the version to get (supports semver)
1030
1113
  * @returns Service|Undefined
1031
1114
  */
1032
- getService: getService(join12(path3)),
1115
+ getService: getService(join13(path4)),
1033
1116
  /**
1034
1117
  * Returns all services from EventCatalog
1035
1118
  * @param latestOnly - optional boolean, set to true to get only latest versions
1036
1119
  * @returns Service[]|Undefined
1037
1120
  */
1038
- getServices: getServices(join12(path3)),
1121
+ getServices: getServices(join13(path4)),
1039
1122
  /**
1040
1123
  * Moves a given service id to the version directory
1041
1124
  * @param directory
1042
1125
  */
1043
- versionService: versionService(join12(path3)),
1126
+ versionService: versionService(join13(path4)),
1044
1127
  /**
1045
1128
  * Remove a service from EventCatalog (modeled on the standard POSIX rm utility)
1046
1129
  *
1047
1130
  * @param path - The path to your service, e.g. `/InventoryService`
1048
1131
  *
1049
1132
  */
1050
- rmService: rmService(join12(path3, "services")),
1133
+ rmService: rmService(join13(path4, "services")),
1051
1134
  /**
1052
1135
  * Remove an service by an service id
1053
1136
  *
1054
1137
  * @param id - The id of the service you want to remove
1055
1138
  *
1056
1139
  */
1057
- rmServiceById: rmServiceById(join12(path3)),
1140
+ rmServiceById: rmServiceById(join13(path4)),
1058
1141
  /**
1059
1142
  * Adds a file to the given service
1060
1143
  * @param id - The id of the service to add the file to
@@ -1062,21 +1145,21 @@ var index_default = (path3) => {
1062
1145
  * @param version - Optional version of the service to add the file to
1063
1146
  * @returns
1064
1147
  */
1065
- addFileToService: addFileToService(join12(path3)),
1148
+ addFileToService: addFileToService(join13(path4)),
1066
1149
  /**
1067
1150
  * Returns the specifications for a given service
1068
1151
  * @param id - The id of the service to retrieve the specifications for
1069
1152
  * @param version - Optional version of the service
1070
1153
  * @returns
1071
1154
  */
1072
- getSpecificationFilesForService: getSpecificationFilesForService(join12(path3)),
1155
+ getSpecificationFilesForService: getSpecificationFilesForService(join13(path4)),
1073
1156
  /**
1074
1157
  * Check to see if a service version exists
1075
1158
  * @param id - The id of the service
1076
1159
  * @param version - The version of the service (supports semver)
1077
1160
  * @returns
1078
1161
  */
1079
- serviceHasVersion: serviceHasVersion(join12(path3)),
1162
+ serviceHasVersion: serviceHasVersion(join13(path4)),
1080
1163
  /**
1081
1164
  * Add an event to a service by it's id.
1082
1165
  *
@@ -1096,7 +1179,7 @@ var index_default = (path3) => {
1096
1179
  *
1097
1180
  * ```
1098
1181
  */
1099
- addEventToService: addMessageToService(join12(path3)),
1182
+ addEventToService: addMessageToService(join13(path4)),
1100
1183
  /**
1101
1184
  * Add a command to a service by it's id.
1102
1185
  *
@@ -1116,7 +1199,7 @@ var index_default = (path3) => {
1116
1199
  *
1117
1200
  * ```
1118
1201
  */
1119
- addCommandToService: addMessageToService(join12(path3)),
1202
+ addCommandToService: addMessageToService(join13(path4)),
1120
1203
  /**
1121
1204
  * Add a query to a service by it's id.
1122
1205
  *
@@ -1136,7 +1219,7 @@ var index_default = (path3) => {
1136
1219
  *
1137
1220
  * ```
1138
1221
  */
1139
- addQueryToService: addMessageToService(join12(path3)),
1222
+ addQueryToService: addMessageToService(join13(path4)),
1140
1223
  /**
1141
1224
  * ================================
1142
1225
  * Domains
@@ -1149,39 +1232,39 @@ var index_default = (path3) => {
1149
1232
  * @param options - Optional options to write the event
1150
1233
  *
1151
1234
  */
1152
- writeDomain: writeDomain(join12(path3, "domains")),
1235
+ writeDomain: writeDomain(join13(path4, "domains")),
1153
1236
  /**
1154
1237
  * Returns a domain from EventCatalog
1155
1238
  * @param id - The id of the domain to retrieve
1156
1239
  * @param version - Optional id of the version to get (supports semver)
1157
1240
  * @returns Domain|Undefined
1158
1241
  */
1159
- getDomain: getDomain(join12(path3, "domains")),
1242
+ getDomain: getDomain(join13(path4, "domains")),
1160
1243
  /**
1161
1244
  * Returns all domains from EventCatalog
1162
1245
  * @param latestOnly - optional boolean, set to true to get only latest versions
1163
1246
  * @returns Domain[]|Undefined
1164
1247
  */
1165
- getDomains: getDomains(join12(path3)),
1248
+ getDomains: getDomains(join13(path4)),
1166
1249
  /**
1167
1250
  * Moves a given domain id to the version directory
1168
1251
  * @param directory
1169
1252
  */
1170
- versionDomain: versionDomain(join12(path3, "domains")),
1253
+ versionDomain: versionDomain(join13(path4, "domains")),
1171
1254
  /**
1172
1255
  * Remove a domain from EventCatalog (modeled on the standard POSIX rm utility)
1173
1256
  *
1174
1257
  * @param path - The path to your domain, e.g. `/Payment`
1175
1258
  *
1176
1259
  */
1177
- rmDomain: rmDomain(join12(path3, "domains")),
1260
+ rmDomain: rmDomain(join13(path4, "domains")),
1178
1261
  /**
1179
1262
  * Remove an service by an domain id
1180
1263
  *
1181
1264
  * @param id - The id of the domain you want to remove
1182
1265
  *
1183
1266
  */
1184
- rmDomainById: rmDomainById(join12(path3, "domains")),
1267
+ rmDomainById: rmDomainById(join13(path4, "domains")),
1185
1268
  /**
1186
1269
  * Adds a file to the given domain
1187
1270
  * @param id - The id of the domain to add the file to
@@ -1189,28 +1272,28 @@ var index_default = (path3) => {
1189
1272
  * @param version - Optional version of the domain to add the file to
1190
1273
  * @returns
1191
1274
  */
1192
- addFileToDomain: addFileToDomain(join12(path3, "domains")),
1275
+ addFileToDomain: addFileToDomain(join13(path4, "domains")),
1193
1276
  /**
1194
1277
  * Adds an ubiquitous language dictionary to a domain
1195
1278
  * @param id - The id of the domain to add the ubiquitous language to
1196
1279
  * @param ubiquitousLanguageDictionary - The ubiquitous language dictionary to add
1197
1280
  * @param version - Optional version of the domain to add the ubiquitous language to
1198
1281
  */
1199
- addUbiquitousLanguageToDomain: addUbiquitousLanguageToDomain(join12(path3, "domains")),
1282
+ addUbiquitousLanguageToDomain: addUbiquitousLanguageToDomain(join13(path4, "domains")),
1200
1283
  /**
1201
1284
  * Get the ubiquitous language dictionary from a domain
1202
1285
  * @param id - The id of the domain to get the ubiquitous language from
1203
1286
  * @param version - Optional version of the domain to get the ubiquitous language from
1204
1287
  * @returns
1205
1288
  */
1206
- getUbiquitousLanguageFromDomain: getUbiquitousLanguageFromDomain(join12(path3, "domains")),
1289
+ getUbiquitousLanguageFromDomain: getUbiquitousLanguageFromDomain(join13(path4, "domains")),
1207
1290
  /**
1208
1291
  * Check to see if a domain version exists
1209
1292
  * @param id - The id of the domain
1210
1293
  * @param version - The version of the domain (supports semver)
1211
1294
  * @returns
1212
1295
  */
1213
- domainHasVersion: domainHasVersion(join12(path3)),
1296
+ domainHasVersion: domainHasVersion(join13(path4)),
1214
1297
  /**
1215
1298
  * Adds a given service to a domain
1216
1299
  * @param id - The id of the domain
@@ -1218,7 +1301,7 @@ var index_default = (path3) => {
1218
1301
  * @param version - (Optional) The version of the domain to add the service to
1219
1302
  * @returns
1220
1303
  */
1221
- addServiceToDomain: addServiceToDomain(join12(path3, "domains")),
1304
+ addServiceToDomain: addServiceToDomain(join13(path4, "domains")),
1222
1305
  /**
1223
1306
  * ================================
1224
1307
  * Teams
@@ -1231,25 +1314,25 @@ var index_default = (path3) => {
1231
1314
  * @param options - Optional options to write the team
1232
1315
  *
1233
1316
  */
1234
- writeTeam: writeTeam(join12(path3, "teams")),
1317
+ writeTeam: writeTeam(join13(path4, "teams")),
1235
1318
  /**
1236
1319
  * Returns a team from EventCatalog
1237
1320
  * @param id - The id of the team to retrieve
1238
1321
  * @returns Team|Undefined
1239
1322
  */
1240
- getTeam: getTeam(join12(path3, "teams")),
1323
+ getTeam: getTeam(join13(path4, "teams")),
1241
1324
  /**
1242
1325
  * Returns all teams from EventCatalog
1243
1326
  * @returns Team[]|Undefined
1244
1327
  */
1245
- getTeams: getTeams(join12(path3)),
1328
+ getTeams: getTeams(join13(path4)),
1246
1329
  /**
1247
1330
  * Remove a team by the team id
1248
1331
  *
1249
1332
  * @param id - The id of the team you want to remove
1250
1333
  *
1251
1334
  */
1252
- rmTeamById: rmTeamById(join12(path3, "teams")),
1335
+ rmTeamById: rmTeamById(join13(path4, "teams")),
1253
1336
  /**
1254
1337
  * ================================
1255
1338
  * Users
@@ -1262,25 +1345,25 @@ var index_default = (path3) => {
1262
1345
  * @param options - Optional options to write the user
1263
1346
  *
1264
1347
  */
1265
- writeUser: writeUser(join12(path3, "users")),
1348
+ writeUser: writeUser(join13(path4, "users")),
1266
1349
  /**
1267
1350
  * Returns a user from EventCatalog
1268
1351
  * @param id - The id of the user to retrieve
1269
1352
  * @returns User|Undefined
1270
1353
  */
1271
- getUser: getUser(join12(path3, "users")),
1354
+ getUser: getUser(join13(path4, "users")),
1272
1355
  /**
1273
1356
  * Returns all user from EventCatalog
1274
1357
  * @returns User[]|Undefined
1275
1358
  */
1276
- getUsers: getUsers(join12(path3)),
1359
+ getUsers: getUsers(join13(path4)),
1277
1360
  /**
1278
1361
  * Remove a user by the user id
1279
1362
  *
1280
1363
  * @param id - The id of the user you want to remove
1281
1364
  *
1282
1365
  */
1283
- rmUserById: rmUserById(join12(path3, "users")),
1366
+ rmUserById: rmUserById(join13(path4, "users")),
1284
1367
  /**
1285
1368
  * ================================
1286
1369
  * Custom Docs
@@ -1291,26 +1374,32 @@ var index_default = (path3) => {
1291
1374
  * @param path - The path to the custom doc to retrieve
1292
1375
  * @returns CustomDoc|Undefined
1293
1376
  */
1294
- getCustomDoc: getCustomDoc(join12(path3, "docs")),
1377
+ getCustomDoc: getCustomDoc(join13(path4, "docs")),
1295
1378
  /**
1296
1379
  * Returns all custom docs from EventCatalog
1297
1380
  * @param options - Optional options to get custom docs from a specific path
1298
1381
  * @returns CustomDoc[]|Undefined
1299
1382
  */
1300
- getCustomDocs: getCustomDocs(join12(path3, "docs")),
1383
+ getCustomDocs: getCustomDocs(join13(path4, "docs")),
1301
1384
  /**
1302
1385
  * Writes a custom doc to EventCatalog
1303
1386
  * @param customDoc - The custom doc to write
1304
1387
  * @param options - Optional options to write the custom doc
1305
1388
  *
1306
1389
  */
1307
- writeCustomDoc: writeCustomDoc(join12(path3, "docs")),
1390
+ writeCustomDoc: writeCustomDoc(join13(path4, "docs")),
1308
1391
  /**
1309
1392
  * Removes a custom doc from EventCatalog
1310
1393
  * @param path - The path to the custom doc to remove
1311
1394
  *
1312
1395
  */
1313
- rmCustomDoc: rmCustomDoc(join12(path3, "docs"))
1396
+ rmCustomDoc: rmCustomDoc(join13(path4, "docs")),
1397
+ /**
1398
+ * Dumps the catalog to a JSON file.
1399
+ * @param directory - The directory to dump the catalog to
1400
+ * @returns A JSON file with the catalog
1401
+ */
1402
+ dumpCatalog: dumpCatalog(join13(path4))
1314
1403
  };
1315
1404
  };
1316
1405
  export {