@eventcatalog/sdk 2.2.1 → 2.2.3

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