@eventcatalog/sdk 2.4.0 → 2.5.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/eventcatalog.js.map +1 -1
- package/dist/eventcatalog.mjs.map +1 -1
- package/dist/index.d.mts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +100 -100
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +102 -102
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.d.mts +11 -2
- package/dist/types.d.d.ts +11 -2
- package/dist/types.d.js.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -631,101 +631,14 @@ var addMessageToChannel = (directory, collection) => async (id, _message, versio
|
|
|
631
631
|
await writeMessage(pathToResource)(message, { format: extension === ".md" ? "md" : "mdx" });
|
|
632
632
|
};
|
|
633
633
|
|
|
634
|
-
// src/eventcatalog.ts
|
|
635
|
-
import fs8 from "fs";
|
|
636
|
-
import path2, { join as join9 } from "path";
|
|
637
|
-
var DUMP_VERSION = "0.0.1";
|
|
638
|
-
var getEventCatalogVersion = async (catalogDir) => {
|
|
639
|
-
try {
|
|
640
|
-
const packageJson = fs8.readFileSync(join9(catalogDir, "package.json"), "utf8");
|
|
641
|
-
const packageJsonObject = JSON.parse(packageJson);
|
|
642
|
-
return packageJsonObject["dependencies"]["@eventcatalog/core"];
|
|
643
|
-
} catch (error) {
|
|
644
|
-
return "unknown";
|
|
645
|
-
}
|
|
646
|
-
};
|
|
647
|
-
var hydrateResource = async (catalogDir, resources, { attachSchema = false } = {}) => {
|
|
648
|
-
return await Promise.all(
|
|
649
|
-
resources.map(async (resource) => {
|
|
650
|
-
const resourcePath = await getResourcePath(catalogDir, resource.id, resource.version);
|
|
651
|
-
let schema = "";
|
|
652
|
-
if (resource.schemaPath && resourcePath?.fullPath) {
|
|
653
|
-
const pathToSchema = path2.join(path2.dirname(resourcePath?.fullPath), resource.schemaPath);
|
|
654
|
-
if (fs8.existsSync(pathToSchema)) {
|
|
655
|
-
schema = fs8.readFileSync(pathToSchema, "utf8");
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
const eventcatalog = schema ? { directory: resourcePath?.directory, schema } : { directory: resourcePath?.directory };
|
|
659
|
-
return {
|
|
660
|
-
...resource,
|
|
661
|
-
_eventcatalog: eventcatalog
|
|
662
|
-
};
|
|
663
|
-
})
|
|
664
|
-
);
|
|
665
|
-
};
|
|
666
|
-
var filterCollection = (collection, options) => {
|
|
667
|
-
return collection.map((item) => ({
|
|
668
|
-
...item,
|
|
669
|
-
markdown: options?.includeMarkdown ? item.markdown : void 0
|
|
670
|
-
}));
|
|
671
|
-
};
|
|
672
|
-
var dumpCatalog = (directory) => async (options) => {
|
|
673
|
-
const { getDomains: getDomains2, getServices: getServices2, getEvents: getEvents2, getQueries: getQueries2, getCommands: getCommands2, getChannels: getChannels2, getTeams: getTeams2, getUsers: getUsers2 } = index_default(directory);
|
|
674
|
-
const { includeMarkdown = true } = options || {};
|
|
675
|
-
const domains = await getDomains2();
|
|
676
|
-
const services = await getServices2();
|
|
677
|
-
const events = await getEvents2();
|
|
678
|
-
const commands = await getCommands2();
|
|
679
|
-
const queries = await getQueries2();
|
|
680
|
-
const teams = await getTeams2();
|
|
681
|
-
const users = await getUsers2();
|
|
682
|
-
const channels = await getChannels2();
|
|
683
|
-
const [
|
|
684
|
-
hydratedDomains,
|
|
685
|
-
hydratedServices,
|
|
686
|
-
hydratedEvents,
|
|
687
|
-
hydratedQueries,
|
|
688
|
-
hydratedCommands,
|
|
689
|
-
hydratedTeams,
|
|
690
|
-
hydratedUsers,
|
|
691
|
-
hydratedChannels
|
|
692
|
-
] = await Promise.all([
|
|
693
|
-
hydrateResource(directory, domains),
|
|
694
|
-
hydrateResource(directory, services),
|
|
695
|
-
hydrateResource(directory, events),
|
|
696
|
-
hydrateResource(directory, queries),
|
|
697
|
-
hydrateResource(directory, commands),
|
|
698
|
-
hydrateResource(directory, teams),
|
|
699
|
-
hydrateResource(directory, users),
|
|
700
|
-
hydrateResource(directory, channels)
|
|
701
|
-
]);
|
|
702
|
-
return {
|
|
703
|
-
version: DUMP_VERSION,
|
|
704
|
-
catalogVersion: await getEventCatalogVersion(directory),
|
|
705
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
706
|
-
resources: {
|
|
707
|
-
domains: filterCollection(hydratedDomains, { includeMarkdown }),
|
|
708
|
-
services: filterCollection(hydratedServices, { includeMarkdown }),
|
|
709
|
-
messages: {
|
|
710
|
-
events: filterCollection(hydratedEvents, { includeMarkdown }),
|
|
711
|
-
queries: filterCollection(hydratedQueries, { includeMarkdown }),
|
|
712
|
-
commands: filterCollection(hydratedCommands, { includeMarkdown })
|
|
713
|
-
},
|
|
714
|
-
teams: filterCollection(hydratedTeams, { includeMarkdown }),
|
|
715
|
-
users: filterCollection(hydratedUsers, { includeMarkdown }),
|
|
716
|
-
channels: filterCollection(hydratedChannels, { includeMarkdown })
|
|
717
|
-
}
|
|
718
|
-
};
|
|
719
|
-
};
|
|
720
|
-
|
|
721
634
|
// src/custom-docs.ts
|
|
722
|
-
import
|
|
635
|
+
import path2, { join as join9 } from "path";
|
|
723
636
|
import fsSync4 from "fs";
|
|
724
|
-
import
|
|
637
|
+
import fs8 from "fs/promises";
|
|
725
638
|
import matter4 from "gray-matter";
|
|
726
639
|
import slugify from "slugify";
|
|
727
640
|
var getCustomDoc = (directory) => async (filePath) => {
|
|
728
|
-
const fullPath =
|
|
641
|
+
const fullPath = path2.join(directory, filePath);
|
|
729
642
|
const fullPathWithExtension = fullPath.endsWith(".mdx") ? fullPath : `${fullPath}.mdx`;
|
|
730
643
|
const fileExists = fsSync4.existsSync(fullPathWithExtension);
|
|
731
644
|
if (!fileExists) {
|
|
@@ -744,20 +657,20 @@ var writeCustomDoc = (directory) => async (customDoc, options = { path: "" }) =>
|
|
|
744
657
|
const { fileName, ...rest } = customDoc;
|
|
745
658
|
const name = fileName || slugify(customDoc.title, { lower: true });
|
|
746
659
|
const withExtension = name.endsWith(".mdx") ? name : `${name}.mdx`;
|
|
747
|
-
const fullPath =
|
|
748
|
-
fsSync4.mkdirSync(
|
|
660
|
+
const fullPath = path2.join(directory, options.path || "", withExtension);
|
|
661
|
+
fsSync4.mkdirSync(path2.dirname(fullPath), { recursive: true });
|
|
749
662
|
const document = matter4.stringify(customDoc.markdown.trim(), rest);
|
|
750
663
|
fsSync4.writeFileSync(fullPath, document);
|
|
751
664
|
};
|
|
752
665
|
var rmCustomDoc = (directory) => async (filePath) => {
|
|
753
666
|
const withExtension = filePath.endsWith(".mdx") ? filePath : `${filePath}.mdx`;
|
|
754
|
-
await
|
|
667
|
+
await fs8.rm(join9(directory, withExtension), { recursive: true });
|
|
755
668
|
};
|
|
756
669
|
|
|
757
670
|
// src/teams.ts
|
|
758
|
-
import
|
|
671
|
+
import fs9 from "fs/promises";
|
|
759
672
|
import fsSync5 from "fs";
|
|
760
|
-
import { join as
|
|
673
|
+
import { join as join10 } from "path";
|
|
761
674
|
import matter5 from "gray-matter";
|
|
762
675
|
var getTeam = (catalogDir) => async (id) => {
|
|
763
676
|
const files = await getFiles(`${catalogDir}/${id}.{md,mdx}`);
|
|
@@ -793,16 +706,16 @@ var writeTeam = (catalogDir) => async (team, options = {}) => {
|
|
|
793
706
|
}
|
|
794
707
|
const { markdown, ...frontmatter } = resource;
|
|
795
708
|
const document = matter5.stringify(markdown, frontmatter);
|
|
796
|
-
fsSync5.mkdirSync(
|
|
797
|
-
fsSync5.writeFileSync(
|
|
709
|
+
fsSync5.mkdirSync(join10(catalogDir, ""), { recursive: true });
|
|
710
|
+
fsSync5.writeFileSync(join10(catalogDir, "", `${resource.id}.mdx`), document);
|
|
798
711
|
};
|
|
799
712
|
var rmTeamById = (catalogDir) => async (id) => {
|
|
800
|
-
await
|
|
713
|
+
await fs9.rm(join10(catalogDir, `${id}.mdx`), { recursive: true });
|
|
801
714
|
};
|
|
802
715
|
|
|
803
716
|
// src/users.ts
|
|
804
717
|
import fsSync6 from "fs";
|
|
805
|
-
import { join as
|
|
718
|
+
import { join as join11 } from "path";
|
|
806
719
|
import matter6 from "gray-matter";
|
|
807
720
|
var getUser = (catalogDir) => async (id) => {
|
|
808
721
|
const files = await getFiles(`${catalogDir}/${id}.{md,mdx}`);
|
|
@@ -840,11 +753,98 @@ var writeUser = (catalogDir) => async (user, options = {}) => {
|
|
|
840
753
|
}
|
|
841
754
|
const { markdown, ...frontmatter } = resource;
|
|
842
755
|
const document = matter6.stringify(markdown, frontmatter);
|
|
843
|
-
fsSync6.mkdirSync(
|
|
844
|
-
fsSync6.writeFileSync(
|
|
756
|
+
fsSync6.mkdirSync(join11(catalogDir, ""), { recursive: true });
|
|
757
|
+
fsSync6.writeFileSync(join11(catalogDir, "", `${resource.id}.mdx`), document);
|
|
845
758
|
};
|
|
846
759
|
var rmUserById = (catalogDir) => async (id) => {
|
|
847
|
-
fsSync6.rmSync(
|
|
760
|
+
fsSync6.rmSync(join11(catalogDir, `${id}.mdx`), { recursive: true });
|
|
761
|
+
};
|
|
762
|
+
|
|
763
|
+
// src/eventcatalog.ts
|
|
764
|
+
import fs10 from "fs";
|
|
765
|
+
import path3, { join as join12 } from "path";
|
|
766
|
+
var DUMP_VERSION = "0.0.1";
|
|
767
|
+
var getEventCatalogVersion = async (catalogDir) => {
|
|
768
|
+
try {
|
|
769
|
+
const packageJson = fs10.readFileSync(join12(catalogDir, "package.json"), "utf8");
|
|
770
|
+
const packageJsonObject = JSON.parse(packageJson);
|
|
771
|
+
return packageJsonObject["dependencies"]["@eventcatalog/core"];
|
|
772
|
+
} catch (error) {
|
|
773
|
+
return "unknown";
|
|
774
|
+
}
|
|
775
|
+
};
|
|
776
|
+
var hydrateResource = async (catalogDir, resources, { attachSchema = false } = {}) => {
|
|
777
|
+
return await Promise.all(
|
|
778
|
+
resources.map(async (resource) => {
|
|
779
|
+
const resourcePath = await getResourcePath(catalogDir, resource.id, resource.version);
|
|
780
|
+
let schema = "";
|
|
781
|
+
if (resource.schemaPath && resourcePath?.fullPath) {
|
|
782
|
+
const pathToSchema = path3.join(path3.dirname(resourcePath?.fullPath), resource.schemaPath);
|
|
783
|
+
if (fs10.existsSync(pathToSchema)) {
|
|
784
|
+
schema = fs10.readFileSync(pathToSchema, "utf8");
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
const eventcatalog = schema ? { directory: resourcePath?.directory, schema } : { directory: resourcePath?.directory };
|
|
788
|
+
return {
|
|
789
|
+
...resource,
|
|
790
|
+
_eventcatalog: eventcatalog
|
|
791
|
+
};
|
|
792
|
+
})
|
|
793
|
+
);
|
|
794
|
+
};
|
|
795
|
+
var filterCollection = (collection, options) => {
|
|
796
|
+
return collection.map((item) => ({
|
|
797
|
+
...item,
|
|
798
|
+
markdown: options?.includeMarkdown ? item.markdown : void 0
|
|
799
|
+
}));
|
|
800
|
+
};
|
|
801
|
+
var dumpCatalog = (directory) => async (options) => {
|
|
802
|
+
const { getDomains: getDomains2, getServices: getServices2, getEvents: getEvents2, getQueries: getQueries2, getCommands: getCommands2, getChannels: getChannels2, getTeams: getTeams2, getUsers: getUsers2 } = index_default(directory);
|
|
803
|
+
const { includeMarkdown = true } = options || {};
|
|
804
|
+
const domains = await getDomains2();
|
|
805
|
+
const services = await getServices2();
|
|
806
|
+
const events = await getEvents2();
|
|
807
|
+
const commands = await getCommands2();
|
|
808
|
+
const queries = await getQueries2();
|
|
809
|
+
const teams = await getTeams2();
|
|
810
|
+
const users = await getUsers2();
|
|
811
|
+
const channels = await getChannels2();
|
|
812
|
+
const [
|
|
813
|
+
hydratedDomains,
|
|
814
|
+
hydratedServices,
|
|
815
|
+
hydratedEvents,
|
|
816
|
+
hydratedQueries,
|
|
817
|
+
hydratedCommands,
|
|
818
|
+
hydratedTeams,
|
|
819
|
+
hydratedUsers,
|
|
820
|
+
hydratedChannels
|
|
821
|
+
] = await Promise.all([
|
|
822
|
+
hydrateResource(directory, domains),
|
|
823
|
+
hydrateResource(directory, services),
|
|
824
|
+
hydrateResource(directory, events),
|
|
825
|
+
hydrateResource(directory, queries),
|
|
826
|
+
hydrateResource(directory, commands),
|
|
827
|
+
hydrateResource(directory, teams),
|
|
828
|
+
hydrateResource(directory, users),
|
|
829
|
+
hydrateResource(directory, channels)
|
|
830
|
+
]);
|
|
831
|
+
return {
|
|
832
|
+
version: DUMP_VERSION,
|
|
833
|
+
catalogVersion: await getEventCatalogVersion(directory),
|
|
834
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
835
|
+
resources: {
|
|
836
|
+
domains: filterCollection(hydratedDomains, { includeMarkdown }),
|
|
837
|
+
services: filterCollection(hydratedServices, { includeMarkdown }),
|
|
838
|
+
messages: {
|
|
839
|
+
events: filterCollection(hydratedEvents, { includeMarkdown }),
|
|
840
|
+
queries: filterCollection(hydratedQueries, { includeMarkdown }),
|
|
841
|
+
commands: filterCollection(hydratedCommands, { includeMarkdown })
|
|
842
|
+
},
|
|
843
|
+
teams: filterCollection(hydratedTeams, { includeMarkdown }),
|
|
844
|
+
users: filterCollection(hydratedUsers, { includeMarkdown }),
|
|
845
|
+
channels: filterCollection(hydratedChannels, { includeMarkdown })
|
|
846
|
+
}
|
|
847
|
+
};
|
|
848
848
|
};
|
|
849
849
|
|
|
850
850
|
// src/index.ts
|