@eventcatalog/sdk 2.0.1 → 2.1.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.
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/index.ts
2
- import { join as join11 } from "node:path";
2
+ import { join as join12 } 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((path) => !path.includes("versioned"));
23
+ const latestVersion = matchedFiles.find((path2) => !path2.includes("versioned"));
24
24
  if (!version) {
25
25
  return latestVersion;
26
26
  }
27
- const parsedFiles = matchedFiles.map((path) => {
28
- const { data } = matter.read(path);
29
- return { ...data, path };
27
+ const parsedFiles = matchedFiles.map((path2) => {
28
+ const { data } = matter.read(path2);
29
+ return { ...data, path: path2 };
30
30
  });
31
31
  const semverRange = validRange(version);
32
32
  if (semverRange && valid(version)) {
@@ -50,6 +50,11 @@ var getFiles = async (pattern, ignore = "") => {
50
50
  throw new Error(`Error finding files: ${error}`);
51
51
  }
52
52
  };
53
+ var readMdxFile = async (path2) => {
54
+ const { data } = matter.read(path2);
55
+ const { markdown, ...frontmatter } = data;
56
+ return { ...frontmatter, markdown };
57
+ };
53
58
  var searchFilesForId = async (files, id, version) => {
54
59
  const idRegex = new RegExp(`^id:\\s*(['"]|>-)?\\s*${id}['"]?\\s*$`, "m");
55
60
  const versionRegex = new RegExp(`^version:\\s*['"]?${version}['"]?\\s*$`, "m");
@@ -127,8 +132,8 @@ var writeResource = async (catalogDir, resource, options = {
127
132
  override: false,
128
133
  versionExistingContent: false
129
134
  }) => {
130
- const path = options.path || `/${resource.id}`;
131
- const fullPath = join2(catalogDir, path);
135
+ const path2 = options.path || `/${resource.id}`;
136
+ const fullPath = join2(catalogDir, path2);
132
137
  fsSync2.mkdirSync(fullPath, { recursive: true });
133
138
  const lockPath = join2(fullPath, "index.mdx");
134
139
  if (!fsSync2.existsSync(lockPath)) {
@@ -171,9 +176,15 @@ var getResource = async (catalogDir, id, version, options) => {
171
176
  markdown: content.trim()
172
177
  };
173
178
  };
174
- var getResources = async (catalogDir, { type, latestOnly = false, ignore = [] }) => {
179
+ var getResources = async (catalogDir, {
180
+ type,
181
+ latestOnly = false,
182
+ ignore = [],
183
+ pattern = ""
184
+ }) => {
175
185
  const ignoreList = latestOnly ? `**/versioned/**` : "";
176
- const files = await getFiles(`${catalogDir}/**/${type}/**/index.{md,mdx}`, [ignoreList, ...ignore]);
186
+ const filePattern = pattern || `${catalogDir}/**/${type}/**/index.{md,mdx}`;
187
+ const files = await getFiles(filePattern, [ignoreList, ...ignore]);
177
188
  if (files.length === 0) return;
178
189
  return files.map((file) => {
179
190
  const { data, content } = matter2.read(file);
@@ -229,8 +240,8 @@ var writeEventToService = (directory) => async (event, service, options = { path
229
240
  pathForEvent = join3(pathForEvent, event.id);
230
241
  await writeResource(directory, { ...event }, { ...options, path: pathForEvent, type: "event" });
231
242
  };
232
- var rmEvent = (directory) => async (path) => {
233
- await fs2.rm(join3(directory, path), { recursive: true });
243
+ var rmEvent = (directory) => async (path2) => {
244
+ await fs2.rm(join3(directory, path2), { recursive: true });
234
245
  };
235
246
  var rmEventById = (directory) => async (id, version, persistFiles) => {
236
247
  await rmResourceById(directory, id, version, { type: "event", persistFiles });
@@ -256,8 +267,8 @@ var writeCommandToService = (directory) => async (command, service, options = {
256
267
  pathForEvent = join4(pathForEvent, command.id);
257
268
  await writeResource(directory, { ...command }, { ...options, path: pathForEvent, type: "command" });
258
269
  };
259
- var rmCommand = (directory) => async (path) => {
260
- await fs3.rm(join4(directory, path), { recursive: true });
270
+ var rmCommand = (directory) => async (path2) => {
271
+ await fs3.rm(join4(directory, path2), { recursive: true });
261
272
  };
262
273
  var rmCommandById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "command", persistFiles });
263
274
  var versionCommand = (directory) => async (id) => versionResource(directory, id);
@@ -281,8 +292,8 @@ var writeQueryToService = (directory) => async (query, service, options = { path
281
292
  pathForQuery = join5(pathForQuery, query.id);
282
293
  await writeResource(directory, { ...query }, { ...options, path: pathForQuery, type: "query" });
283
294
  };
284
- var rmQuery = (directory) => async (path) => {
285
- await fs4.rm(join5(directory, path), { recursive: true });
295
+ var rmQuery = (directory) => async (path2) => {
296
+ await fs4.rm(join5(directory, path2), { recursive: true });
286
297
  };
287
298
  var rmQueryById = (directory) => async (id, version, persistFiles) => {
288
299
  await rmResourceById(directory, id, version, { type: "query", persistFiles });
@@ -318,8 +329,8 @@ var writeService = (directory) => async (service, options = { path: "" }) => {
318
329
  };
319
330
  var writeVersionedService = (directory) => async (service) => {
320
331
  const resource = { ...service };
321
- const path = getVersionedDirectory(service.id, service.version);
322
- return await writeService(directory)(resource, { path });
332
+ const path2 = getVersionedDirectory(service.id, service.version);
333
+ return await writeService(directory)(resource, { path: path2 });
323
334
  };
324
335
  var writeServiceToDomain = (directory) => async (service, domain, options = { path: "" }) => {
325
336
  let pathForService = domain.version && domain.version !== "latest" ? `/${domain.id}/versioned/${domain.version}/services` : `/${domain.id}/services`;
@@ -327,8 +338,8 @@ var writeServiceToDomain = (directory) => async (service, domain, options = { pa
327
338
  await writeResource(directory, { ...service }, { ...options, path: pathForService, type: "service" });
328
339
  };
329
340
  var versionService = (directory) => async (id) => versionResource(directory, id);
330
- var rmService = (directory) => async (path) => {
331
- await fs5.rm(join6(directory, path), { recursive: true });
341
+ var rmService = (directory) => async (path2) => {
342
+ await fs5.rm(join6(directory, path2), { recursive: true });
332
343
  };
333
344
  var rmServiceById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "service", persistFiles });
334
345
  var addFileToService = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
@@ -381,8 +392,8 @@ var addMessageToService = (directory) => async (id, direction, event, version) =
381
392
  if (!existingResource) {
382
393
  throw new Error(`Cannot find service ${id} in the catalog`);
383
394
  }
384
- const path = existingResource.split("/services")[0];
385
- const pathToResource = join6(path, "services");
395
+ const path2 = existingResource.split("/services")[0];
396
+ const pathToResource = join6(path2, "services");
386
397
  await rmServiceById(directory)(id, version);
387
398
  await writeService(pathToResource)(service);
388
399
  };
@@ -408,8 +419,8 @@ var writeDomain = (directory) => async (domain, options = { path: "" }) => {
408
419
  return await writeResource(directory, resource, { ...options, type: "domain" });
409
420
  };
410
421
  var versionDomain = (directory) => async (id) => versionResource(directory, id);
411
- var rmDomain = (directory) => async (path) => {
412
- await fs6.rm(join7(directory, path), { recursive: true });
422
+ var rmDomain = (directory) => async (path2) => {
423
+ await fs6.rm(join7(directory, path2), { recursive: true });
413
424
  };
414
425
  var rmDomainById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "domain", persistFiles });
415
426
  var addFileToDomain = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
@@ -437,8 +448,8 @@ import { join as join8 } from "node:path";
437
448
  var getChannel = (directory) => async (id, version) => getResource(directory, id, version, { type: "channel" });
438
449
  var getChannels = (directory) => async (options) => getResources(directory, { type: "channels", ...options });
439
450
  var writeChannel = (directory) => async (channel, options = { path: "" }) => writeResource(directory, { ...channel }, { ...options, type: "channel" });
440
- var rmChannel = (directory) => async (path) => {
441
- await fs7.rm(join8(directory, path), { recursive: true });
451
+ var rmChannel = (directory) => async (path2) => {
452
+ await fs7.rm(join8(directory, path2), { recursive: true });
442
453
  };
443
454
  var rmChannelById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "channel", persistFiles });
444
455
  var versionChannel = (directory) => async (id) => versionResource(directory, id);
@@ -477,22 +488,58 @@ var addMessageToChannel = (directory, collection) => async (id, _message, versio
477
488
  if (!existingResource) {
478
489
  throw new Error(`Cannot find message ${id} in the catalog`);
479
490
  }
480
- const path = existingResource.split(`/${collection}`)[0];
481
- const pathToResource = join8(path, collection);
491
+ const path2 = existingResource.split(`/${collection}`)[0];
492
+ const pathToResource = join8(path2, collection);
482
493
  await rmMessageById(directory)(_message.id, _message.version, true);
483
494
  await writeMessage(pathToResource)(message);
484
495
  };
485
496
 
486
- // src/teams.ts
487
- import fs8 from "node:fs/promises";
497
+ // src/custom-docs.ts
498
+ import path, { join as join9 } from "node:path";
488
499
  import fsSync3 from "node:fs";
489
- import { join as join9 } from "node:path";
500
+ import fs8 from "node:fs/promises";
490
501
  import matter3 from "gray-matter";
502
+ import slugify from "slugify";
503
+ var getCustomDoc = (directory) => async (filePath) => {
504
+ const fullPath = path.join(directory, filePath);
505
+ const fullPathWithExtension = fullPath.endsWith(".mdx") ? fullPath : `${fullPath}.mdx`;
506
+ const fileExists = fsSync3.existsSync(fullPathWithExtension);
507
+ if (!fileExists) {
508
+ return void 0;
509
+ }
510
+ return readMdxFile(fullPathWithExtension);
511
+ };
512
+ var getCustomDocs = (directory) => async (options) => {
513
+ if (options?.path) {
514
+ const pattern = `${directory}/${options.path}/**/*.{md,mdx}`;
515
+ return getResources(directory, { type: "docs", pattern });
516
+ }
517
+ return getResources(directory, { type: "docs", pattern: `${directory}/**/*.{md,mdx}` });
518
+ };
519
+ var writeCustomDoc = (directory) => async (customDoc, options = { path: "" }) => {
520
+ const { fileName, ...rest } = customDoc;
521
+ const name = fileName || slugify(customDoc.title, { lower: true });
522
+ const withExtension = name.endsWith(".mdx") ? name : `${name}.mdx`;
523
+ const fullPath = path.join(directory, options.path || "", withExtension);
524
+ fsSync3.mkdirSync(path.dirname(fullPath), { recursive: true });
525
+ const document = matter3.stringify(customDoc.markdown.trim(), rest);
526
+ fsSync3.writeFileSync(fullPath, document);
527
+ };
528
+ var rmCustomDoc = (directory) => async (filePath) => {
529
+ const withExtension = filePath.endsWith(".mdx") ? filePath : `${filePath}.mdx`;
530
+ await fs8.rm(join9(directory, withExtension), { recursive: true });
531
+ };
532
+
533
+ // src/teams.ts
534
+ import fs9 from "node:fs/promises";
535
+ import fsSync4 from "node:fs";
536
+ import { join as join10 } from "node:path";
537
+ import matter4 from "gray-matter";
491
538
  var getTeam = (catalogDir) => async (id) => {
492
539
  const files = await getFiles(`${catalogDir}/${id}.md`);
493
540
  if (files.length == 0) return void 0;
494
541
  const file = files[0];
495
- const { data, content } = matter3.read(file);
542
+ const { data, content } = matter4.read(file);
496
543
  return {
497
544
  ...data,
498
545
  id: data.id,
@@ -504,7 +551,7 @@ var getTeams = (catalogDir) => async (options) => {
504
551
  const files = await getFiles(`${catalogDir}/teams/*.md`);
505
552
  if (files.length === 0) return [];
506
553
  return files.map((file) => {
507
- const { data, content } = matter3.read(file);
554
+ const { data, content } = matter4.read(file);
508
555
  return {
509
556
  ...data,
510
557
  id: data.id,
@@ -521,23 +568,23 @@ var writeTeam = (catalogDir) => async (team, options = {}) => {
521
568
  throw new Error(`Failed to write ${resource.id} (team) as it already exists`);
522
569
  }
523
570
  const { markdown, ...frontmatter } = resource;
524
- const document = matter3.stringify(markdown, frontmatter);
525
- fsSync3.mkdirSync(join9(catalogDir, ""), { recursive: true });
526
- fsSync3.writeFileSync(join9(catalogDir, "", `${resource.id}.md`), document);
571
+ const document = matter4.stringify(markdown, frontmatter);
572
+ fsSync4.mkdirSync(join10(catalogDir, ""), { recursive: true });
573
+ fsSync4.writeFileSync(join10(catalogDir, "", `${resource.id}.md`), document);
527
574
  };
528
575
  var rmTeamById = (catalogDir) => async (id) => {
529
- await fs8.rm(join9(catalogDir, `${id}.md`), { recursive: true });
576
+ await fs9.rm(join10(catalogDir, `${id}.md`), { recursive: true });
530
577
  };
531
578
 
532
579
  // src/users.ts
533
- import fsSync4 from "node:fs";
534
- import { join as join10 } from "node:path";
535
- import matter4 from "gray-matter";
580
+ import fsSync5 from "node:fs";
581
+ import { join as join11 } from "node:path";
582
+ import matter5 from "gray-matter";
536
583
  var getUser = (catalogDir) => async (id) => {
537
584
  const files = await getFiles(`${catalogDir}/${id}.md`);
538
585
  if (files.length == 0) return void 0;
539
586
  const file = files[0];
540
- const { data, content } = matter4.read(file);
587
+ const { data, content } = matter5.read(file);
541
588
  return {
542
589
  ...data,
543
590
  id: data.id,
@@ -550,7 +597,7 @@ var getUsers = (catalogDir) => async (options) => {
550
597
  const files = await getFiles(`${catalogDir}/users/*.md`);
551
598
  if (files.length === 0) return [];
552
599
  return files.map((file) => {
553
- const { data, content } = matter4.read(file);
600
+ const { data, content } = matter5.read(file);
554
601
  return {
555
602
  ...data,
556
603
  id: data.id,
@@ -568,16 +615,16 @@ var writeUser = (catalogDir) => async (user, options = {}) => {
568
615
  throw new Error(`Failed to write ${resource.id} (user) as it already exists`);
569
616
  }
570
617
  const { markdown, ...frontmatter } = resource;
571
- const document = matter4.stringify(markdown, frontmatter);
572
- fsSync4.mkdirSync(join10(catalogDir, ""), { recursive: true });
573
- fsSync4.writeFileSync(join10(catalogDir, "", `${resource.id}.md`), document);
618
+ const document = matter5.stringify(markdown, frontmatter);
619
+ fsSync5.mkdirSync(join11(catalogDir, ""), { recursive: true });
620
+ fsSync5.writeFileSync(join11(catalogDir, "", `${resource.id}.md`), document);
574
621
  };
575
622
  var rmUserById = (catalogDir) => async (id) => {
576
- fsSync4.rmSync(join10(catalogDir, `${id}.md`), { recursive: true });
623
+ fsSync5.rmSync(join11(catalogDir, `${id}.md`), { recursive: true });
577
624
  };
578
625
 
579
626
  // src/index.ts
580
- var index_default = (path) => {
627
+ var index_default = (path2) => {
581
628
  return {
582
629
  /**
583
630
  * Returns an events from EventCatalog
@@ -585,13 +632,13 @@ var index_default = (path) => {
585
632
  * @param version - Optional id of the version to get (supports semver)
586
633
  * @returns Event|Undefined
587
634
  */
588
- getEvent: getEvent(join11(path)),
635
+ getEvent: getEvent(join12(path2)),
589
636
  /**
590
637
  * Returns all events from EventCatalog
591
638
  * @param latestOnly - optional boolean, set to true to get only latest versions
592
639
  * @returns Event[]|Undefined
593
640
  */
594
- getEvents: getEvents(join11(path)),
641
+ getEvents: getEvents(join12(path2)),
595
642
  /**
596
643
  * Adds an event to EventCatalog
597
644
  *
@@ -599,7 +646,7 @@ var index_default = (path) => {
599
646
  * @param options - Optional options to write the event
600
647
  *
601
648
  */
602
- writeEvent: writeEvent(join11(path, "events")),
649
+ writeEvent: writeEvent(join12(path2, "events")),
603
650
  /**
604
651
  * Adds an event to a service in EventCatalog
605
652
  *
@@ -608,26 +655,26 @@ var index_default = (path) => {
608
655
  * @param options - Optional options to write the event
609
656
  *
610
657
  */
611
- writeEventToService: writeEventToService(join11(path, "services")),
658
+ writeEventToService: writeEventToService(join12(path2, "services")),
612
659
  /**
613
660
  * Remove an event to EventCatalog (modeled on the standard POSIX rm utility)
614
661
  *
615
662
  * @param path - The path to your event, e.g. `/Inventory/InventoryAdjusted`
616
663
  *
617
664
  */
618
- rmEvent: rmEvent(join11(path, "events")),
665
+ rmEvent: rmEvent(join12(path2, "events")),
619
666
  /**
620
667
  * Remove an event by an Event id
621
668
  *
622
669
  * @param id - The id of the event you want to remove
623
670
  *
624
671
  */
625
- rmEventById: rmEventById(join11(path)),
672
+ rmEventById: rmEventById(join12(path2)),
626
673
  /**
627
674
  * Moves a given event id to the version directory
628
675
  * @param directory
629
676
  */
630
- versionEvent: versionEvent(join11(path)),
677
+ versionEvent: versionEvent(join12(path2)),
631
678
  /**
632
679
  * Adds a file to the given event
633
680
  * @param id - The id of the event to add the file to
@@ -635,7 +682,7 @@ var index_default = (path) => {
635
682
  * @param version - Optional version of the event to add the file to
636
683
  * @returns
637
684
  */
638
- addFileToEvent: addFileToEvent(join11(path)),
685
+ addFileToEvent: addFileToEvent(join12(path2)),
639
686
  /**
640
687
  * Adds a schema to the given event
641
688
  * @param id - The id of the event to add the schema to
@@ -643,14 +690,14 @@ var index_default = (path) => {
643
690
  * @param version - Optional version of the event to add the schema to
644
691
  * @returns
645
692
  */
646
- addSchemaToEvent: addSchemaToEvent(join11(path)),
693
+ addSchemaToEvent: addSchemaToEvent(join12(path2)),
647
694
  /**
648
695
  * Check to see if an event version exists
649
696
  * @param id - The id of the event
650
697
  * @param version - The version of the event (supports semver)
651
698
  * @returns
652
699
  */
653
- eventHasVersion: eventHasVersion(join11(path)),
700
+ eventHasVersion: eventHasVersion(join12(path2)),
654
701
  /**
655
702
  * ================================
656
703
  * Commands
@@ -662,13 +709,13 @@ var index_default = (path) => {
662
709
  * @param version - Optional id of the version to get (supports semver)
663
710
  * @returns Command|Undefined
664
711
  */
665
- getCommand: getCommand(join11(path)),
712
+ getCommand: getCommand(join12(path2)),
666
713
  /**
667
714
  * Returns all commands from EventCatalog
668
715
  * @param latestOnly - optional boolean, set to true to get only latest versions
669
716
  * @returns Command[]|Undefined
670
717
  */
671
- getCommands: getCommands(join11(path)),
718
+ getCommands: getCommands(join12(path2)),
672
719
  /**
673
720
  * Adds an command to EventCatalog
674
721
  *
@@ -676,7 +723,7 @@ var index_default = (path) => {
676
723
  * @param options - Optional options to write the command
677
724
  *
678
725
  */
679
- writeCommand: writeCommand(join11(path, "commands")),
726
+ writeCommand: writeCommand(join12(path2, "commands")),
680
727
  /**
681
728
  * Adds a command to a service in EventCatalog
682
729
  *
@@ -685,26 +732,26 @@ var index_default = (path) => {
685
732
  * @param options - Optional options to write the command
686
733
  *
687
734
  */
688
- writeCommandToService: writeCommandToService(join11(path, "services")),
735
+ writeCommandToService: writeCommandToService(join12(path2, "services")),
689
736
  /**
690
737
  * Remove an command to EventCatalog (modeled on the standard POSIX rm utility)
691
738
  *
692
739
  * @param path - The path to your command, e.g. `/Inventory/InventoryAdjusted`
693
740
  *
694
741
  */
695
- rmCommand: rmCommand(join11(path, "commands")),
742
+ rmCommand: rmCommand(join12(path2, "commands")),
696
743
  /**
697
744
  * Remove an command by an Event id
698
745
  *
699
746
  * @param id - The id of the command you want to remove
700
747
  *
701
748
  */
702
- rmCommandById: rmCommandById(join11(path)),
749
+ rmCommandById: rmCommandById(join12(path2)),
703
750
  /**
704
751
  * Moves a given command id to the version directory
705
752
  * @param directory
706
753
  */
707
- versionCommand: versionCommand(join11(path)),
754
+ versionCommand: versionCommand(join12(path2)),
708
755
  /**
709
756
  * Adds a file to the given command
710
757
  * @param id - The id of the command to add the file to
@@ -712,7 +759,7 @@ var index_default = (path) => {
712
759
  * @param version - Optional version of the command to add the file to
713
760
  * @returns
714
761
  */
715
- addFileToCommand: addFileToCommand(join11(path)),
762
+ addFileToCommand: addFileToCommand(join12(path2)),
716
763
  /**
717
764
  * Adds a schema to the given command
718
765
  * @param id - The id of the command to add the schema to
@@ -720,14 +767,14 @@ var index_default = (path) => {
720
767
  * @param version - Optional version of the command to add the schema to
721
768
  * @returns
722
769
  */
723
- addSchemaToCommand: addSchemaToCommand(join11(path)),
770
+ addSchemaToCommand: addSchemaToCommand(join12(path2)),
724
771
  /**
725
772
  * Check to see if a command version exists
726
773
  * @param id - The id of the command
727
774
  * @param version - The version of the command (supports semver)
728
775
  * @returns
729
776
  */
730
- commandHasVersion: commandHasVersion(join11(path)),
777
+ commandHasVersion: commandHasVersion(join12(path2)),
731
778
  /**
732
779
  * ================================
733
780
  * Queries
@@ -739,13 +786,13 @@ var index_default = (path) => {
739
786
  * @param version - Optional id of the version to get (supports semver)
740
787
  * @returns Query|Undefined
741
788
  */
742
- getQuery: getQuery(join11(path)),
789
+ getQuery: getQuery(join12(path2)),
743
790
  /**
744
791
  * Returns all queries from EventCatalog
745
792
  * @param latestOnly - optional boolean, set to true to get only latest versions
746
793
  * @returns Query[]|Undefined
747
794
  */
748
- getQueries: getQueries(join11(path)),
795
+ getQueries: getQueries(join12(path2)),
749
796
  /**
750
797
  * Adds a query to EventCatalog
751
798
  *
@@ -753,7 +800,7 @@ var index_default = (path) => {
753
800
  * @param options - Optional options to write the event
754
801
  *
755
802
  */
756
- writeQuery: writeQuery(join11(path, "queries")),
803
+ writeQuery: writeQuery(join12(path2, "queries")),
757
804
  /**
758
805
  * Adds a query to a service in EventCatalog
759
806
  *
@@ -762,26 +809,26 @@ var index_default = (path) => {
762
809
  * @param options - Optional options to write the query
763
810
  *
764
811
  */
765
- writeQueryToService: writeQueryToService(join11(path, "services")),
812
+ writeQueryToService: writeQueryToService(join12(path2, "services")),
766
813
  /**
767
814
  * Remove an query to EventCatalog (modeled on the standard POSIX rm utility)
768
815
  *
769
816
  * @param path - The path to your query, e.g. `/Orders/GetOrder`
770
817
  *
771
818
  */
772
- rmQuery: rmQuery(join11(path, "queries")),
819
+ rmQuery: rmQuery(join12(path2, "queries")),
773
820
  /**
774
821
  * Remove a query by a Query id
775
822
  *
776
823
  * @param id - The id of the query you want to remove
777
824
  *
778
825
  */
779
- rmQueryById: rmQueryById(join11(path)),
826
+ rmQueryById: rmQueryById(join12(path2)),
780
827
  /**
781
828
  * Moves a given query id to the version directory
782
829
  * @param directory
783
830
  */
784
- versionQuery: versionQuery(join11(path)),
831
+ versionQuery: versionQuery(join12(path2)),
785
832
  /**
786
833
  * Adds a file to the given query
787
834
  * @param id - The id of the query to add the file to
@@ -789,7 +836,7 @@ var index_default = (path) => {
789
836
  * @param version - Optional version of the query to add the file to
790
837
  * @returns
791
838
  */
792
- addFileToQuery: addFileToQuery(join11(path)),
839
+ addFileToQuery: addFileToQuery(join12(path2)),
793
840
  /**
794
841
  * Adds a schema to the given query
795
842
  * @param id - The id of the query to add the schema to
@@ -797,14 +844,14 @@ var index_default = (path) => {
797
844
  * @param version - Optional version of the query to add the schema to
798
845
  * @returns
799
846
  */
800
- addSchemaToQuery: addSchemaToQuery(join11(path)),
847
+ addSchemaToQuery: addSchemaToQuery(join12(path2)),
801
848
  /**
802
849
  * Check to see if an query version exists
803
850
  * @param id - The id of the query
804
851
  * @param version - The version of the query (supports semver)
805
852
  * @returns
806
853
  */
807
- queryHasVersion: queryHasVersion(join11(path)),
854
+ queryHasVersion: queryHasVersion(join12(path2)),
808
855
  /**
809
856
  * ================================
810
857
  * Channels
@@ -816,13 +863,13 @@ var index_default = (path) => {
816
863
  * @param version - Optional id of the version to get (supports semver)
817
864
  * @returns Channel|Undefined
818
865
  */
819
- getChannel: getChannel(join11(path)),
866
+ getChannel: getChannel(join12(path2)),
820
867
  /**
821
868
  * Returns all channels from EventCatalog
822
869
  * @param latestOnly - optional boolean, set to true to get only latest versions
823
870
  * @returns Channel[]|Undefined
824
871
  */
825
- getChannels: getChannels(join11(path)),
872
+ getChannels: getChannels(join12(path2)),
826
873
  /**
827
874
  * Adds an channel to EventCatalog
828
875
  *
@@ -830,33 +877,33 @@ var index_default = (path) => {
830
877
  * @param options - Optional options to write the channel
831
878
  *
832
879
  */
833
- writeChannel: writeChannel(join11(path, "channels")),
880
+ writeChannel: writeChannel(join12(path2, "channels")),
834
881
  /**
835
882
  * Remove an channel to EventCatalog (modeled on the standard POSIX rm utility)
836
883
  *
837
884
  * @param path - The path to your channel, e.g. `/Inventory/InventoryAdjusted`
838
885
  *
839
886
  */
840
- rmChannel: rmChannel(join11(path, "channels")),
887
+ rmChannel: rmChannel(join12(path2, "channels")),
841
888
  /**
842
889
  * Remove an channel by an Event id
843
890
  *
844
891
  * @param id - The id of the channel you want to remove
845
892
  *
846
893
  */
847
- rmChannelById: rmChannelById(join11(path)),
894
+ rmChannelById: rmChannelById(join12(path2)),
848
895
  /**
849
896
  * Moves a given channel id to the version directory
850
897
  * @param directory
851
898
  */
852
- versionChannel: versionChannel(join11(path)),
899
+ versionChannel: versionChannel(join12(path2)),
853
900
  /**
854
901
  * Check to see if a channel version exists
855
902
  * @param id - The id of the channel
856
903
  * @param version - The version of the channel (supports semver)
857
904
  * @returns
858
905
  */
859
- channelHasVersion: channelHasVersion(join11(path)),
906
+ channelHasVersion: channelHasVersion(join12(path2)),
860
907
  /**
861
908
  * Add a channel to an event
862
909
  *
@@ -873,7 +920,7 @@ var index_default = (path) => {
873
920
  *
874
921
  * ```
875
922
  */
876
- addEventToChannel: addMessageToChannel(join11(path), "events"),
923
+ addEventToChannel: addMessageToChannel(join12(path2), "events"),
877
924
  /**
878
925
  * Add a channel to an command
879
926
  *
@@ -890,7 +937,7 @@ var index_default = (path) => {
890
937
  *
891
938
  * ```
892
939
  */
893
- addCommandToChannel: addMessageToChannel(join11(path), "commands"),
940
+ addCommandToChannel: addMessageToChannel(join12(path2), "commands"),
894
941
  /**
895
942
  * Add a channel to an query
896
943
  *
@@ -907,7 +954,7 @@ var index_default = (path) => {
907
954
  *
908
955
  * ```
909
956
  */
910
- addQueryToChannel: addMessageToChannel(join11(path), "queries"),
957
+ addQueryToChannel: addMessageToChannel(join12(path2), "queries"),
911
958
  /**
912
959
  * ================================
913
960
  * SERVICES
@@ -920,14 +967,14 @@ var index_default = (path) => {
920
967
  * @param options - Optional options to write the event
921
968
  *
922
969
  */
923
- writeService: writeService(join11(path, "services")),
970
+ writeService: writeService(join12(path2, "services")),
924
971
  /**
925
972
  * Adds a versioned service to EventCatalog
926
973
  *
927
974
  * @param service - The service to write
928
975
  *
929
976
  */
930
- writeVersionedService: writeVersionedService(join11(path, "services")),
977
+ writeVersionedService: writeVersionedService(join12(path2, "services")),
931
978
  /**
932
979
  * Adds a service to a domain in EventCatalog
933
980
  *
@@ -936,39 +983,39 @@ var index_default = (path) => {
936
983
  * @param options - Optional options to write the event
937
984
  *
938
985
  */
939
- writeServiceToDomain: writeServiceToDomain(join11(path, "domains")),
986
+ writeServiceToDomain: writeServiceToDomain(join12(path2, "domains")),
940
987
  /**
941
988
  * Returns a service from EventCatalog
942
989
  * @param id - The id of the service to retrieve
943
990
  * @param version - Optional id of the version to get (supports semver)
944
991
  * @returns Service|Undefined
945
992
  */
946
- getService: getService(join11(path)),
993
+ getService: getService(join12(path2)),
947
994
  /**
948
995
  * Returns all services from EventCatalog
949
996
  * @param latestOnly - optional boolean, set to true to get only latest versions
950
997
  * @returns Service[]|Undefined
951
998
  */
952
- getServices: getServices(join11(path)),
999
+ getServices: getServices(join12(path2)),
953
1000
  /**
954
1001
  * Moves a given service id to the version directory
955
1002
  * @param directory
956
1003
  */
957
- versionService: versionService(join11(path)),
1004
+ versionService: versionService(join12(path2)),
958
1005
  /**
959
1006
  * Remove a service from EventCatalog (modeled on the standard POSIX rm utility)
960
1007
  *
961
1008
  * @param path - The path to your service, e.g. `/InventoryService`
962
1009
  *
963
1010
  */
964
- rmService: rmService(join11(path, "services")),
1011
+ rmService: rmService(join12(path2, "services")),
965
1012
  /**
966
1013
  * Remove an service by an service id
967
1014
  *
968
1015
  * @param id - The id of the service you want to remove
969
1016
  *
970
1017
  */
971
- rmServiceById: rmServiceById(join11(path)),
1018
+ rmServiceById: rmServiceById(join12(path2)),
972
1019
  /**
973
1020
  * Adds a file to the given service
974
1021
  * @param id - The id of the service to add the file to
@@ -976,21 +1023,21 @@ var index_default = (path) => {
976
1023
  * @param version - Optional version of the service to add the file to
977
1024
  * @returns
978
1025
  */
979
- addFileToService: addFileToService(join11(path)),
1026
+ addFileToService: addFileToService(join12(path2)),
980
1027
  /**
981
1028
  * Returns the specifications for a given service
982
1029
  * @param id - The id of the service to retrieve the specifications for
983
1030
  * @param version - Optional version of the service
984
1031
  * @returns
985
1032
  */
986
- getSpecificationFilesForService: getSpecificationFilesForService(join11(path)),
1033
+ getSpecificationFilesForService: getSpecificationFilesForService(join12(path2)),
987
1034
  /**
988
1035
  * Check to see if a service version exists
989
1036
  * @param id - The id of the service
990
1037
  * @param version - The version of the service (supports semver)
991
1038
  * @returns
992
1039
  */
993
- serviceHasVersion: serviceHasVersion(join11(path)),
1040
+ serviceHasVersion: serviceHasVersion(join12(path2)),
994
1041
  /**
995
1042
  * Add an event to a service by it's id.
996
1043
  *
@@ -1010,7 +1057,7 @@ var index_default = (path) => {
1010
1057
  *
1011
1058
  * ```
1012
1059
  */
1013
- addEventToService: addMessageToService(join11(path)),
1060
+ addEventToService: addMessageToService(join12(path2)),
1014
1061
  /**
1015
1062
  * Add a command to a service by it's id.
1016
1063
  *
@@ -1030,7 +1077,7 @@ var index_default = (path) => {
1030
1077
  *
1031
1078
  * ```
1032
1079
  */
1033
- addCommandToService: addMessageToService(join11(path)),
1080
+ addCommandToService: addMessageToService(join12(path2)),
1034
1081
  /**
1035
1082
  * Add a query to a service by it's id.
1036
1083
  *
@@ -1050,7 +1097,7 @@ var index_default = (path) => {
1050
1097
  *
1051
1098
  * ```
1052
1099
  */
1053
- addQueryToService: addMessageToService(join11(path)),
1100
+ addQueryToService: addMessageToService(join12(path2)),
1054
1101
  /**
1055
1102
  * ================================
1056
1103
  * Domains
@@ -1063,39 +1110,39 @@ var index_default = (path) => {
1063
1110
  * @param options - Optional options to write the event
1064
1111
  *
1065
1112
  */
1066
- writeDomain: writeDomain(join11(path, "domains")),
1113
+ writeDomain: writeDomain(join12(path2, "domains")),
1067
1114
  /**
1068
1115
  * Returns a domain from EventCatalog
1069
1116
  * @param id - The id of the domain to retrieve
1070
1117
  * @param version - Optional id of the version to get (supports semver)
1071
1118
  * @returns Domain|Undefined
1072
1119
  */
1073
- getDomain: getDomain(join11(path, "domains")),
1120
+ getDomain: getDomain(join12(path2, "domains")),
1074
1121
  /**
1075
1122
  * Returns all domains from EventCatalog
1076
1123
  * @param latestOnly - optional boolean, set to true to get only latest versions
1077
1124
  * @returns Domain[]|Undefined
1078
1125
  */
1079
- getDomains: getDomains(join11(path)),
1126
+ getDomains: getDomains(join12(path2)),
1080
1127
  /**
1081
1128
  * Moves a given domain id to the version directory
1082
1129
  * @param directory
1083
1130
  */
1084
- versionDomain: versionDomain(join11(path, "domains")),
1131
+ versionDomain: versionDomain(join12(path2, "domains")),
1085
1132
  /**
1086
1133
  * Remove a domain from EventCatalog (modeled on the standard POSIX rm utility)
1087
1134
  *
1088
1135
  * @param path - The path to your domain, e.g. `/Payment`
1089
1136
  *
1090
1137
  */
1091
- rmDomain: rmDomain(join11(path, "domains")),
1138
+ rmDomain: rmDomain(join12(path2, "domains")),
1092
1139
  /**
1093
1140
  * Remove an service by an domain id
1094
1141
  *
1095
1142
  * @param id - The id of the domain you want to remove
1096
1143
  *
1097
1144
  */
1098
- rmDomainById: rmDomainById(join11(path, "domains")),
1145
+ rmDomainById: rmDomainById(join12(path2, "domains")),
1099
1146
  /**
1100
1147
  * Adds a file to the given domain
1101
1148
  * @param id - The id of the domain to add the file to
@@ -1103,14 +1150,14 @@ var index_default = (path) => {
1103
1150
  * @param version - Optional version of the domain to add the file to
1104
1151
  * @returns
1105
1152
  */
1106
- addFileToDomain: addFileToDomain(join11(path, "domains")),
1153
+ addFileToDomain: addFileToDomain(join12(path2, "domains")),
1107
1154
  /**
1108
1155
  * Check to see if a domain version exists
1109
1156
  * @param id - The id of the domain
1110
1157
  * @param version - The version of the domain (supports semver)
1111
1158
  * @returns
1112
1159
  */
1113
- domainHasVersion: domainHasVersion(join11(path)),
1160
+ domainHasVersion: domainHasVersion(join12(path2)),
1114
1161
  /**
1115
1162
  * Adds a given service to a domain
1116
1163
  * @param id - The id of the domain
@@ -1118,7 +1165,7 @@ var index_default = (path) => {
1118
1165
  * @param version - (Optional) The version of the domain to add the service to
1119
1166
  * @returns
1120
1167
  */
1121
- addServiceToDomain: addServiceToDomain(join11(path, "domains")),
1168
+ addServiceToDomain: addServiceToDomain(join12(path2, "domains")),
1122
1169
  /**
1123
1170
  * ================================
1124
1171
  * Teams
@@ -1131,25 +1178,25 @@ var index_default = (path) => {
1131
1178
  * @param options - Optional options to write the team
1132
1179
  *
1133
1180
  */
1134
- writeTeam: writeTeam(join11(path, "teams")),
1181
+ writeTeam: writeTeam(join12(path2, "teams")),
1135
1182
  /**
1136
1183
  * Returns a team from EventCatalog
1137
1184
  * @param id - The id of the team to retrieve
1138
1185
  * @returns Team|Undefined
1139
1186
  */
1140
- getTeam: getTeam(join11(path, "teams")),
1187
+ getTeam: getTeam(join12(path2, "teams")),
1141
1188
  /**
1142
1189
  * Returns all teams from EventCatalog
1143
1190
  * @returns Team[]|Undefined
1144
1191
  */
1145
- getTeams: getTeams(join11(path)),
1192
+ getTeams: getTeams(join12(path2)),
1146
1193
  /**
1147
1194
  * Remove a team by the team id
1148
1195
  *
1149
1196
  * @param id - The id of the team you want to remove
1150
1197
  *
1151
1198
  */
1152
- rmTeamById: rmTeamById(join11(path, "teams")),
1199
+ rmTeamById: rmTeamById(join12(path2, "teams")),
1153
1200
  /**
1154
1201
  * ================================
1155
1202
  * Users
@@ -1162,25 +1209,55 @@ var index_default = (path) => {
1162
1209
  * @param options - Optional options to write the user
1163
1210
  *
1164
1211
  */
1165
- writeUser: writeUser(join11(path, "users")),
1212
+ writeUser: writeUser(join12(path2, "users")),
1166
1213
  /**
1167
1214
  * Returns a user from EventCatalog
1168
1215
  * @param id - The id of the user to retrieve
1169
1216
  * @returns User|Undefined
1170
1217
  */
1171
- getUser: getUser(join11(path, "users")),
1218
+ getUser: getUser(join12(path2, "users")),
1172
1219
  /**
1173
1220
  * Returns all user from EventCatalog
1174
1221
  * @returns User[]|Undefined
1175
1222
  */
1176
- getUsers: getUsers(join11(path)),
1223
+ getUsers: getUsers(join12(path2)),
1177
1224
  /**
1178
1225
  * Remove a user by the user id
1179
1226
  *
1180
1227
  * @param id - The id of the user you want to remove
1181
1228
  *
1182
1229
  */
1183
- rmUserById: rmUserById(join11(path, "users"))
1230
+ rmUserById: rmUserById(join12(path2, "users")),
1231
+ /**
1232
+ * ================================
1233
+ * Custom Docs
1234
+ * ================================
1235
+ */
1236
+ /**
1237
+ * Returns a custom doc from EventCatalog
1238
+ * @param path - The path to the custom doc to retrieve
1239
+ * @returns CustomDoc|Undefined
1240
+ */
1241
+ getCustomDoc: getCustomDoc(join12(path2, "docs")),
1242
+ /**
1243
+ * Returns all custom docs from EventCatalog
1244
+ * @param options - Optional options to get custom docs from a specific path
1245
+ * @returns CustomDoc[]|Undefined
1246
+ */
1247
+ getCustomDocs: getCustomDocs(join12(path2, "docs")),
1248
+ /**
1249
+ * Writes a custom doc to EventCatalog
1250
+ * @param customDoc - The custom doc to write
1251
+ * @param options - Optional options to write the custom doc
1252
+ *
1253
+ */
1254
+ writeCustomDoc: writeCustomDoc(join12(path2, "docs")),
1255
+ /**
1256
+ * Removes a custom doc from EventCatalog
1257
+ * @param path - The path to the custom doc to remove
1258
+ *
1259
+ */
1260
+ rmCustomDoc: rmCustomDoc(join12(path2, "docs"))
1184
1261
  };
1185
1262
  };
1186
1263
  export {