@eventcatalog/core 2.40.1 → 2.41.1
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-TLEJWHPX.js → chunk-LJRN3X6I.js} +1 -1
- package/dist/{chunk-77FIZKRC.js → chunk-ZOHANGSK.js} +1 -1
- package/dist/{chunk-P5YUKYTV.js → chunk-ZTIHRJ5F.js} +1 -1
- package/dist/constants.cjs +1 -1
- package/dist/constants.js +1 -1
- package/dist/eventcatalog.cjs +1 -1
- package/dist/eventcatalog.js +3 -3
- package/eventcatalog/src/enterprise/eventcatalog-chat/EventCatalogVectorStore.ts +2 -0
- package/eventcatalog/src/enterprise/eventcatalog-chat/utils/ai.ts +6 -3
- package/eventcatalog/src/pages/docs/[type]/[id]/[version].mdx.ts +10 -2
- package/eventcatalog/src/pages/docs/llm/llms-full.txt.ts +13 -1
- package/eventcatalog/src/pages/docs/llm/llms.txt.ts +1 -1
- package/eventcatalog/src/utils/llms.ts +35 -0
- 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-LJRN3X6I.js";
|
|
4
|
+
import "../chunk-ZOHANGSK.js";
|
|
5
|
+
import "../chunk-ZTIHRJ5F.js";
|
|
6
6
|
import "../chunk-E7TXTI7G.js";
|
|
7
7
|
export {
|
|
8
8
|
log_build_default as default
|
package/dist/constants.cjs
CHANGED
package/dist/constants.js
CHANGED
package/dist/eventcatalog.cjs
CHANGED
package/dist/eventcatalog.js
CHANGED
|
@@ -6,15 +6,15 @@ import {
|
|
|
6
6
|
} from "./chunk-DCLTVJDP.js";
|
|
7
7
|
import {
|
|
8
8
|
log_build_default
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-LJRN3X6I.js";
|
|
10
|
+
import "./chunk-ZOHANGSK.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-
|
|
17
|
+
} from "./chunk-ZTIHRJ5F.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 {
|
|
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]) =>
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
|
@@ -18,7 +18,7 @@ const customDocs = await getCollection('customPages');
|
|
|
18
18
|
|
|
19
19
|
export const GET: APIRoute = async ({ params, request }) => {
|
|
20
20
|
const url = new URL(request.url);
|
|
21
|
-
const baseUrl = `${url.
|
|
21
|
+
const baseUrl = `${url.origin}`;
|
|
22
22
|
|
|
23
23
|
const formatVersionedItem = (item: any, type: string) =>
|
|
24
24
|
`- [${item.data.name} - ${item.data.id} - ${item.data.version}](${baseUrl}/docs/${type}/${item.data.id}/${item.data.version}.mdx) - ${item.data.summary}`;
|
|
@@ -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.
|
|
9
|
+
"version": "2.41.1",
|
|
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
|
|
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",
|