@eventcatalog/core 2.64.4 → 2.65.0-beta.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/analytics/analytics.cjs +1 -1
- package/dist/analytics/analytics.js +2 -2
- package/dist/analytics/log-build.cjs +1 -1
- package/dist/analytics/log-build.js +3 -3
- package/dist/{chunk-MDWC22V7.js → chunk-2ZXSFW7J.js} +1 -1
- package/dist/chunk-622JYJWG.js +109 -0
- package/dist/{chunk-KEEW2PJ4.js → chunk-6MJGAOPK.js} +1 -1
- package/dist/chunk-BH3JMNAV.js +12 -0
- package/dist/{chunk-BXXJNRMA.js → chunk-GGFP7ZBX.js} +1 -1
- package/dist/constants.cjs +1 -1
- package/dist/constants.js +1 -1
- package/dist/eventcatalog.cjs +139 -24
- package/dist/eventcatalog.js +9 -3
- package/dist/migrations/index.cjs +150 -0
- package/dist/migrations/index.d.cts +3 -0
- package/dist/migrations/index.d.ts +3 -0
- package/dist/migrations/index.js +7 -0
- package/dist/migrations/message-channels-to-service-channels.cjs +139 -0
- package/dist/migrations/message-channels-to-service-channels.d.cts +6 -0
- package/dist/migrations/message-channels-to-service-channels.d.ts +6 -0
- package/dist/migrations/message-channels-to-service-channels.js +6 -0
- package/eventcatalog/src/components/MDX/NodeGraph/Edges/AnimatedMessageEdge.tsx +42 -28
- package/eventcatalog/src/components/SideNav/ListViewSideBar/index.tsx +41 -35
- package/eventcatalog/src/content.config.ts +31 -3
- package/eventcatalog/src/enterprise/eventcatalog-chat/providers/ai-provider.ts +0 -4
- package/eventcatalog/src/hooks/eventcatalog-visualizer.ts +35 -15
- package/eventcatalog/src/utils/channels.ts +73 -1
- package/eventcatalog/src/utils/collections/util.ts +7 -0
- package/eventcatalog/src/utils/node-graphs/channel-node-graph.ts +75 -0
- package/eventcatalog/src/utils/node-graphs/message-node-graph.ts +856 -61
- package/eventcatalog/src/utils/node-graphs/services-node-graph.ts +46 -70
- package/eventcatalog/src/utils/node-graphs/utils/utils.ts +26 -80
- package/package.json +2 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
log_build_default
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-GGFP7ZBX.js";
|
|
4
|
+
import "../chunk-2ZXSFW7J.js";
|
|
5
|
+
import "../chunk-6MJGAOPK.js";
|
|
6
6
|
import "../chunk-UPONRQSN.js";
|
|
7
7
|
export {
|
|
8
8
|
log_build_default as default
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// src/migrations/message-channels-to-service-channels.ts
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import { glob } from "glob";
|
|
4
|
+
import os from "os";
|
|
5
|
+
import matter from "gray-matter";
|
|
6
|
+
import path from "path";
|
|
7
|
+
var message_channels_to_service_channels_default = async (dir) => {
|
|
8
|
+
const PROJECT_DIR = path.join(dir || process.env.PROJECT_DIR);
|
|
9
|
+
const messages = await glob(
|
|
10
|
+
[
|
|
11
|
+
"**/events/*/index.mdx",
|
|
12
|
+
"**/events/*/index.md",
|
|
13
|
+
"**/events/*/versioned/*/index.mdx",
|
|
14
|
+
"**/events/*/versioned/*/index.md",
|
|
15
|
+
// commands
|
|
16
|
+
"**/commands/*/index.mdx",
|
|
17
|
+
"**/commands/*/index.md",
|
|
18
|
+
"**/commands/*/versioned/*/index.mdx",
|
|
19
|
+
"**/commands/*/versioned/*/index.md",
|
|
20
|
+
// queries
|
|
21
|
+
"**/queries/*/index.mdx",
|
|
22
|
+
"**/queries/*/index.md",
|
|
23
|
+
"**/queries/*/versioned/*/index.mdx",
|
|
24
|
+
"**/queries/*/versioned/*/index.md"
|
|
25
|
+
],
|
|
26
|
+
{
|
|
27
|
+
// const events = await glob(['**/events/*/index.(md|mdx)', '**/events/*/versioned/*/index.(md|mdx)'], {
|
|
28
|
+
cwd: PROJECT_DIR,
|
|
29
|
+
absolute: true,
|
|
30
|
+
nodir: true,
|
|
31
|
+
windowsPathsNoEscape: os.platform() == "win32",
|
|
32
|
+
ignore: ["node_modules/**", "**/dist/**", "**/teams", "**/users", "**/package.json", "**/Dockerfile"]
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
const services = await glob(
|
|
36
|
+
[
|
|
37
|
+
"**/services/*/index.mdx",
|
|
38
|
+
"**/services/*/index.md",
|
|
39
|
+
"**/services/*/versioned/*/index.mdx",
|
|
40
|
+
"**/services/*/versioned/*/index.md"
|
|
41
|
+
],
|
|
42
|
+
{
|
|
43
|
+
cwd: PROJECT_DIR,
|
|
44
|
+
absolute: true
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
const messagesWithChannels = messages.reduce((acc, message) => {
|
|
48
|
+
const file = fs.readFileSync(message, "utf8");
|
|
49
|
+
const { data } = matter(file);
|
|
50
|
+
if (data.channels?.length > 0) {
|
|
51
|
+
acc.push({
|
|
52
|
+
...data,
|
|
53
|
+
path: message
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return acc;
|
|
57
|
+
}, []);
|
|
58
|
+
if (messagesWithChannels.length === 0) {
|
|
59
|
+
return { status: "success", message: "No messages with channels found in the catalog" };
|
|
60
|
+
}
|
|
61
|
+
const servicesWithChannels = services.reduce((acc, service) => {
|
|
62
|
+
const file = fs.readFileSync(service, "utf8");
|
|
63
|
+
const { data } = matter(file);
|
|
64
|
+
const isSending = data.sends?.some((send) => messagesWithChannels.some((message) => message.id === send.id));
|
|
65
|
+
const isReceiving = data.receives?.some(
|
|
66
|
+
(receive) => messagesWithChannels.some((message) => message.id === receive.id)
|
|
67
|
+
);
|
|
68
|
+
if (isSending || isReceiving) {
|
|
69
|
+
acc.push({
|
|
70
|
+
...data,
|
|
71
|
+
path: service
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return acc;
|
|
75
|
+
}, []);
|
|
76
|
+
for (const service of servicesWithChannels) {
|
|
77
|
+
const file = fs.readFileSync(service.path, "utf8");
|
|
78
|
+
const { data } = matter(file);
|
|
79
|
+
const messagesTheServiceSendsThatNeedUpdating = data.sends?.filter((send) => messagesWithChannels.some((message) => message.id === send.id)) ?? [];
|
|
80
|
+
const messagesTheServiceReceivesThatNeedUpdating = data.receives?.filter((receive) => messagesWithChannels.some((message) => message.id === receive.id)) ?? [];
|
|
81
|
+
if (messagesTheServiceSendsThatNeedUpdating.length > 0 || messagesTheServiceReceivesThatNeedUpdating.length > 0) {
|
|
82
|
+
const newSends = messagesTheServiceSendsThatNeedUpdating.map((send) => ({
|
|
83
|
+
...send,
|
|
84
|
+
to: messagesWithChannels.map((message) => message.id === send.id ? message.channels : []).flat().filter((channel) => channel !== null)
|
|
85
|
+
}));
|
|
86
|
+
const newReceives = messagesTheServiceReceivesThatNeedUpdating.map((receive) => ({
|
|
87
|
+
...receive,
|
|
88
|
+
from: messagesWithChannels.map((message) => message.id === receive.id ? message.channels : []).flat().filter((channel) => channel !== null)
|
|
89
|
+
}));
|
|
90
|
+
const newData = {
|
|
91
|
+
...data,
|
|
92
|
+
...newSends.length > 0 ? { sends: newSends } : {},
|
|
93
|
+
...newReceives.length > 0 ? { receives: newReceives } : {}
|
|
94
|
+
};
|
|
95
|
+
fs.writeFileSync(service.path, matter.stringify(file, newData));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
for (const message of messagesWithChannels) {
|
|
99
|
+
const file = fs.readFileSync(message.path, "utf8");
|
|
100
|
+
const parsed = matter(file);
|
|
101
|
+
const { channels, ...newData } = parsed.data;
|
|
102
|
+
fs.writeFileSync(message.path, matter.stringify(parsed.content, newData));
|
|
103
|
+
}
|
|
104
|
+
console.log("\u2714 Channels migrated to new services API");
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export {
|
|
108
|
+
message_channels_to_service_channels_default
|
|
109
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
message_channels_to_service_channels_default
|
|
3
|
+
} from "./chunk-622JYJWG.js";
|
|
4
|
+
|
|
5
|
+
// src/migrations/index.ts
|
|
6
|
+
var runMigrations = async (dir) => {
|
|
7
|
+
await message_channels_to_service_channels_default(dir);
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
runMigrations
|
|
12
|
+
};
|
package/dist/constants.cjs
CHANGED
package/dist/constants.js
CHANGED
package/dist/eventcatalog.cjs
CHANGED
|
@@ -29,9 +29,9 @@ var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
|
29
29
|
// src/eventcatalog.ts
|
|
30
30
|
var import_commander = require("commander");
|
|
31
31
|
var import_node_child_process = require("child_process");
|
|
32
|
-
var
|
|
32
|
+
var import_node_path7 = require("path");
|
|
33
33
|
var import_fs2 = __toESM(require("fs"), 1);
|
|
34
|
-
var
|
|
34
|
+
var import_node_path8 = __toESM(require("path"), 1);
|
|
35
35
|
var import_node_url = require("url");
|
|
36
36
|
var import_concurrently = __toESM(require("concurrently"), 1);
|
|
37
37
|
|
|
@@ -157,7 +157,7 @@ var import_axios = __toESM(require("axios"), 1);
|
|
|
157
157
|
var import_os = __toESM(require("os"), 1);
|
|
158
158
|
|
|
159
159
|
// package.json
|
|
160
|
-
var version = "2.
|
|
160
|
+
var version = "2.65.0-beta.0";
|
|
161
161
|
|
|
162
162
|
// src/constants.ts
|
|
163
163
|
var VERSION = version;
|
|
@@ -522,15 +522,128 @@ var isAuthEnabled = async () => {
|
|
|
522
522
|
// src/eventcatalog.ts
|
|
523
523
|
var import_update_notifier = __toESM(require("update-notifier"), 1);
|
|
524
524
|
var import_dotenv = __toESM(require("dotenv"), 1);
|
|
525
|
+
|
|
526
|
+
// src/migrations/message-channels-to-service-channels.ts
|
|
527
|
+
var import_node_fs5 = __toESM(require("fs"), 1);
|
|
528
|
+
var import_glob2 = require("glob");
|
|
529
|
+
var import_node_os2 = __toESM(require("os"), 1);
|
|
530
|
+
var import_gray_matter3 = __toESM(require("gray-matter"), 1);
|
|
531
|
+
var import_node_path6 = __toESM(require("path"), 1);
|
|
532
|
+
var message_channels_to_service_channels_default = async (dir2) => {
|
|
533
|
+
const PROJECT_DIR = import_node_path6.default.join(dir2 || process.env.PROJECT_DIR);
|
|
534
|
+
const messages = await (0, import_glob2.glob)(
|
|
535
|
+
[
|
|
536
|
+
"**/events/*/index.mdx",
|
|
537
|
+
"**/events/*/index.md",
|
|
538
|
+
"**/events/*/versioned/*/index.mdx",
|
|
539
|
+
"**/events/*/versioned/*/index.md",
|
|
540
|
+
// commands
|
|
541
|
+
"**/commands/*/index.mdx",
|
|
542
|
+
"**/commands/*/index.md",
|
|
543
|
+
"**/commands/*/versioned/*/index.mdx",
|
|
544
|
+
"**/commands/*/versioned/*/index.md",
|
|
545
|
+
// queries
|
|
546
|
+
"**/queries/*/index.mdx",
|
|
547
|
+
"**/queries/*/index.md",
|
|
548
|
+
"**/queries/*/versioned/*/index.mdx",
|
|
549
|
+
"**/queries/*/versioned/*/index.md"
|
|
550
|
+
],
|
|
551
|
+
{
|
|
552
|
+
// const events = await glob(['**/events/*/index.(md|mdx)', '**/events/*/versioned/*/index.(md|mdx)'], {
|
|
553
|
+
cwd: PROJECT_DIR,
|
|
554
|
+
absolute: true,
|
|
555
|
+
nodir: true,
|
|
556
|
+
windowsPathsNoEscape: import_node_os2.default.platform() == "win32",
|
|
557
|
+
ignore: ["node_modules/**", "**/dist/**", "**/teams", "**/users", "**/package.json", "**/Dockerfile"]
|
|
558
|
+
}
|
|
559
|
+
);
|
|
560
|
+
const services = await (0, import_glob2.glob)(
|
|
561
|
+
[
|
|
562
|
+
"**/services/*/index.mdx",
|
|
563
|
+
"**/services/*/index.md",
|
|
564
|
+
"**/services/*/versioned/*/index.mdx",
|
|
565
|
+
"**/services/*/versioned/*/index.md"
|
|
566
|
+
],
|
|
567
|
+
{
|
|
568
|
+
cwd: PROJECT_DIR,
|
|
569
|
+
absolute: true
|
|
570
|
+
}
|
|
571
|
+
);
|
|
572
|
+
const messagesWithChannels = messages.reduce((acc, message) => {
|
|
573
|
+
const file = import_node_fs5.default.readFileSync(message, "utf8");
|
|
574
|
+
const { data } = (0, import_gray_matter3.default)(file);
|
|
575
|
+
if (data.channels?.length > 0) {
|
|
576
|
+
acc.push({
|
|
577
|
+
...data,
|
|
578
|
+
path: message
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
return acc;
|
|
582
|
+
}, []);
|
|
583
|
+
if (messagesWithChannels.length === 0) {
|
|
584
|
+
return { status: "success", message: "No messages with channels found in the catalog" };
|
|
585
|
+
}
|
|
586
|
+
const servicesWithChannels = services.reduce((acc, service) => {
|
|
587
|
+
const file = import_node_fs5.default.readFileSync(service, "utf8");
|
|
588
|
+
const { data } = (0, import_gray_matter3.default)(file);
|
|
589
|
+
const isSending = data.sends?.some((send) => messagesWithChannels.some((message) => message.id === send.id));
|
|
590
|
+
const isReceiving = data.receives?.some(
|
|
591
|
+
(receive) => messagesWithChannels.some((message) => message.id === receive.id)
|
|
592
|
+
);
|
|
593
|
+
if (isSending || isReceiving) {
|
|
594
|
+
acc.push({
|
|
595
|
+
...data,
|
|
596
|
+
path: service
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
return acc;
|
|
600
|
+
}, []);
|
|
601
|
+
for (const service of servicesWithChannels) {
|
|
602
|
+
const file = import_node_fs5.default.readFileSync(service.path, "utf8");
|
|
603
|
+
const { data } = (0, import_gray_matter3.default)(file);
|
|
604
|
+
const messagesTheServiceSendsThatNeedUpdating = data.sends?.filter((send) => messagesWithChannels.some((message) => message.id === send.id)) ?? [];
|
|
605
|
+
const messagesTheServiceReceivesThatNeedUpdating = data.receives?.filter((receive) => messagesWithChannels.some((message) => message.id === receive.id)) ?? [];
|
|
606
|
+
if (messagesTheServiceSendsThatNeedUpdating.length > 0 || messagesTheServiceReceivesThatNeedUpdating.length > 0) {
|
|
607
|
+
const newSends = messagesTheServiceSendsThatNeedUpdating.map((send) => ({
|
|
608
|
+
...send,
|
|
609
|
+
to: messagesWithChannels.map((message) => message.id === send.id ? message.channels : []).flat().filter((channel) => channel !== null)
|
|
610
|
+
}));
|
|
611
|
+
const newReceives = messagesTheServiceReceivesThatNeedUpdating.map((receive) => ({
|
|
612
|
+
...receive,
|
|
613
|
+
from: messagesWithChannels.map((message) => message.id === receive.id ? message.channels : []).flat().filter((channel) => channel !== null)
|
|
614
|
+
}));
|
|
615
|
+
const newData = {
|
|
616
|
+
...data,
|
|
617
|
+
...newSends.length > 0 ? { sends: newSends } : {},
|
|
618
|
+
...newReceives.length > 0 ? { receives: newReceives } : {}
|
|
619
|
+
};
|
|
620
|
+
import_node_fs5.default.writeFileSync(service.path, import_gray_matter3.default.stringify(file, newData));
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
for (const message of messagesWithChannels) {
|
|
624
|
+
const file = import_node_fs5.default.readFileSync(message.path, "utf8");
|
|
625
|
+
const parsed = (0, import_gray_matter3.default)(file);
|
|
626
|
+
const { channels, ...newData } = parsed.data;
|
|
627
|
+
import_node_fs5.default.writeFileSync(message.path, import_gray_matter3.default.stringify(parsed.content, newData));
|
|
628
|
+
}
|
|
629
|
+
console.log("\u2714 Channels migrated to new services API");
|
|
630
|
+
};
|
|
631
|
+
|
|
632
|
+
// src/migrations/index.ts
|
|
633
|
+
var runMigrations = async (dir2) => {
|
|
634
|
+
await message_channels_to_service_channels_default(dir2);
|
|
635
|
+
};
|
|
636
|
+
|
|
637
|
+
// src/eventcatalog.ts
|
|
525
638
|
var import_license = require("@eventcatalog/license");
|
|
526
|
-
var currentDir =
|
|
639
|
+
var currentDir = import_node_path8.default.dirname((0, import_node_url.fileURLToPath)(importMetaUrl));
|
|
527
640
|
var program = new import_commander.Command().version(VERSION);
|
|
528
|
-
var dir =
|
|
529
|
-
var core =
|
|
530
|
-
var eventCatalogDir =
|
|
641
|
+
var dir = import_node_path8.default.resolve(process.env.PROJECT_DIR || process.cwd());
|
|
642
|
+
var core = import_node_path8.default.resolve(process.env.CATALOG_DIR || (0, import_node_path7.join)(dir, ".eventcatalog-core"));
|
|
643
|
+
var eventCatalogDir = import_node_path8.default.resolve((0, import_node_path7.join)(currentDir, "../eventcatalog/"));
|
|
531
644
|
var getInstalledEventCatalogVersion = () => {
|
|
532
645
|
try {
|
|
533
|
-
const pkg = import_fs2.default.readFileSync((0,
|
|
646
|
+
const pkg = import_fs2.default.readFileSync((0, import_node_path7.join)(dir, "package.json"), "utf8");
|
|
534
647
|
const json = JSON.parse(pkg);
|
|
535
648
|
return json.dependencies["@eventcatalog/core"];
|
|
536
649
|
} catch (error) {
|
|
@@ -557,13 +670,13 @@ var copyCore = () => {
|
|
|
557
670
|
};
|
|
558
671
|
var copyServerFiles = async () => {
|
|
559
672
|
const isServerOutput = await isOutputServer();
|
|
560
|
-
if (import_fs2.default.existsSync((0,
|
|
561
|
-
import_fs2.default.rmSync((0,
|
|
673
|
+
if (import_fs2.default.existsSync((0, import_node_path7.join)(core, "src/pages/api/server"))) {
|
|
674
|
+
import_fs2.default.rmSync((0, import_node_path7.join)(core, "src/pages/api/server"), { recursive: true });
|
|
562
675
|
}
|
|
563
676
|
if (!isServerOutput) {
|
|
564
677
|
return;
|
|
565
678
|
}
|
|
566
|
-
import_fs2.default.cpSync((0,
|
|
679
|
+
import_fs2.default.cpSync((0, import_node_path7.join)(eventCatalogDir, "src/enterprise/eventcatalog-chat/pages/api"), (0, import_node_path7.join)(core, "src/pages/api"), {
|
|
567
680
|
recursive: true
|
|
568
681
|
});
|
|
569
682
|
};
|
|
@@ -574,7 +687,7 @@ var createAuthFileIfNotExists = async (hasRequiredLicense) => {
|
|
|
574
687
|
if (authEnabled && hasRequiredLicense && isSRR) {
|
|
575
688
|
console.log("Creating auth file");
|
|
576
689
|
import_fs2.default.writeFileSync(
|
|
577
|
-
(0,
|
|
690
|
+
(0, import_node_path7.join)(core, "src/pages/api/[...auth].ts"),
|
|
578
691
|
`import { AstroAuth } from 'auth-astro/server';
|
|
579
692
|
export const prerender = false;
|
|
580
693
|
export const { GET, POST } = AstroAuth();
|
|
@@ -617,8 +730,8 @@ Run npm i @eventcatalog/core to update`;
|
|
|
617
730
|
};
|
|
618
731
|
program.command("dev").description("Run development server of EventCatalog").option("-d, --debug", "Output EventCatalog application information into your terminal").option("--force-recreate", "Recreate the eventcatalog-core directory", false).action(async (options, command) => {
|
|
619
732
|
console.log("Setting up EventCatalog....");
|
|
620
|
-
if (import_fs2.default.existsSync(
|
|
621
|
-
import_dotenv.default.config({ path:
|
|
733
|
+
if (import_fs2.default.existsSync(import_node_path8.default.join(dir, ".env"))) {
|
|
734
|
+
import_dotenv.default.config({ path: import_node_path8.default.join(dir, ".env") });
|
|
622
735
|
}
|
|
623
736
|
if (options.debug) {
|
|
624
737
|
console.log("Debug mode enabled");
|
|
@@ -629,6 +742,7 @@ program.command("dev").description("Run development server of EventCatalog").opt
|
|
|
629
742
|
copyCore();
|
|
630
743
|
await resolve_catalog_dependencies_default(dir, core);
|
|
631
744
|
await checkAndConvertMdToMdx(dir, core);
|
|
745
|
+
await runMigrations(dir);
|
|
632
746
|
await catalogToAstro(dir, core);
|
|
633
747
|
await copyServerFiles();
|
|
634
748
|
const canEmbedPages = await (0, import_license.isFeatureEnabled)(
|
|
@@ -671,8 +785,8 @@ program.command("dev").description("Run development server of EventCatalog").opt
|
|
|
671
785
|
});
|
|
672
786
|
program.command("build").description("Run build of EventCatalog").action(async (options, command) => {
|
|
673
787
|
console.log("Building EventCatalog...");
|
|
674
|
-
if (import_fs2.default.existsSync(
|
|
675
|
-
import_dotenv.default.config({ path:
|
|
788
|
+
if (import_fs2.default.existsSync(import_node_path8.default.join(dir, ".env"))) {
|
|
789
|
+
import_dotenv.default.config({ path: import_node_path8.default.join(dir, ".env") });
|
|
676
790
|
}
|
|
677
791
|
copyCore();
|
|
678
792
|
await copyServerFiles();
|
|
@@ -691,6 +805,7 @@ program.command("build").description("Run build of EventCatalog").action(async (
|
|
|
691
805
|
});
|
|
692
806
|
await resolve_catalog_dependencies_default(dir, core);
|
|
693
807
|
await checkAndConvertMdToMdx(dir, core);
|
|
808
|
+
await runMigrations(dir);
|
|
694
809
|
await catalogToAstro(dir, core);
|
|
695
810
|
checkForUpdate();
|
|
696
811
|
const windowsCommand = `npx astro build ${command.args.join(" ").trim()} | findstr /V "The collection"`;
|
|
@@ -715,8 +830,8 @@ program.command("build").description("Run build of EventCatalog").action(async (
|
|
|
715
830
|
stdio: "inherit"
|
|
716
831
|
}
|
|
717
832
|
);
|
|
718
|
-
if (import_fs2.default.existsSync((0,
|
|
719
|
-
import_fs2.default.cpSync((0,
|
|
833
|
+
if (import_fs2.default.existsSync((0, import_node_path7.join)(dir, outDir, "pagefind"))) {
|
|
834
|
+
import_fs2.default.cpSync((0, import_node_path7.join)(dir, outDir, "pagefind"), (0, import_node_path7.join)(dir, "public", "pagefind"), { recursive: true });
|
|
720
835
|
}
|
|
721
836
|
}
|
|
722
837
|
});
|
|
@@ -750,8 +865,8 @@ var startServerCatalog = ({
|
|
|
750
865
|
};
|
|
751
866
|
program.command("preview").description("Serves the contents of your eventcatalog build directory").action(async (options, command) => {
|
|
752
867
|
console.log("Starting preview of your build...");
|
|
753
|
-
if (import_fs2.default.existsSync(
|
|
754
|
-
import_dotenv.default.config({ path:
|
|
868
|
+
if (import_fs2.default.existsSync(import_node_path8.default.join(dir, ".env"))) {
|
|
869
|
+
import_dotenv.default.config({ path: import_node_path8.default.join(dir, ".env") });
|
|
755
870
|
}
|
|
756
871
|
const canEmbedPages = await (0, import_license.isFeatureEnabled)(
|
|
757
872
|
"@eventcatalog/backstage-plugin-eventcatalog",
|
|
@@ -765,8 +880,8 @@ program.command("preview").description("Serves the contents of your eventcatalog
|
|
|
765
880
|
});
|
|
766
881
|
program.command("start").description("Serves the contents of your eventcatalog build directory").action(async (options, command) => {
|
|
767
882
|
console.log("Starting preview of your build...");
|
|
768
|
-
if (import_fs2.default.existsSync(
|
|
769
|
-
import_dotenv.default.config({ path:
|
|
883
|
+
if (import_fs2.default.existsSync(import_node_path8.default.join(dir, ".env"))) {
|
|
884
|
+
import_dotenv.default.config({ path: import_node_path8.default.join(dir, ".env") });
|
|
770
885
|
}
|
|
771
886
|
const canEmbedPages = await (0, import_license.isFeatureEnabled)(
|
|
772
887
|
"@eventcatalog/backstage-plugin-eventcatalog",
|
|
@@ -792,8 +907,8 @@ program.command("start").description("Serves the contents of your eventcatalog b
|
|
|
792
907
|
}
|
|
793
908
|
});
|
|
794
909
|
program.command("generate [siteDir]").description("Start the generator scripts.").action(async () => {
|
|
795
|
-
if (import_fs2.default.existsSync(
|
|
796
|
-
import_dotenv.default.config({ path:
|
|
910
|
+
if (import_fs2.default.existsSync(import_node_path8.default.join(dir, ".env"))) {
|
|
911
|
+
import_dotenv.default.config({ path: import_node_path8.default.join(dir, ".env") });
|
|
797
912
|
}
|
|
798
913
|
await generate(dir);
|
|
799
914
|
});
|
package/dist/eventcatalog.js
CHANGED
|
@@ -6,8 +6,12 @@ import {
|
|
|
6
6
|
} from "./chunk-PLNJC7NZ.js";
|
|
7
7
|
import {
|
|
8
8
|
log_build_default
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-GGFP7ZBX.js";
|
|
10
|
+
import "./chunk-2ZXSFW7J.js";
|
|
11
|
+
import {
|
|
12
|
+
runMigrations
|
|
13
|
+
} from "./chunk-BH3JMNAV.js";
|
|
14
|
+
import "./chunk-622JYJWG.js";
|
|
11
15
|
import {
|
|
12
16
|
catalogToAstro,
|
|
13
17
|
checkAndConvertMdToMdx
|
|
@@ -15,7 +19,7 @@ import {
|
|
|
15
19
|
import "./chunk-55D645EH.js";
|
|
16
20
|
import {
|
|
17
21
|
VERSION
|
|
18
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-6MJGAOPK.js";
|
|
19
23
|
import {
|
|
20
24
|
getProjectOutDir,
|
|
21
25
|
isAuthEnabled,
|
|
@@ -144,6 +148,7 @@ program.command("dev").description("Run development server of EventCatalog").opt
|
|
|
144
148
|
copyCore();
|
|
145
149
|
await resolve_catalog_dependencies_default(dir, core);
|
|
146
150
|
await checkAndConvertMdToMdx(dir, core);
|
|
151
|
+
await runMigrations(dir);
|
|
147
152
|
await catalogToAstro(dir, core);
|
|
148
153
|
await copyServerFiles();
|
|
149
154
|
const canEmbedPages = await isFeatureEnabled(
|
|
@@ -206,6 +211,7 @@ program.command("build").description("Run build of EventCatalog").action(async (
|
|
|
206
211
|
});
|
|
207
212
|
await resolve_catalog_dependencies_default(dir, core);
|
|
208
213
|
await checkAndConvertMdToMdx(dir, core);
|
|
214
|
+
await runMigrations(dir);
|
|
209
215
|
await catalogToAstro(dir, core);
|
|
210
216
|
checkForUpdate();
|
|
211
217
|
const windowsCommand = `npx astro build ${command.args.join(" ").trim()} | findstr /V "The collection"`;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/migrations/index.ts
|
|
31
|
+
var migrations_exports = {};
|
|
32
|
+
__export(migrations_exports, {
|
|
33
|
+
runMigrations: () => runMigrations
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(migrations_exports);
|
|
36
|
+
|
|
37
|
+
// src/migrations/message-channels-to-service-channels.ts
|
|
38
|
+
var import_node_fs = __toESM(require("fs"), 1);
|
|
39
|
+
var import_glob = require("glob");
|
|
40
|
+
var import_node_os = __toESM(require("os"), 1);
|
|
41
|
+
var import_gray_matter = __toESM(require("gray-matter"), 1);
|
|
42
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
43
|
+
var message_channels_to_service_channels_default = async (dir) => {
|
|
44
|
+
const PROJECT_DIR = import_node_path.default.join(dir || process.env.PROJECT_DIR);
|
|
45
|
+
const messages = await (0, import_glob.glob)(
|
|
46
|
+
[
|
|
47
|
+
"**/events/*/index.mdx",
|
|
48
|
+
"**/events/*/index.md",
|
|
49
|
+
"**/events/*/versioned/*/index.mdx",
|
|
50
|
+
"**/events/*/versioned/*/index.md",
|
|
51
|
+
// commands
|
|
52
|
+
"**/commands/*/index.mdx",
|
|
53
|
+
"**/commands/*/index.md",
|
|
54
|
+
"**/commands/*/versioned/*/index.mdx",
|
|
55
|
+
"**/commands/*/versioned/*/index.md",
|
|
56
|
+
// queries
|
|
57
|
+
"**/queries/*/index.mdx",
|
|
58
|
+
"**/queries/*/index.md",
|
|
59
|
+
"**/queries/*/versioned/*/index.mdx",
|
|
60
|
+
"**/queries/*/versioned/*/index.md"
|
|
61
|
+
],
|
|
62
|
+
{
|
|
63
|
+
// const events = await glob(['**/events/*/index.(md|mdx)', '**/events/*/versioned/*/index.(md|mdx)'], {
|
|
64
|
+
cwd: PROJECT_DIR,
|
|
65
|
+
absolute: true,
|
|
66
|
+
nodir: true,
|
|
67
|
+
windowsPathsNoEscape: import_node_os.default.platform() == "win32",
|
|
68
|
+
ignore: ["node_modules/**", "**/dist/**", "**/teams", "**/users", "**/package.json", "**/Dockerfile"]
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
const services = await (0, import_glob.glob)(
|
|
72
|
+
[
|
|
73
|
+
"**/services/*/index.mdx",
|
|
74
|
+
"**/services/*/index.md",
|
|
75
|
+
"**/services/*/versioned/*/index.mdx",
|
|
76
|
+
"**/services/*/versioned/*/index.md"
|
|
77
|
+
],
|
|
78
|
+
{
|
|
79
|
+
cwd: PROJECT_DIR,
|
|
80
|
+
absolute: true
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
const messagesWithChannels = messages.reduce((acc, message) => {
|
|
84
|
+
const file = import_node_fs.default.readFileSync(message, "utf8");
|
|
85
|
+
const { data } = (0, import_gray_matter.default)(file);
|
|
86
|
+
if (data.channels?.length > 0) {
|
|
87
|
+
acc.push({
|
|
88
|
+
...data,
|
|
89
|
+
path: message
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return acc;
|
|
93
|
+
}, []);
|
|
94
|
+
if (messagesWithChannels.length === 0) {
|
|
95
|
+
return { status: "success", message: "No messages with channels found in the catalog" };
|
|
96
|
+
}
|
|
97
|
+
const servicesWithChannels = services.reduce((acc, service) => {
|
|
98
|
+
const file = import_node_fs.default.readFileSync(service, "utf8");
|
|
99
|
+
const { data } = (0, import_gray_matter.default)(file);
|
|
100
|
+
const isSending = data.sends?.some((send) => messagesWithChannels.some((message) => message.id === send.id));
|
|
101
|
+
const isReceiving = data.receives?.some(
|
|
102
|
+
(receive) => messagesWithChannels.some((message) => message.id === receive.id)
|
|
103
|
+
);
|
|
104
|
+
if (isSending || isReceiving) {
|
|
105
|
+
acc.push({
|
|
106
|
+
...data,
|
|
107
|
+
path: service
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
return acc;
|
|
111
|
+
}, []);
|
|
112
|
+
for (const service of servicesWithChannels) {
|
|
113
|
+
const file = import_node_fs.default.readFileSync(service.path, "utf8");
|
|
114
|
+
const { data } = (0, import_gray_matter.default)(file);
|
|
115
|
+
const messagesTheServiceSendsThatNeedUpdating = data.sends?.filter((send) => messagesWithChannels.some((message) => message.id === send.id)) ?? [];
|
|
116
|
+
const messagesTheServiceReceivesThatNeedUpdating = data.receives?.filter((receive) => messagesWithChannels.some((message) => message.id === receive.id)) ?? [];
|
|
117
|
+
if (messagesTheServiceSendsThatNeedUpdating.length > 0 || messagesTheServiceReceivesThatNeedUpdating.length > 0) {
|
|
118
|
+
const newSends = messagesTheServiceSendsThatNeedUpdating.map((send) => ({
|
|
119
|
+
...send,
|
|
120
|
+
to: messagesWithChannels.map((message) => message.id === send.id ? message.channels : []).flat().filter((channel) => channel !== null)
|
|
121
|
+
}));
|
|
122
|
+
const newReceives = messagesTheServiceReceivesThatNeedUpdating.map((receive) => ({
|
|
123
|
+
...receive,
|
|
124
|
+
from: messagesWithChannels.map((message) => message.id === receive.id ? message.channels : []).flat().filter((channel) => channel !== null)
|
|
125
|
+
}));
|
|
126
|
+
const newData = {
|
|
127
|
+
...data,
|
|
128
|
+
...newSends.length > 0 ? { sends: newSends } : {},
|
|
129
|
+
...newReceives.length > 0 ? { receives: newReceives } : {}
|
|
130
|
+
};
|
|
131
|
+
import_node_fs.default.writeFileSync(service.path, import_gray_matter.default.stringify(file, newData));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
for (const message of messagesWithChannels) {
|
|
135
|
+
const file = import_node_fs.default.readFileSync(message.path, "utf8");
|
|
136
|
+
const parsed = (0, import_gray_matter.default)(file);
|
|
137
|
+
const { channels, ...newData } = parsed.data;
|
|
138
|
+
import_node_fs.default.writeFileSync(message.path, import_gray_matter.default.stringify(parsed.content, newData));
|
|
139
|
+
}
|
|
140
|
+
console.log("\u2714 Channels migrated to new services API");
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
// src/migrations/index.ts
|
|
144
|
+
var runMigrations = async (dir) => {
|
|
145
|
+
await message_channels_to_service_channels_default(dir);
|
|
146
|
+
};
|
|
147
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
148
|
+
0 && (module.exports = {
|
|
149
|
+
runMigrations
|
|
150
|
+
});
|