@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.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EventCatalogObject } from './eventcatalog.mjs';
|
|
2
2
|
import { Event, Command, Query, Channel, Service, Domain, UbiquitousLanguageDictionary, Team, User, CustomDoc } from './types.d.mjs';
|
|
3
|
+
export { Badge, BaseSchema, ChannelPointer, Message, ResourceGroup, ResourcePointer, Specifications, UbiquitousLanguage } from './types.d.mjs';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Init the SDK for EventCatalog
|
|
@@ -249,7 +250,12 @@ declare const _default: (path: string) => {
|
|
|
249
250
|
*/
|
|
250
251
|
writeQueryToService: (query: Query, service: {
|
|
251
252
|
id: string;
|
|
252
|
-
version
|
|
253
|
+
version? /**
|
|
254
|
+
* Returns a command from EventCatalog
|
|
255
|
+
* @param id - The id of the command to retrieve
|
|
256
|
+
* @param version - Optional id of the version to get (supports semver)
|
|
257
|
+
* @returns Command|Undefined
|
|
258
|
+
*/: string;
|
|
253
259
|
}, options?: {
|
|
254
260
|
path?: string;
|
|
255
261
|
format?: "md" | "mdx";
|
|
@@ -832,4 +838,4 @@ declare const _default: (path: string) => {
|
|
|
832
838
|
} | undefined>;
|
|
833
839
|
};
|
|
834
840
|
|
|
835
|
-
export { _default as default };
|
|
841
|
+
export { Channel, Command, CustomDoc, Domain, Event, Query, Service, Team, UbiquitousLanguageDictionary, User, _default as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EventCatalogObject } from './eventcatalog.js';
|
|
2
2
|
import { Event, Command, Query, Channel, Service, Domain, UbiquitousLanguageDictionary, Team, User, CustomDoc } from './types.d.js';
|
|
3
|
+
export { Badge, BaseSchema, ChannelPointer, Message, ResourceGroup, ResourcePointer, Specifications, UbiquitousLanguage } from './types.d.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Init the SDK for EventCatalog
|
|
@@ -249,7 +250,12 @@ declare const _default: (path: string) => {
|
|
|
249
250
|
*/
|
|
250
251
|
writeQueryToService: (query: Query, service: {
|
|
251
252
|
id: string;
|
|
252
|
-
version
|
|
253
|
+
version? /**
|
|
254
|
+
* Returns a command from EventCatalog
|
|
255
|
+
* @param id - The id of the command to retrieve
|
|
256
|
+
* @param version - Optional id of the version to get (supports semver)
|
|
257
|
+
* @returns Command|Undefined
|
|
258
|
+
*/: string;
|
|
253
259
|
}, options?: {
|
|
254
260
|
path?: string;
|
|
255
261
|
format?: "md" | "mdx";
|
|
@@ -832,4 +838,4 @@ declare const _default: (path: string) => {
|
|
|
832
838
|
} | undefined>;
|
|
833
839
|
};
|
|
834
840
|
|
|
835
|
-
export { _default as default };
|
|
841
|
+
export { Channel, Command, CustomDoc, Domain, Event, Query, Service, Team, UbiquitousLanguageDictionary, User, _default as default };
|
package/dist/index.js
CHANGED
|
@@ -665,101 +665,14 @@ var addMessageToChannel = (directory, collection) => async (id, _message, versio
|
|
|
665
665
|
await writeMessage(pathToResource)(message, { format: extension === ".md" ? "md" : "mdx" });
|
|
666
666
|
};
|
|
667
667
|
|
|
668
|
-
// src/eventcatalog.ts
|
|
669
|
-
var import_fs = __toESM(require("fs"));
|
|
670
|
-
var import_node_path8 = __toESM(require("path"));
|
|
671
|
-
var DUMP_VERSION = "0.0.1";
|
|
672
|
-
var getEventCatalogVersion = async (catalogDir) => {
|
|
673
|
-
try {
|
|
674
|
-
const packageJson = import_fs.default.readFileSync((0, import_node_path8.join)(catalogDir, "package.json"), "utf8");
|
|
675
|
-
const packageJsonObject = JSON.parse(packageJson);
|
|
676
|
-
return packageJsonObject["dependencies"]["@eventcatalog/core"];
|
|
677
|
-
} catch (error) {
|
|
678
|
-
return "unknown";
|
|
679
|
-
}
|
|
680
|
-
};
|
|
681
|
-
var hydrateResource = async (catalogDir, resources, { attachSchema = false } = {}) => {
|
|
682
|
-
return await Promise.all(
|
|
683
|
-
resources.map(async (resource) => {
|
|
684
|
-
const resourcePath = await getResourcePath(catalogDir, resource.id, resource.version);
|
|
685
|
-
let schema = "";
|
|
686
|
-
if (resource.schemaPath && resourcePath?.fullPath) {
|
|
687
|
-
const pathToSchema = import_node_path8.default.join(import_node_path8.default.dirname(resourcePath?.fullPath), resource.schemaPath);
|
|
688
|
-
if (import_fs.default.existsSync(pathToSchema)) {
|
|
689
|
-
schema = import_fs.default.readFileSync(pathToSchema, "utf8");
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
const eventcatalog = schema ? { directory: resourcePath?.directory, schema } : { directory: resourcePath?.directory };
|
|
693
|
-
return {
|
|
694
|
-
...resource,
|
|
695
|
-
_eventcatalog: eventcatalog
|
|
696
|
-
};
|
|
697
|
-
})
|
|
698
|
-
);
|
|
699
|
-
};
|
|
700
|
-
var filterCollection = (collection, options) => {
|
|
701
|
-
return collection.map((item) => ({
|
|
702
|
-
...item,
|
|
703
|
-
markdown: options?.includeMarkdown ? item.markdown : void 0
|
|
704
|
-
}));
|
|
705
|
-
};
|
|
706
|
-
var dumpCatalog = (directory) => async (options) => {
|
|
707
|
-
const { getDomains: getDomains2, getServices: getServices2, getEvents: getEvents2, getQueries: getQueries2, getCommands: getCommands2, getChannels: getChannels2, getTeams: getTeams2, getUsers: getUsers2 } = index_default(directory);
|
|
708
|
-
const { includeMarkdown = true } = options || {};
|
|
709
|
-
const domains = await getDomains2();
|
|
710
|
-
const services = await getServices2();
|
|
711
|
-
const events = await getEvents2();
|
|
712
|
-
const commands = await getCommands2();
|
|
713
|
-
const queries = await getQueries2();
|
|
714
|
-
const teams = await getTeams2();
|
|
715
|
-
const users = await getUsers2();
|
|
716
|
-
const channels = await getChannels2();
|
|
717
|
-
const [
|
|
718
|
-
hydratedDomains,
|
|
719
|
-
hydratedServices,
|
|
720
|
-
hydratedEvents,
|
|
721
|
-
hydratedQueries,
|
|
722
|
-
hydratedCommands,
|
|
723
|
-
hydratedTeams,
|
|
724
|
-
hydratedUsers,
|
|
725
|
-
hydratedChannels
|
|
726
|
-
] = await Promise.all([
|
|
727
|
-
hydrateResource(directory, domains),
|
|
728
|
-
hydrateResource(directory, services),
|
|
729
|
-
hydrateResource(directory, events),
|
|
730
|
-
hydrateResource(directory, queries),
|
|
731
|
-
hydrateResource(directory, commands),
|
|
732
|
-
hydrateResource(directory, teams),
|
|
733
|
-
hydrateResource(directory, users),
|
|
734
|
-
hydrateResource(directory, channels)
|
|
735
|
-
]);
|
|
736
|
-
return {
|
|
737
|
-
version: DUMP_VERSION,
|
|
738
|
-
catalogVersion: await getEventCatalogVersion(directory),
|
|
739
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
740
|
-
resources: {
|
|
741
|
-
domains: filterCollection(hydratedDomains, { includeMarkdown }),
|
|
742
|
-
services: filterCollection(hydratedServices, { includeMarkdown }),
|
|
743
|
-
messages: {
|
|
744
|
-
events: filterCollection(hydratedEvents, { includeMarkdown }),
|
|
745
|
-
queries: filterCollection(hydratedQueries, { includeMarkdown }),
|
|
746
|
-
commands: filterCollection(hydratedCommands, { includeMarkdown })
|
|
747
|
-
},
|
|
748
|
-
teams: filterCollection(hydratedTeams, { includeMarkdown }),
|
|
749
|
-
users: filterCollection(hydratedUsers, { includeMarkdown }),
|
|
750
|
-
channels: filterCollection(hydratedChannels, { includeMarkdown })
|
|
751
|
-
}
|
|
752
|
-
};
|
|
753
|
-
};
|
|
754
|
-
|
|
755
668
|
// src/custom-docs.ts
|
|
756
|
-
var
|
|
669
|
+
var import_node_path8 = __toESM(require("path"));
|
|
757
670
|
var import_node_fs4 = __toESM(require("fs"));
|
|
758
671
|
var import_promises8 = __toESM(require("fs/promises"));
|
|
759
672
|
var import_gray_matter4 = __toESM(require("gray-matter"));
|
|
760
673
|
var import_slugify = __toESM(require("slugify"));
|
|
761
674
|
var getCustomDoc = (directory) => async (filePath) => {
|
|
762
|
-
const fullPath =
|
|
675
|
+
const fullPath = import_node_path8.default.join(directory, filePath);
|
|
763
676
|
const fullPathWithExtension = fullPath.endsWith(".mdx") ? fullPath : `${fullPath}.mdx`;
|
|
764
677
|
const fileExists = import_node_fs4.default.existsSync(fullPathWithExtension);
|
|
765
678
|
if (!fileExists) {
|
|
@@ -778,20 +691,20 @@ var writeCustomDoc = (directory) => async (customDoc, options = { path: "" }) =>
|
|
|
778
691
|
const { fileName, ...rest } = customDoc;
|
|
779
692
|
const name = fileName || (0, import_slugify.default)(customDoc.title, { lower: true });
|
|
780
693
|
const withExtension = name.endsWith(".mdx") ? name : `${name}.mdx`;
|
|
781
|
-
const fullPath =
|
|
782
|
-
import_node_fs4.default.mkdirSync(
|
|
694
|
+
const fullPath = import_node_path8.default.join(directory, options.path || "", withExtension);
|
|
695
|
+
import_node_fs4.default.mkdirSync(import_node_path8.default.dirname(fullPath), { recursive: true });
|
|
783
696
|
const document = import_gray_matter4.default.stringify(customDoc.markdown.trim(), rest);
|
|
784
697
|
import_node_fs4.default.writeFileSync(fullPath, document);
|
|
785
698
|
};
|
|
786
699
|
var rmCustomDoc = (directory) => async (filePath) => {
|
|
787
700
|
const withExtension = filePath.endsWith(".mdx") ? filePath : `${filePath}.mdx`;
|
|
788
|
-
await import_promises8.default.rm((0,
|
|
701
|
+
await import_promises8.default.rm((0, import_node_path8.join)(directory, withExtension), { recursive: true });
|
|
789
702
|
};
|
|
790
703
|
|
|
791
704
|
// src/teams.ts
|
|
792
705
|
var import_promises9 = __toESM(require("fs/promises"));
|
|
793
706
|
var import_node_fs5 = __toESM(require("fs"));
|
|
794
|
-
var
|
|
707
|
+
var import_node_path9 = require("path");
|
|
795
708
|
var import_gray_matter5 = __toESM(require("gray-matter"));
|
|
796
709
|
var getTeam = (catalogDir) => async (id) => {
|
|
797
710
|
const files = await getFiles(`${catalogDir}/${id}.{md,mdx}`);
|
|
@@ -827,16 +740,16 @@ var writeTeam = (catalogDir) => async (team, options = {}) => {
|
|
|
827
740
|
}
|
|
828
741
|
const { markdown, ...frontmatter } = resource;
|
|
829
742
|
const document = import_gray_matter5.default.stringify(markdown, frontmatter);
|
|
830
|
-
import_node_fs5.default.mkdirSync((0,
|
|
831
|
-
import_node_fs5.default.writeFileSync((0,
|
|
743
|
+
import_node_fs5.default.mkdirSync((0, import_node_path9.join)(catalogDir, ""), { recursive: true });
|
|
744
|
+
import_node_fs5.default.writeFileSync((0, import_node_path9.join)(catalogDir, "", `${resource.id}.mdx`), document);
|
|
832
745
|
};
|
|
833
746
|
var rmTeamById = (catalogDir) => async (id) => {
|
|
834
|
-
await import_promises9.default.rm((0,
|
|
747
|
+
await import_promises9.default.rm((0, import_node_path9.join)(catalogDir, `${id}.mdx`), { recursive: true });
|
|
835
748
|
};
|
|
836
749
|
|
|
837
750
|
// src/users.ts
|
|
838
751
|
var import_node_fs6 = __toESM(require("fs"));
|
|
839
|
-
var
|
|
752
|
+
var import_node_path10 = require("path");
|
|
840
753
|
var import_gray_matter6 = __toESM(require("gray-matter"));
|
|
841
754
|
var getUser = (catalogDir) => async (id) => {
|
|
842
755
|
const files = await getFiles(`${catalogDir}/${id}.{md,mdx}`);
|
|
@@ -874,11 +787,98 @@ var writeUser = (catalogDir) => async (user, options = {}) => {
|
|
|
874
787
|
}
|
|
875
788
|
const { markdown, ...frontmatter } = resource;
|
|
876
789
|
const document = import_gray_matter6.default.stringify(markdown, frontmatter);
|
|
877
|
-
import_node_fs6.default.mkdirSync((0,
|
|
878
|
-
import_node_fs6.default.writeFileSync((0,
|
|
790
|
+
import_node_fs6.default.mkdirSync((0, import_node_path10.join)(catalogDir, ""), { recursive: true });
|
|
791
|
+
import_node_fs6.default.writeFileSync((0, import_node_path10.join)(catalogDir, "", `${resource.id}.mdx`), document);
|
|
879
792
|
};
|
|
880
793
|
var rmUserById = (catalogDir) => async (id) => {
|
|
881
|
-
import_node_fs6.default.rmSync((0,
|
|
794
|
+
import_node_fs6.default.rmSync((0, import_node_path10.join)(catalogDir, `${id}.mdx`), { recursive: true });
|
|
795
|
+
};
|
|
796
|
+
|
|
797
|
+
// src/eventcatalog.ts
|
|
798
|
+
var import_fs = __toESM(require("fs"));
|
|
799
|
+
var import_node_path11 = __toESM(require("path"));
|
|
800
|
+
var DUMP_VERSION = "0.0.1";
|
|
801
|
+
var getEventCatalogVersion = async (catalogDir) => {
|
|
802
|
+
try {
|
|
803
|
+
const packageJson = import_fs.default.readFileSync((0, import_node_path11.join)(catalogDir, "package.json"), "utf8");
|
|
804
|
+
const packageJsonObject = JSON.parse(packageJson);
|
|
805
|
+
return packageJsonObject["dependencies"]["@eventcatalog/core"];
|
|
806
|
+
} catch (error) {
|
|
807
|
+
return "unknown";
|
|
808
|
+
}
|
|
809
|
+
};
|
|
810
|
+
var hydrateResource = async (catalogDir, resources, { attachSchema = false } = {}) => {
|
|
811
|
+
return await Promise.all(
|
|
812
|
+
resources.map(async (resource) => {
|
|
813
|
+
const resourcePath = await getResourcePath(catalogDir, resource.id, resource.version);
|
|
814
|
+
let schema = "";
|
|
815
|
+
if (resource.schemaPath && resourcePath?.fullPath) {
|
|
816
|
+
const pathToSchema = import_node_path11.default.join(import_node_path11.default.dirname(resourcePath?.fullPath), resource.schemaPath);
|
|
817
|
+
if (import_fs.default.existsSync(pathToSchema)) {
|
|
818
|
+
schema = import_fs.default.readFileSync(pathToSchema, "utf8");
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
const eventcatalog = schema ? { directory: resourcePath?.directory, schema } : { directory: resourcePath?.directory };
|
|
822
|
+
return {
|
|
823
|
+
...resource,
|
|
824
|
+
_eventcatalog: eventcatalog
|
|
825
|
+
};
|
|
826
|
+
})
|
|
827
|
+
);
|
|
828
|
+
};
|
|
829
|
+
var filterCollection = (collection, options) => {
|
|
830
|
+
return collection.map((item) => ({
|
|
831
|
+
...item,
|
|
832
|
+
markdown: options?.includeMarkdown ? item.markdown : void 0
|
|
833
|
+
}));
|
|
834
|
+
};
|
|
835
|
+
var dumpCatalog = (directory) => async (options) => {
|
|
836
|
+
const { getDomains: getDomains2, getServices: getServices2, getEvents: getEvents2, getQueries: getQueries2, getCommands: getCommands2, getChannels: getChannels2, getTeams: getTeams2, getUsers: getUsers2 } = index_default(directory);
|
|
837
|
+
const { includeMarkdown = true } = options || {};
|
|
838
|
+
const domains = await getDomains2();
|
|
839
|
+
const services = await getServices2();
|
|
840
|
+
const events = await getEvents2();
|
|
841
|
+
const commands = await getCommands2();
|
|
842
|
+
const queries = await getQueries2();
|
|
843
|
+
const teams = await getTeams2();
|
|
844
|
+
const users = await getUsers2();
|
|
845
|
+
const channels = await getChannels2();
|
|
846
|
+
const [
|
|
847
|
+
hydratedDomains,
|
|
848
|
+
hydratedServices,
|
|
849
|
+
hydratedEvents,
|
|
850
|
+
hydratedQueries,
|
|
851
|
+
hydratedCommands,
|
|
852
|
+
hydratedTeams,
|
|
853
|
+
hydratedUsers,
|
|
854
|
+
hydratedChannels
|
|
855
|
+
] = await Promise.all([
|
|
856
|
+
hydrateResource(directory, domains),
|
|
857
|
+
hydrateResource(directory, services),
|
|
858
|
+
hydrateResource(directory, events),
|
|
859
|
+
hydrateResource(directory, queries),
|
|
860
|
+
hydrateResource(directory, commands),
|
|
861
|
+
hydrateResource(directory, teams),
|
|
862
|
+
hydrateResource(directory, users),
|
|
863
|
+
hydrateResource(directory, channels)
|
|
864
|
+
]);
|
|
865
|
+
return {
|
|
866
|
+
version: DUMP_VERSION,
|
|
867
|
+
catalogVersion: await getEventCatalogVersion(directory),
|
|
868
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
869
|
+
resources: {
|
|
870
|
+
domains: filterCollection(hydratedDomains, { includeMarkdown }),
|
|
871
|
+
services: filterCollection(hydratedServices, { includeMarkdown }),
|
|
872
|
+
messages: {
|
|
873
|
+
events: filterCollection(hydratedEvents, { includeMarkdown }),
|
|
874
|
+
queries: filterCollection(hydratedQueries, { includeMarkdown }),
|
|
875
|
+
commands: filterCollection(hydratedCommands, { includeMarkdown })
|
|
876
|
+
},
|
|
877
|
+
teams: filterCollection(hydratedTeams, { includeMarkdown }),
|
|
878
|
+
users: filterCollection(hydratedUsers, { includeMarkdown }),
|
|
879
|
+
channels: filterCollection(hydratedChannels, { includeMarkdown })
|
|
880
|
+
}
|
|
881
|
+
};
|
|
882
882
|
};
|
|
883
883
|
|
|
884
884
|
// src/index.ts
|