@eventcatalog/core 2.34.7 → 2.35.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.
Files changed (47) hide show
  1. package/dist/analytics/analytics.cjs +1 -1
  2. package/dist/analytics/analytics.js +2 -2
  3. package/dist/analytics/log-build.cjs +1 -1
  4. package/dist/analytics/log-build.js +3 -3
  5. package/dist/{chunk-RHCB6E6X.js → chunk-5XXPX5HQ.js} +1 -1
  6. package/dist/{chunk-Y6K4D4LS.js → chunk-7LCJC7ER.js} +1 -1
  7. package/dist/{chunk-ZPWE3CVX.js → chunk-HDG7YSFG.js} +9 -0
  8. package/dist/{chunk-F22TOAQN.js → chunk-TVAQVUFO.js} +1 -1
  9. package/dist/constants.cjs +1 -1
  10. package/dist/constants.js +1 -1
  11. package/dist/eventcatalog.cjs +20 -1
  12. package/dist/eventcatalog.config.d.cts +1 -0
  13. package/dist/eventcatalog.config.d.ts +1 -0
  14. package/dist/eventcatalog.js +21 -5
  15. package/dist/features.cjs +44 -2
  16. package/dist/features.d.cts +2 -1
  17. package/dist/features.d.ts +2 -1
  18. package/dist/features.js +6 -3
  19. package/eventcatalog/astro.config.mjs +8 -2
  20. package/eventcatalog/src/components/Tables/columns/DomainTableColumns.tsx +1 -2
  21. package/eventcatalog/src/content.config.ts +13 -2
  22. package/eventcatalog/src/enterprise/collections/chat-prompts.ts +32 -0
  23. package/eventcatalog/src/enterprise/collections/custom-pages.ts +12 -15
  24. package/eventcatalog/src/enterprise/collections/index.ts +2 -0
  25. package/eventcatalog/src/enterprise/custom-documentation/collection.ts +1 -1
  26. package/eventcatalog/src/enterprise/eventcatalog-chat/EventCatalogVectorStore.ts +50 -0
  27. package/eventcatalog/src/enterprise/eventcatalog-chat/components/Chat.tsx +50 -0
  28. package/eventcatalog/src/enterprise/eventcatalog-chat/components/ChatMessage.tsx +231 -0
  29. package/eventcatalog/src/enterprise/eventcatalog-chat/components/InputModal.tsx +233 -0
  30. package/eventcatalog/src/enterprise/eventcatalog-chat/components/MentionInput.tsx +211 -0
  31. package/eventcatalog/src/enterprise/eventcatalog-chat/components/WelcomePromptArea.tsx +88 -0
  32. package/eventcatalog/src/enterprise/{ai-assistant/components/ChatWindow.tsx → eventcatalog-chat/components/windows/ChatWindow.client.tsx} +3 -5
  33. package/eventcatalog/src/enterprise/eventcatalog-chat/components/windows/ChatWindow.server.tsx +499 -0
  34. package/eventcatalog/src/enterprise/eventcatalog-chat/pages/api/ai/chat.ts +56 -0
  35. package/eventcatalog/src/enterprise/eventcatalog-chat/pages/api/ai/resources.ts +42 -0
  36. package/eventcatalog/src/enterprise/eventcatalog-chat/pages/chat/index.astro +189 -0
  37. package/eventcatalog/src/enterprise/eventcatalog-chat/utils/ai.ts +151 -0
  38. package/eventcatalog/src/enterprise/eventcatalog-chat/utils/chat-prompts.ts +50 -0
  39. package/eventcatalog/src/pages/chat/index.astro +2 -168
  40. package/eventcatalog/src/types/react-syntax-highlighter.d.ts +1 -0
  41. package/package.json +8 -1
  42. package/eventcatalog/src/enterprise/ai-assistant/components/Chat.tsx +0 -16
  43. /package/eventcatalog/src/{shared-collections.ts → content.config-shared-collections.ts} +0 -0
  44. /package/eventcatalog/src/enterprise/{ai-assistant → eventcatalog-chat}/components/ChatSidebar.tsx +0 -0
  45. /package/eventcatalog/src/enterprise/{ai-assistant → eventcatalog-chat}/components/hooks/ChatProvider.tsx +0 -0
  46. /package/eventcatalog/src/enterprise/{ai-assistant → eventcatalog-chat}/components/workers/document-importer.ts +0 -0
  47. /package/eventcatalog/src/enterprise/{ai-assistant → eventcatalog-chat}/components/workers/engine.ts +0 -0
@@ -37,7 +37,7 @@ var import_axios = __toESM(require("axios"), 1);
37
37
  var import_os = __toESM(require("os"), 1);
38
38
 
39
39
  // package.json
40
- var version = "2.34.7";
40
+ var version = "2.35.0";
41
41
 
42
42
  // src/constants.ts
43
43
  var VERSION = version;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  raiseEvent
3
- } from "../chunk-RHCB6E6X.js";
4
- import "../chunk-F22TOAQN.js";
3
+ } from "../chunk-5XXPX5HQ.js";
4
+ import "../chunk-TVAQVUFO.js";
5
5
  export {
6
6
  raiseEvent
7
7
  };
@@ -106,7 +106,7 @@ var import_axios = __toESM(require("axios"), 1);
106
106
  var import_os = __toESM(require("os"), 1);
107
107
 
108
108
  // package.json
109
- var version = "2.34.7";
109
+ var version = "2.35.0";
110
110
 
111
111
  // src/constants.ts
112
112
  var VERSION = version;
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  log_build_default
3
- } from "../chunk-Y6K4D4LS.js";
4
- import "../chunk-RHCB6E6X.js";
5
- import "../chunk-F22TOAQN.js";
3
+ } from "../chunk-7LCJC7ER.js";
4
+ import "../chunk-5XXPX5HQ.js";
5
+ import "../chunk-TVAQVUFO.js";
6
6
  import "../chunk-E7TXTI7G.js";
7
7
  export {
8
8
  log_build_default as default
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  VERSION
3
- } from "./chunk-F22TOAQN.js";
3
+ } from "./chunk-TVAQVUFO.js";
4
4
 
5
5
  // src/analytics/analytics.js
6
6
  import axios from "axios";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  raiseEvent
3
- } from "./chunk-RHCB6E6X.js";
3
+ } from "./chunk-5XXPX5HQ.js";
4
4
  import {
5
5
  getEventCatalogConfigFile,
6
6
  verifyRequiredFieldsAreInCatalogConfigFile
@@ -1,5 +1,13 @@
1
+ import {
2
+ getEventCatalogConfigFile
3
+ } from "./chunk-E7TXTI7G.js";
4
+
1
5
  // src/features.ts
2
6
  import boxen from "boxen";
7
+ var isOutputServer = async () => {
8
+ const config = await getEventCatalogConfigFile(process.env.PROJECT_DIR || "");
9
+ return config?.output === "server";
10
+ };
3
11
  var isBackstagePluginEnabled = async (licenseKey) => {
4
12
  const LICENSE_KEY = process.env.EVENTCATALOG_LICENSE_KEY_BACKSTAGE || process.env.EVENTCATALOG_SCALE_LICENSE_KEY || null;
5
13
  const acceptedPlugins = ["@eventcatalog/backstage-plugin-eventcatalog", "@eventcatalog/eventcatalog-scale"];
@@ -129,6 +137,7 @@ var isEventCatalogStarterEnabled = async (licenseKey) => {
129
137
  };
130
138
 
131
139
  export {
140
+ isOutputServer,
132
141
  isBackstagePluginEnabled,
133
142
  isEventCatalogScaleEnabled,
134
143
  isEventCatalogStarterEnabled
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "2.34.7";
2
+ var version = "2.35.0";
3
3
 
4
4
  // src/constants.ts
5
5
  var VERSION = version;
@@ -25,7 +25,7 @@ __export(constants_exports, {
25
25
  module.exports = __toCommonJS(constants_exports);
26
26
 
27
27
  // package.json
28
- var version = "2.34.7";
28
+ var version = "2.35.0";
29
29
 
30
30
  // src/constants.ts
31
31
  var VERSION = version;
package/dist/constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  VERSION
3
- } from "./chunk-F22TOAQN.js";
3
+ } from "./chunk-TVAQVUFO.js";
4
4
  export {
5
5
  VERSION
6
6
  };
@@ -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.34.7";
160
+ var version = "2.35.0";
161
161
 
162
162
  // src/constants.ts
163
163
  var VERSION = version;
@@ -473,6 +473,10 @@ var import_boxen2 = __toESM(require("boxen"), 1);
473
473
 
474
474
  // src/features.ts
475
475
  var import_boxen = __toESM(require("boxen"), 1);
476
+ var isOutputServer = async () => {
477
+ const config = await getEventCatalogConfigFile(process.env.PROJECT_DIR || "");
478
+ return config?.output === "server";
479
+ };
476
480
  var isBackstagePluginEnabled = async (licenseKey) => {
477
481
  const LICENSE_KEY = process.env.EVENTCATALOG_LICENSE_KEY_BACKSTAGE || process.env.EVENTCATALOG_SCALE_LICENSE_KEY || null;
478
482
  const acceptedPlugins = ["@eventcatalog/backstage-plugin-eventcatalog", "@eventcatalog/eventcatalog-scale"];
@@ -636,6 +640,18 @@ var copyCore = () => {
636
640
  }
637
641
  });
638
642
  };
643
+ var copyServerFiles = async () => {
644
+ const isServerOutput = await isOutputServer();
645
+ if (import_fs2.default.existsSync((0, import_node_path6.join)(core, "src/pages/api/server"))) {
646
+ import_fs2.default.rmSync((0, import_node_path6.join)(core, "src/pages/api/server"), { recursive: true });
647
+ }
648
+ if (!isServerOutput) {
649
+ return;
650
+ }
651
+ import_fs2.default.cpSync((0, import_node_path6.join)(eventCatalogDir, "src/enterprise/eventcatalog-chat/pages/api"), (0, import_node_path6.join)(core, "src/pages/api/server"), {
652
+ recursive: true
653
+ });
654
+ };
639
655
  var clearCore = () => {
640
656
  if (import_fs2.default.existsSync(core)) import_fs2.default.rmSync(core, { recursive: true });
641
657
  };
@@ -679,6 +695,7 @@ program.command("dev").description("Run development server of EventCatalog").opt
679
695
  await resolve_catalog_dependencies_default(dir, core);
680
696
  await checkAndConvertMdToMdx(dir, core);
681
697
  await catalogToAstro(dir, core);
698
+ await copyServerFiles();
682
699
  const canEmbedPages = await isBackstagePluginEnabled();
683
700
  const isEventCatalogStarter = await isEventCatalogStarterEnabled();
684
701
  const isEventCatalogScale = await isEventCatalogScaleEnabled();
@@ -725,6 +742,7 @@ program.command("dev").description("Run development server of EventCatalog").opt
725
742
  program.command("build").description("Run build of EventCatalog").action(async (options, command) => {
726
743
  console.log("Building EventCatalog...");
727
744
  copyCore();
745
+ await copyServerFiles();
728
746
  const canEmbedPages = await isBackstagePluginEnabled();
729
747
  const isEventCatalogStarter = await isEventCatalogStarterEnabled();
730
748
  const isEventCatalogScale = await isEventCatalogScaleEnabled();
@@ -767,6 +785,7 @@ program.command("preview").description("Serves the contents of your eventcatalog
767
785
  const canEmbedPages = await isBackstagePluginEnabled();
768
786
  const isEventCatalogStarter = await isEventCatalogStarterEnabled();
769
787
  const isEventCatalogScale = await isEventCatalogScaleEnabled();
788
+ await copyServerFiles();
770
789
  previewCatalog({ command, canEmbedPages, isEventCatalogStarter, isEventCatalogScale });
771
790
  });
772
791
  program.command("start").description("Serves the contents of your eventcatalog build directory").action(async (options, command) => {
@@ -41,6 +41,7 @@ interface Config {
41
41
  base?: string;
42
42
  port?: string;
43
43
  trailingSlash?: boolean;
44
+ output?: 'server' | 'static';
44
45
  rss?: {
45
46
  enabled: boolean;
46
47
  limit: number;
@@ -41,6 +41,7 @@ interface Config {
41
41
  base?: string;
42
42
  port?: string;
43
43
  trailingSlash?: boolean;
44
+ output?: 'server' | 'static';
44
45
  rss?: {
45
46
  enabled: boolean;
46
47
  limit: number;
@@ -6,20 +6,21 @@ import {
6
6
  } from "./chunk-UKJ7F5WR.js";
7
7
  import {
8
8
  log_build_default
9
- } from "./chunk-Y6K4D4LS.js";
10
- import "./chunk-RHCB6E6X.js";
9
+ } from "./chunk-7LCJC7ER.js";
10
+ import "./chunk-5XXPX5HQ.js";
11
11
  import {
12
12
  catalogToAstro,
13
13
  checkAndConvertMdToMdx
14
14
  } from "./chunk-7SI5EVOX.js";
15
15
  import {
16
16
  VERSION
17
- } from "./chunk-F22TOAQN.js";
17
+ } from "./chunk-TVAQVUFO.js";
18
18
  import {
19
19
  isBackstagePluginEnabled,
20
20
  isEventCatalogScaleEnabled,
21
- isEventCatalogStarterEnabled
22
- } from "./chunk-ZPWE3CVX.js";
21
+ isEventCatalogStarterEnabled,
22
+ isOutputServer
23
+ } from "./chunk-HDG7YSFG.js";
23
24
  import {
24
25
  generate
25
26
  } from "./chunk-YEQVKHST.js";
@@ -69,6 +70,18 @@ var copyCore = () => {
69
70
  }
70
71
  });
71
72
  };
73
+ var copyServerFiles = async () => {
74
+ const isServerOutput = await isOutputServer();
75
+ if (fs.existsSync(join(core, "src/pages/api/server"))) {
76
+ fs.rmSync(join(core, "src/pages/api/server"), { recursive: true });
77
+ }
78
+ if (!isServerOutput) {
79
+ return;
80
+ }
81
+ fs.cpSync(join(eventCatalogDir, "src/enterprise/eventcatalog-chat/pages/api"), join(core, "src/pages/api/server"), {
82
+ recursive: true
83
+ });
84
+ };
72
85
  var clearCore = () => {
73
86
  if (fs.existsSync(core)) fs.rmSync(core, { recursive: true });
74
87
  };
@@ -112,6 +125,7 @@ program.command("dev").description("Run development server of EventCatalog").opt
112
125
  await resolve_catalog_dependencies_default(dir, core);
113
126
  await checkAndConvertMdToMdx(dir, core);
114
127
  await catalogToAstro(dir, core);
128
+ await copyServerFiles();
115
129
  const canEmbedPages = await isBackstagePluginEnabled();
116
130
  const isEventCatalogStarter = await isEventCatalogStarterEnabled();
117
131
  const isEventCatalogScale = await isEventCatalogScaleEnabled();
@@ -158,6 +172,7 @@ program.command("dev").description("Run development server of EventCatalog").opt
158
172
  program.command("build").description("Run build of EventCatalog").action(async (options, command) => {
159
173
  console.log("Building EventCatalog...");
160
174
  copyCore();
175
+ await copyServerFiles();
161
176
  const canEmbedPages = await isBackstagePluginEnabled();
162
177
  const isEventCatalogStarter = await isEventCatalogStarterEnabled();
163
178
  const isEventCatalogScale = await isEventCatalogScaleEnabled();
@@ -200,6 +215,7 @@ program.command("preview").description("Serves the contents of your eventcatalog
200
215
  const canEmbedPages = await isBackstagePluginEnabled();
201
216
  const isEventCatalogStarter = await isEventCatalogStarterEnabled();
202
217
  const isEventCatalogScale = await isEventCatalogScaleEnabled();
218
+ await copyServerFiles();
203
219
  previewCatalog({ command, canEmbedPages, isEventCatalogStarter, isEventCatalogScale });
204
220
  });
205
221
  program.command("start").description("Serves the contents of your eventcatalog build directory").action(async (options, command) => {
package/dist/features.cjs CHANGED
@@ -32,10 +32,51 @@ var features_exports = {};
32
32
  __export(features_exports, {
33
33
  isBackstagePluginEnabled: () => isBackstagePluginEnabled,
34
34
  isEventCatalogScaleEnabled: () => isEventCatalogScaleEnabled,
35
- isEventCatalogStarterEnabled: () => isEventCatalogStarterEnabled
35
+ isEventCatalogStarterEnabled: () => isEventCatalogStarterEnabled,
36
+ isOutputServer: () => isOutputServer
36
37
  });
37
38
  module.exports = __toCommonJS(features_exports);
38
39
  var import_boxen = __toESM(require("boxen"), 1);
40
+
41
+ // src/eventcatalog-config-file-utils.js
42
+ var import_promises = require("fs/promises");
43
+ var import_node_fs = require("fs");
44
+ var import_promises2 = require("fs/promises");
45
+ var import_node_path = __toESM(require("path"), 1);
46
+ var import_uuid = require("uuid");
47
+ var import_url = require("url");
48
+ var import_gray_matter = __toESM(require("gray-matter"), 1);
49
+ async function cleanup(projectDirectory) {
50
+ const filePath = import_node_path.default.join(projectDirectory, "eventcatalog.config.mjs");
51
+ if ((0, import_node_fs.existsSync)(filePath)) {
52
+ await (0, import_promises.rm)(filePath);
53
+ }
54
+ }
55
+ var getEventCatalogConfigFile = async (projectDirectory) => {
56
+ try {
57
+ let configFilePath = import_node_path.default.join(projectDirectory, "eventcatalog.config.js");
58
+ const filePath = import_node_path.default.join(projectDirectory, "package.json");
59
+ const packageJson = JSON.parse(await (0, import_promises.readFile)(filePath, "utf-8"));
60
+ if (packageJson?.type !== "module") {
61
+ await (0, import_promises2.copyFile)(configFilePath, import_node_path.default.join(projectDirectory, "eventcatalog.config.mjs"));
62
+ configFilePath = import_node_path.default.join(projectDirectory, "eventcatalog.config.mjs");
63
+ }
64
+ const configFileURL = (0, import_url.pathToFileURL)(configFilePath).href;
65
+ const config = await import(
66
+ /* @vite-ignore */
67
+ configFileURL
68
+ );
69
+ return config.default;
70
+ } finally {
71
+ await cleanup(projectDirectory);
72
+ }
73
+ };
74
+
75
+ // src/features.ts
76
+ var isOutputServer = async () => {
77
+ const config = await getEventCatalogConfigFile(process.env.PROJECT_DIR || "");
78
+ return config?.output === "server";
79
+ };
39
80
  var isBackstagePluginEnabled = async (licenseKey) => {
40
81
  const LICENSE_KEY = process.env.EVENTCATALOG_LICENSE_KEY_BACKSTAGE || process.env.EVENTCATALOG_SCALE_LICENSE_KEY || null;
41
82
  const acceptedPlugins = ["@eventcatalog/backstage-plugin-eventcatalog", "@eventcatalog/eventcatalog-scale"];
@@ -167,5 +208,6 @@ var isEventCatalogStarterEnabled = async (licenseKey) => {
167
208
  0 && (module.exports = {
168
209
  isBackstagePluginEnabled,
169
210
  isEventCatalogScaleEnabled,
170
- isEventCatalogStarterEnabled
211
+ isEventCatalogStarterEnabled,
212
+ isOutputServer
171
213
  });
@@ -1,5 +1,6 @@
1
+ declare const isOutputServer: () => Promise<boolean>;
1
2
  declare const isBackstagePluginEnabled: (licenseKey?: string) => Promise<boolean>;
2
3
  declare const isEventCatalogScaleEnabled: (licenseKey?: string) => Promise<boolean>;
3
4
  declare const isEventCatalogStarterEnabled: (licenseKey?: string) => Promise<boolean>;
4
5
 
5
- export { isBackstagePluginEnabled, isEventCatalogScaleEnabled, isEventCatalogStarterEnabled };
6
+ export { isBackstagePluginEnabled, isEventCatalogScaleEnabled, isEventCatalogStarterEnabled, isOutputServer };
@@ -1,5 +1,6 @@
1
+ declare const isOutputServer: () => Promise<boolean>;
1
2
  declare const isBackstagePluginEnabled: (licenseKey?: string) => Promise<boolean>;
2
3
  declare const isEventCatalogScaleEnabled: (licenseKey?: string) => Promise<boolean>;
3
4
  declare const isEventCatalogStarterEnabled: (licenseKey?: string) => Promise<boolean>;
4
5
 
5
- export { isBackstagePluginEnabled, isEventCatalogScaleEnabled, isEventCatalogStarterEnabled };
6
+ export { isBackstagePluginEnabled, isEventCatalogScaleEnabled, isEventCatalogStarterEnabled, isOutputServer };
package/dist/features.js CHANGED
@@ -1,10 +1,13 @@
1
1
  import {
2
2
  isBackstagePluginEnabled,
3
3
  isEventCatalogScaleEnabled,
4
- isEventCatalogStarterEnabled
5
- } from "./chunk-ZPWE3CVX.js";
4
+ isEventCatalogStarterEnabled,
5
+ isOutputServer
6
+ } from "./chunk-HDG7YSFG.js";
7
+ import "./chunk-E7TXTI7G.js";
6
8
  export {
7
9
  isBackstagePluginEnabled,
8
10
  isEventCatalogScaleEnabled,
9
- isEventCatalogStarterEnabled
11
+ isEventCatalogStarterEnabled,
12
+ isOutputServer
10
13
  };
@@ -7,7 +7,7 @@ import { mermaid } from "./src/remark-plugins/mermaid"
7
7
  import { join } from 'node:path';
8
8
  import remarkDirective from 'remark-directive';
9
9
  import { remarkDirectives } from "./src/remark-plugins/directives"
10
-
10
+ import node from '@astrojs/node';
11
11
  import remarkComment from 'remark-comment'
12
12
 
13
13
  /** @type {import('bin/eventcatalog.config').Config} */
@@ -22,6 +22,12 @@ export default defineConfig({
22
22
  base,
23
23
  server: { port: config.port || 3000 },
24
24
 
25
+ // output: config.output || 'static',
26
+
27
+ adapter: config.output === 'server' ? node({
28
+ mode: 'standalone'
29
+ }) : undefined,
30
+
25
31
  outDir: config.outDir ? join(projectDirectory, config.outDir) : join(projectDirectory, 'dist'),
26
32
 
27
33
  // https://docs.astro.build/en/reference/configuration-reference/#site
@@ -47,7 +53,7 @@ export default defineConfig({
47
53
  wrap: true,
48
54
  },
49
55
  }),
50
-
56
+
51
57
  mdx({
52
58
  // https://docs.astro.build/en/guides/integrations-guide/mdx/#optimize
53
59
  optimize: config.mdxOptimize || false,
@@ -1,5 +1,4 @@
1
- import { ServerIcon } from '@heroicons/react/20/solid';
2
- import { RectangleGroupIcon } from '@heroicons/react/20/solid';
1
+ import { ServerIcon, RectangleGroupIcon } from '@heroicons/react/20/solid';
3
2
  import { createColumnHelper } from '@tanstack/react-table';
4
3
  import { filterByName, filterCollectionByName } from '../filters/custom-filters';
5
4
  import { buildUrl } from '@utils/url-builder';
@@ -1,8 +1,10 @@
1
1
  import { z, defineCollection, reference } from 'astro:content';
2
2
  import { glob } from 'astro/loaders';
3
3
  import { v4 as uuidv4 } from 'uuid';
4
- import { badge, ownerReference } from './shared-collections';
5
- import { customPagesSchema } from './enterprise/custom-documentation/collection';
4
+ import { badge, ownerReference } from './content.config-shared-collections';
5
+
6
+ // Enterprise Collections
7
+ import { chatPromptsSchema, customPagesSchema } from './enterprise/collections';
6
8
 
7
9
  export const projectDirBase = (() => {
8
10
  if (process.platform === 'win32') {
@@ -306,6 +308,14 @@ const customPages = defineCollection({
306
308
  schema: customPagesSchema,
307
309
  });
308
310
 
311
+ const chatPrompts = defineCollection({
312
+ loader: glob({
313
+ pattern: ['chat-prompts/*.(md|mdx)', 'chat-prompts/**/*.@(md|mdx)'],
314
+ base: projectDirBase,
315
+ }),
316
+ schema: chatPromptsSchema,
317
+ });
318
+
309
319
  const domains = defineCollection({
310
320
  loader: glob({
311
321
  pattern: [
@@ -432,4 +442,5 @@ export const collections = {
432
442
 
433
443
  // EventCatalog Pro Collections
434
444
  customPages,
445
+ chatPrompts,
435
446
  };
@@ -0,0 +1,32 @@
1
+ import { z } from 'astro:content';
2
+
3
+ export const chatPromptsSchema = z.object({
4
+ title: z.string(),
5
+ type: z.enum(['text', 'code']).default('text'),
6
+ inputs: z
7
+ .array(
8
+ z.object({
9
+ id: z.string(),
10
+ label: z.string(),
11
+ type: z
12
+ .enum([
13
+ 'text',
14
+ 'resource-list-events',
15
+ 'resource-list-services',
16
+ 'resource-list-commands',
17
+ 'resource-list-queries',
18
+ 'code',
19
+ 'text-area',
20
+ 'select',
21
+ ])
22
+ .default('text'),
23
+ options: z.array(z.string()).optional(),
24
+ })
25
+ )
26
+ .optional(),
27
+ category: z.object({
28
+ id: z.string(),
29
+ label: z.string(),
30
+ icon: z.string().optional(),
31
+ }),
32
+ });
@@ -1,19 +1,16 @@
1
- import { glob } from 'astro/loaders';
2
- import { z, defineCollection } from 'astro:content';
3
- import { projectDirBase } from '../../content.config';
1
+ import { z } from 'astro:content';
2
+ import { badge, ownerReference } from '../../content.config-shared-collections';
4
3
 
5
- export const customPages = defineCollection({
6
- loader: glob({
7
- pattern: ['docs/hello-world.mdx'],
8
- base: projectDirBase,
9
- }),
10
- schema: z.object({
11
- id: z.string(),
12
- title: z.string(),
13
- description: z.string(),
14
- sidebar: z.object({
4
+ export const customPagesSchema = z.object({
5
+ title: z.string(),
6
+ summary: z.string(),
7
+ slug: z.string().optional(),
8
+ sidebar: z
9
+ .object({
15
10
  label: z.string(),
16
11
  order: z.number(),
17
- }),
18
- }),
12
+ })
13
+ .optional(),
14
+ owners: z.array(ownerReference).optional(),
15
+ badges: z.array(badge).optional(),
19
16
  });
@@ -0,0 +1,2 @@
1
+ export { customPagesSchema } from './custom-pages';
2
+ export { chatPromptsSchema } from './chat-prompts';
@@ -1,5 +1,5 @@
1
1
  import { z } from 'astro:content';
2
- import { badge, ownerReference } from '../../shared-collections';
2
+ import { badge, ownerReference } from '../../content.config-shared-collections';
3
3
 
4
4
  export const customPagesSchema = z.object({
5
5
  title: z.string(),
@@ -0,0 +1,50 @@
1
+ import { HuggingFaceTransformersEmbeddings } from '@langchain/community/embeddings/huggingface_transformers';
2
+ import { MemoryVectorStore } from 'langchain/vectorstores/memory';
3
+ import { Document as LangChainDocument } from 'langchain/document';
4
+
5
+ const embeddingsInstance = new HuggingFaceTransformersEmbeddings({ model: 'Xenova/all-MiniLM-L6-v2' });
6
+
7
+ export interface Resource {
8
+ id: string;
9
+ type: string;
10
+ url: string;
11
+ title?: string;
12
+ }
13
+
14
+ export class EventCatalogVectorStore {
15
+ private vectorStore: MemoryVectorStore;
16
+
17
+ // Make the constructor private so it can only be called from within the class
18
+ private constructor(vectorStore: MemoryVectorStore) {
19
+ this.vectorStore = vectorStore;
20
+ }
21
+
22
+ // Static async factory method
23
+ public static async create(documents: LangChainDocument[], embeddings: number[][]): Promise<EventCatalogVectorStore> {
24
+ const vectorStore = new MemoryVectorStore(embeddingsInstance);
25
+ await vectorStore.addVectors(embeddings, documents);
26
+ return new EventCatalogVectorStore(vectorStore);
27
+ }
28
+
29
+ async search(query: string) {
30
+ return this.vectorStore.similaritySearch(query, 10);
31
+ }
32
+
33
+ async getEventCatalogResources(query: string): Promise<Resource[]> {
34
+ const results = await this.vectorStore.similaritySearchWithScore(query, 50);
35
+ return Array.from(
36
+ new Map(
37
+ results.map((result: any) => {
38
+ const metadata = result[0].metadata;
39
+ const resource: Resource = {
40
+ id: metadata.id,
41
+ type: metadata.type,
42
+ url: `/docs/${metadata.type}s/${metadata.id}`,
43
+ title: metadata.title || metadata.id,
44
+ };
45
+ return [metadata.id, resource]; // Use ID as key for Map
46
+ })
47
+ ).values()
48
+ );
49
+ }
50
+ }
@@ -0,0 +1,50 @@
1
+ import Sidebar from './ChatSidebar';
2
+ import { ChatProvider } from './hooks/ChatProvider';
3
+ import ChatWindowWebLLM from './windows/ChatWindow.client';
4
+ import ChatWindowServer from './windows/ChatWindow.server';
5
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
6
+ import type { ChatPromptCategoryGroup } from '@enterprise/eventcatalog-chat/utils/chat-prompts';
7
+ import config from '@config';
8
+ const output = config.output || 'static';
9
+ interface Resource {
10
+ id: string;
11
+ type: string;
12
+ name: string;
13
+ }
14
+
15
+ /**
16
+ * Chat component has two modes:
17
+ * - Client: ChatWindow.client.tsx (uses webllm)
18
+ * - Server: ChatWindow.server.tsx (uses server-side code, bring your own API key)
19
+ *
20
+ * The mode is determined by the config.output property in the eventcatalog.config.js file.
21
+ */
22
+
23
+ const Chat = ({
24
+ chatConfig,
25
+ resources,
26
+ chatPrompts,
27
+ }: {
28
+ chatConfig: any;
29
+ resources: Resource[];
30
+ chatPrompts: ChatPromptCategoryGroup[];
31
+ }) => {
32
+ const queryClient = new QueryClient();
33
+
34
+ return (
35
+ <ChatProvider>
36
+ <div className="flex overflow-hidden w-full">
37
+ <Sidebar />
38
+ {output === 'server' ? (
39
+ <QueryClientProvider client={queryClient}>
40
+ <ChatWindowServer {...chatConfig} resources={resources} chatPrompts={chatPrompts} />
41
+ </QueryClientProvider>
42
+ ) : (
43
+ <ChatWindowWebLLM {...chatConfig} />
44
+ )}
45
+ </div>
46
+ </ChatProvider>
47
+ );
48
+ };
49
+
50
+ export default Chat;