@eventcatalog/core 2.40.1 → 2.41.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.
@@ -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.40.1";
40
+ var version = "2.41.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-77FIZKRC.js";
4
- import "../chunk-P5YUKYTV.js";
3
+ } from "../chunk-RJR4RWGX.js";
4
+ import "../chunk-KSA77O7W.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.40.1";
109
+ var version = "2.41.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-TLEJWHPX.js";
4
- import "../chunk-77FIZKRC.js";
5
- import "../chunk-P5YUKYTV.js";
3
+ } from "../chunk-2VVCJWLQ.js";
4
+ import "../chunk-RJR4RWGX.js";
5
+ import "../chunk-KSA77O7W.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
  raiseEvent
3
- } from "./chunk-77FIZKRC.js";
3
+ } from "./chunk-RJR4RWGX.js";
4
4
  import {
5
5
  getEventCatalogConfigFile,
6
6
  verifyRequiredFieldsAreInCatalogConfigFile
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "2.40.1";
2
+ var version = "2.41.0";
3
3
 
4
4
  // src/constants.ts
5
5
  var VERSION = version;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  VERSION
3
- } from "./chunk-P5YUKYTV.js";
3
+ } from "./chunk-KSA77O7W.js";
4
4
 
5
5
  // src/analytics/analytics.js
6
6
  import axios from "axios";
@@ -25,7 +25,7 @@ __export(constants_exports, {
25
25
  module.exports = __toCommonJS(constants_exports);
26
26
 
27
27
  // package.json
28
- var version = "2.40.1";
28
+ var version = "2.41.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-P5YUKYTV.js";
3
+ } from "./chunk-KSA77O7W.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.40.1";
160
+ var version = "2.41.0";
161
161
 
162
162
  // src/constants.ts
163
163
  var VERSION = version;
@@ -6,15 +6,15 @@ import {
6
6
  } from "./chunk-DCLTVJDP.js";
7
7
  import {
8
8
  log_build_default
9
- } from "./chunk-TLEJWHPX.js";
10
- import "./chunk-77FIZKRC.js";
9
+ } from "./chunk-2VVCJWLQ.js";
10
+ import "./chunk-RJR4RWGX.js";
11
11
  import {
12
12
  catalogToAstro,
13
13
  checkAndConvertMdToMdx
14
14
  } from "./chunk-SLEMYHTU.js";
15
15
  import {
16
16
  VERSION
17
- } from "./chunk-P5YUKYTV.js";
17
+ } from "./chunk-KSA77O7W.js";
18
18
  import {
19
19
  isBackstagePluginEnabled,
20
20
  isEventCatalogScaleEnabled,
@@ -13,6 +13,7 @@ export interface Resource {
13
13
  type: string;
14
14
  url: string;
15
15
  title?: string;
16
+ schema?: string;
16
17
  }
17
18
 
18
19
  export class EventCatalogVectorStore {
@@ -55,6 +56,7 @@ export class EventCatalogVectorStore {
55
56
  type: metadata.type,
56
57
  url: `/docs/${metadata.type}s/${metadata.id}`,
57
58
  title: metadata.title || metadata.id,
59
+ ...(metadata.schema && { schema: metadata.schema }),
58
60
  };
59
61
  return [metadata.id, resource]; // Use ID as key for Map
60
62
  })
@@ -1,9 +1,8 @@
1
- import { generateText, type CoreMessage, type Message } from 'ai';
1
+ import { type CoreMessage, type Message } from 'ai';
2
2
  import { EventCatalogVectorStore, type Resource } from '@enterprise/eventcatalog-chat/EventCatalogVectorStore';
3
3
  import fs from 'fs';
4
4
  import path from 'path';
5
5
  import config from '@config';
6
- import { anthropic } from '@ai-sdk/anthropic';
7
6
  import { getProvider } from '@enterprise/eventcatalog-chat/providers';
8
7
 
9
8
  const AI_EMBEDDINGS_PATH = path.join(process.env.PROJECT_DIR || process.cwd(), 'public/ai');
@@ -61,7 +60,11 @@ If you have additional context, use it to answer the question.`;
61
60
  const resourceStrings = resources.map((resource: Resource) => {
62
61
  const attributes = Object.entries(resource)
63
62
  .filter(([key, value]) => key !== 'markdown' && key !== 'loc' && value !== undefined && value !== null)
64
- .map(([key, value]) => `${key}="${String(value).replace(/"/g, '"')}"`) // Escape quotes in values
63
+ .map(([key, value]) => {
64
+ // value can be an object, so we need to convert it to a string
65
+ const valueString = typeof value === 'object' ? JSON.stringify(value) : String(value);
66
+ return `${key}="${valueString.replace(/"/g, '"')}"`; // Escape quotes in values
67
+ })
65
68
  .join(' ');
66
69
  return `<resource ${attributes} />`;
67
70
  });
@@ -6,7 +6,8 @@ import type { APIRoute } from 'astro';
6
6
  import { getCollection } from 'astro:content';
7
7
  import config from '@config';
8
8
  import fs from 'fs';
9
-
9
+ import { dirname, join } from 'path';
10
+ import { addSchemaToMarkdown } from '@utils/llms';
10
11
  const events = await getCollection('events');
11
12
  const commands = await getCollection('commands');
12
13
  const queries = await getCollection('queries');
@@ -49,7 +50,14 @@ export const GET: APIRoute = async ({ params, props }) => {
49
50
  }
50
51
 
51
52
  if (props?.content?.filePath) {
52
- const file = fs.readFileSync(props.content.filePath, 'utf8');
53
+ let file = fs.readFileSync(props.content.filePath, 'utf8');
54
+
55
+ try {
56
+ file = addSchemaToMarkdown(props.content, file);
57
+ } catch (error) {
58
+ console.log('Warning: Cant find the schema for', props.content.data.id, props.content.data.version);
59
+ }
60
+
53
61
  return new Response(file, { status: 200 });
54
62
  }
55
63
 
@@ -3,6 +3,7 @@ import config from '@config';
3
3
  import type { APIRoute } from 'astro';
4
4
  import fs from 'fs';
5
5
  import { isCustomDocsEnabled } from '@utils/feature';
6
+ import { addSchemaToMarkdown } from '@utils/llms';
6
7
 
7
8
  type AllowedCollections = 'events' | 'commands' | 'queries' | 'services' | 'domains' | 'teams' | 'users' | 'customPages';
8
9
 
@@ -38,7 +39,18 @@ export const GET: APIRoute = async ({ params, request }) => {
38
39
  const content = resources
39
40
  .map((item) => {
40
41
  if (!item.filePath) return '';
41
- return fs.readFileSync(item.filePath, 'utf8');
42
+
43
+ let file = fs.readFileSync(item.filePath, 'utf8');
44
+
45
+ try {
46
+ // Try and add the schemas to the resource
47
+ // @ts-ignore
48
+ file = addSchemaToMarkdown(item, file);
49
+ } catch (error) {
50
+ // just skip the resource if it has no schema
51
+ }
52
+
53
+ return file;
42
54
  })
43
55
  .join('\n');
44
56
 
@@ -0,0 +1,35 @@
1
+ import type { CollectionTypes } from '@types';
2
+ import type { CollectionEntry } from 'astro:content';
3
+ import { dirname } from 'path';
4
+ import { join } from 'path';
5
+ import fs from 'fs';
6
+
7
+ export const addSchemaToMarkdown = (collection: CollectionEntry<CollectionTypes>, file: string) => {
8
+ const resourceData = collection?.data;
9
+ const fileToResource = collection.filePath ?? '';
10
+ let schemas: string[] = [];
11
+
12
+ if (!resourceData?.specifications && !resourceData?.schemaPath) {
13
+ return file;
14
+ }
15
+
16
+ if (Array.isArray(resourceData?.specifications)) {
17
+ schemas = resourceData?.specifications.map((specification: any) => specification.path);
18
+ } else {
19
+ schemas = [resourceData?.schemaPath ?? ''];
20
+ }
21
+
22
+ const filteredSchemas = schemas.filter((schema: any) => schema !== undefined);
23
+
24
+ // attach the schema if it has it
25
+ if (filteredSchemas.length > 0) {
26
+ for (const pathToSchema of filteredSchemas) {
27
+ const directory = dirname(fileToResource);
28
+ const schemaPath = join(directory, pathToSchema);
29
+ const schemaFile = fs.readFileSync(schemaPath, 'utf8');
30
+ file = `${file}\n\n ## Raw Schema:${pathToSchema}\n\n${schemaFile}`;
31
+ }
32
+ }
33
+
34
+ return file;
35
+ };
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "url": "https://github.com/event-catalog/eventcatalog.git"
7
7
  },
8
8
  "type": "module",
9
- "version": "2.40.1",
9
+ "version": "2.41.0",
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
@@ -33,7 +33,7 @@
33
33
  "@asyncapi/avro-schema-parser": "^3.0.24",
34
34
  "@asyncapi/parser": "^3.4.0",
35
35
  "@asyncapi/react-component": "^2.4.3",
36
- "@eventcatalog/generator-ai": "^1.0.2",
36
+ "@eventcatalog/generator-ai": "^1.1.0",
37
37
  "@eventcatalog/sdk": "^2.2.7",
38
38
  "@fontsource/inter": "^5.2.5",
39
39
  "@headlessui/react": "^2.0.3",