@eventcatalog/core 3.46.1 → 3.47.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.
Files changed (38) 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-VZ6L3G2S.js → chunk-6GSS7Q6C.js} +1 -1
  6. package/dist/{chunk-TZ72NP2W.js → chunk-KCQPWC27.js} +1 -1
  7. package/dist/{chunk-E4QGTJXO.js → chunk-TL2SVMED.js} +1 -1
  8. package/dist/{chunk-A7XUEEUA.js → chunk-UKMUMDL5.js} +1 -1
  9. package/dist/{chunk-62QAJWPT.js → chunk-X5CVZQHR.js} +1 -1
  10. package/dist/constants.cjs +1 -1
  11. package/dist/constants.js +1 -1
  12. package/dist/eventcatalog.cjs +1 -1
  13. package/dist/eventcatalog.js +5 -5
  14. package/dist/generate.cjs +1 -1
  15. package/dist/generate.js +3 -3
  16. package/dist/utils/cli-logger.cjs +1 -1
  17. package/dist/utils/cli-logger.js +2 -2
  18. package/eventcatalog/src/components/MDX/SchemaViewer/SchemaViewerRoot.astro +14 -2
  19. package/eventcatalog/src/components/MDX/SchemaViewer/schema-viewer-utils.spec.ts +63 -0
  20. package/eventcatalog/src/components/MDX/SchemaViewer/schema-viewer-utils.ts +25 -7
  21. package/eventcatalog/src/components/SchemaExplorer/ProtobufSchemaViewer.tsx +532 -0
  22. package/eventcatalog/src/components/SchemaExplorer/SchemaContentViewer.tsx +6 -0
  23. package/eventcatalog/src/components/SchemaExplorer/SchemaDetailsPanel.tsx +20 -2
  24. package/eventcatalog/src/components/SchemaExplorer/SchemaExplorer.tsx +14 -5
  25. package/eventcatalog/src/components/SchemaExplorer/SchemaViewerModal.tsx +8 -2
  26. package/eventcatalog/src/components/SchemaExplorer/utils.ts +4 -0
  27. package/eventcatalog/src/pages/docs/[type]/[id]/language/_index.data.ts +19 -4
  28. package/eventcatalog/src/pages/docs/[type]/[id]/language.mdx.ts +16 -5
  29. package/eventcatalog/src/stores/sidebar-store/builders/domain.ts +4 -2
  30. package/eventcatalog/src/stores/sidebar-store/builders/entity.ts +87 -0
  31. package/eventcatalog/src/stores/sidebar-store/builders/shared.ts +1 -0
  32. package/eventcatalog/src/stores/sidebar-store/state.ts +15 -14
  33. package/eventcatalog/src/utils/collections/domains.ts +39 -0
  34. package/eventcatalog/src/utils/collections/entities.ts +3 -1
  35. package/eventcatalog/src/utils/files.ts +9 -0
  36. package/eventcatalog/src/utils/node-graphs/domain-entity-map.ts +24 -12
  37. package/eventcatalog/src/utils/protobuf-schema.ts +476 -0
  38. package/package.json +1 -1
@@ -36,7 +36,7 @@ module.exports = __toCommonJS(analytics_exports);
36
36
  var import_os = __toESM(require("os"), 1);
37
37
 
38
38
  // package.json
39
- var version = "3.46.1";
39
+ var version = "3.47.1";
40
40
 
41
41
  // src/constants.ts
42
42
  var VERSION = version;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  raiseEvent
3
- } from "../chunk-A7XUEEUA.js";
4
- import "../chunk-E4QGTJXO.js";
3
+ } from "../chunk-UKMUMDL5.js";
4
+ import "../chunk-TL2SVMED.js";
5
5
  export {
6
6
  raiseEvent
7
7
  };
@@ -140,7 +140,7 @@ var verifyRequiredFieldsAreInCatalogConfigFile = async (projectDirectory) => {
140
140
  var import_os = __toESM(require("os"), 1);
141
141
 
142
142
  // package.json
143
- var version = "3.46.1";
143
+ var version = "3.47.1";
144
144
 
145
145
  // src/constants.ts
146
146
  var VERSION = version;
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  log_build_default
3
- } from "../chunk-TZ72NP2W.js";
4
- import "../chunk-A7XUEEUA.js";
3
+ } from "../chunk-KCQPWC27.js";
4
+ import "../chunk-UKMUMDL5.js";
5
5
  import "../chunk-DAOXTQVS.js";
6
- import "../chunk-E4QGTJXO.js";
6
+ import "../chunk-TL2SVMED.js";
7
7
  import "../chunk-6QENHZZP.js";
8
8
  export {
9
9
  log_build_default as default
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  logger
3
- } from "./chunk-62QAJWPT.js";
3
+ } from "./chunk-X5CVZQHR.js";
4
4
  import {
5
5
  cleanup,
6
6
  getEventCatalogConfigFile
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  raiseEvent
3
- } from "./chunk-A7XUEEUA.js";
3
+ } from "./chunk-UKMUMDL5.js";
4
4
  import {
5
5
  countResources,
6
6
  serializeCounts
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "3.46.1";
2
+ var version = "3.47.1";
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-E4QGTJXO.js";
3
+ } from "./chunk-TL2SVMED.js";
4
4
 
5
5
  // src/analytics/analytics.js
6
6
  import os from "os";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  VERSION
3
- } from "./chunk-E4QGTJXO.js";
3
+ } from "./chunk-TL2SVMED.js";
4
4
 
5
5
  // src/utils/cli-logger.ts
6
6
  import pc from "picocolors";
@@ -25,7 +25,7 @@ __export(constants_exports, {
25
25
  module.exports = __toCommonJS(constants_exports);
26
26
 
27
27
  // package.json
28
- var version = "3.46.1";
28
+ var version = "3.47.1";
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-E4QGTJXO.js";
3
+ } from "./chunk-TL2SVMED.js";
4
4
  export {
5
5
  VERSION
6
6
  };
@@ -144,7 +144,7 @@ var verifyRequiredFieldsAreInCatalogConfigFile = async (projectDirectory) => {
144
144
  var import_picocolors = __toESM(require("picocolors"), 1);
145
145
 
146
146
  // package.json
147
- var version = "3.46.1";
147
+ var version = "3.47.1";
148
148
 
149
149
  // src/constants.ts
150
150
  var VERSION = version;
@@ -13,8 +13,8 @@ import {
13
13
  } from "./chunk-3H2RT3CM.js";
14
14
  import {
15
15
  log_build_default
16
- } from "./chunk-TZ72NP2W.js";
17
- import "./chunk-A7XUEEUA.js";
16
+ } from "./chunk-KCQPWC27.js";
17
+ import "./chunk-UKMUMDL5.js";
18
18
  import "./chunk-DAOXTQVS.js";
19
19
  import {
20
20
  catalogToAstro
@@ -28,13 +28,13 @@ import {
28
28
  } from "./chunk-B7HCX5HM.js";
29
29
  import {
30
30
  generate
31
- } from "./chunk-VZ6L3G2S.js";
31
+ } from "./chunk-6GSS7Q6C.js";
32
32
  import {
33
33
  logger
34
- } from "./chunk-62QAJWPT.js";
34
+ } from "./chunk-X5CVZQHR.js";
35
35
  import {
36
36
  VERSION
37
- } from "./chunk-E4QGTJXO.js";
37
+ } from "./chunk-TL2SVMED.js";
38
38
  import {
39
39
  getEventCatalogConfigFile,
40
40
  verifyRequiredFieldsAreInCatalogConfigFile
package/dist/generate.cjs CHANGED
@@ -108,7 +108,7 @@ var getEventCatalogConfigFile = async (projectDirectory) => {
108
108
  var import_picocolors = __toESM(require("picocolors"), 1);
109
109
 
110
110
  // package.json
111
- var version = "3.46.1";
111
+ var version = "3.47.1";
112
112
 
113
113
  // src/constants.ts
114
114
  var VERSION = version;
package/dist/generate.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  generate
3
- } from "./chunk-VZ6L3G2S.js";
4
- import "./chunk-62QAJWPT.js";
5
- import "./chunk-E4QGTJXO.js";
3
+ } from "./chunk-6GSS7Q6C.js";
4
+ import "./chunk-X5CVZQHR.js";
5
+ import "./chunk-TL2SVMED.js";
6
6
  import "./chunk-6QENHZZP.js";
7
7
  export {
8
8
  generate
@@ -36,7 +36,7 @@ module.exports = __toCommonJS(cli_logger_exports);
36
36
  var import_picocolors = __toESM(require("picocolors"), 1);
37
37
 
38
38
  // package.json
39
- var version = "3.46.1";
39
+ var version = "3.47.1";
40
40
 
41
41
  // src/constants.ts
42
42
  var VERSION = version;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  logger
3
- } from "../chunk-62QAJWPT.js";
4
- import "../chunk-E4QGTJXO.js";
3
+ } from "../chunk-X5CVZQHR.js";
4
+ import "../chunk-TL2SVMED.js";
5
5
  export {
6
6
  logger
7
7
  };
@@ -4,12 +4,15 @@ import fs from 'node:fs/promises';
4
4
  import { getCollection } from 'astro:content';
5
5
  import JSONSchemaViewer from '@components/SchemaExplorer/JSONSchemaViewer';
6
6
  import AvroSchemaViewer from '@components/SchemaExplorer/AvroSchemaViewer';
7
+ import ProtobufSchemaViewer from '@components/SchemaExplorer/ProtobufSchemaViewer';
7
8
  import Admonition from '../Admonition';
8
9
  import { getMDXComponentsByName } from '@utils/markdown';
9
10
  import { resolveProjectPath } from '@utils/files';
10
11
  import { resolveSchemaViewer } from './schema-viewer-utils';
11
12
 
12
- let schemas = [];
13
+ type ResolvedSchemaViewer = Awaited<ReturnType<typeof resolveSchemaViewer>>;
14
+
15
+ let schemas: ResolvedSchemaViewer[] = [];
13
16
 
14
17
  try {
15
18
  const absoluteFilePath = resolveProjectPath(filePath);
@@ -46,7 +49,7 @@ try {
46
49
  >
47
50
  {schema.title && <h2 class="text-2xl font-bold mb-2 mt-0!">{schema.title}</h2>}
48
51
 
49
- {/* Render AvroSchemaViewer for Avro schemas */}
52
+ {/* Render the viewer matching the schema format */}
50
53
  {schema.isAvroSchema ? (
51
54
  <AvroSchemaViewer
52
55
  client:load
@@ -56,6 +59,15 @@ try {
56
59
  search={schema.search}
57
60
  showRequired={schema.showRequired}
58
61
  />
62
+ ) : schema.isProtobufSchema ? (
63
+ <ProtobufSchemaViewer
64
+ client:load
65
+ schema={schema.schema}
66
+ maxHeight={schema.maxHeight}
67
+ expand={schema.expand}
68
+ search={schema.search}
69
+ showRequired={schema.showRequired}
70
+ />
59
71
  ) : (
60
72
  <JSONSchemaViewer
61
73
  client:load
@@ -33,6 +33,69 @@ describe('resolveSchemaViewer', () => {
33
33
  expect(schema.schemaPath).toBe('git://contracts/events/OrderPlaced.schema.json');
34
34
  });
35
35
 
36
+ it('parses protobuf schemas from the schema collection', async () => {
37
+ const protoSchema = {
38
+ id: 'schema:events:FraudCheckCompleted:1.0.0:git://contracts/events/FraudCheckCompleted.proto',
39
+ data: {
40
+ ref: 'git://contracts/events/FraudCheckCompleted.proto',
41
+ format: 'protobuf',
42
+ content: 'syntax = "proto3";\nmessage FraudCheckCompleted {\n string transaction_id = 1;\n}',
43
+ default: true,
44
+ message: {
45
+ collection: 'events',
46
+ id: 'FraudCheckCompleted',
47
+ version: '1.0.0',
48
+ },
49
+ },
50
+ };
51
+
52
+ const schema = await resolveSchemaViewer({
53
+ id: 'FraudCheckCompleted',
54
+ version: '1.0.0',
55
+ collection: 'events',
56
+ filePath: 'events/FraudCheckCompleted/index.mdx',
57
+ schemaViewerProps: {},
58
+ collectionSchemas: [protoSchema],
59
+ index: 0,
60
+ });
61
+
62
+ expect(schema.exists).toBe(true);
63
+ expect(schema.isProtobufSchema).toBe(true);
64
+ expect(schema.schema.syntax).toBe('proto3');
65
+ expect(schema.schema.messages[0].name).toBe('FraudCheckCompleted');
66
+ expect(schema.schema.messages[0].fields[0].name).toBe('transaction_id');
67
+ });
68
+
69
+ it('captures parse errors for invalid protobuf schemas', async () => {
70
+ const protoSchema = {
71
+ id: 'schema:events:FraudCheckCompleted:1.0.0:git://contracts/events/FraudCheckCompleted.proto',
72
+ data: {
73
+ ref: 'git://contracts/events/FraudCheckCompleted.proto',
74
+ format: 'protobuf',
75
+ content: '{"this": "is not protobuf"}',
76
+ default: true,
77
+ message: {
78
+ collection: 'events',
79
+ id: 'FraudCheckCompleted',
80
+ version: '1.0.0',
81
+ },
82
+ },
83
+ };
84
+
85
+ const schema = await resolveSchemaViewer({
86
+ id: 'FraudCheckCompleted',
87
+ version: '1.0.0',
88
+ collection: 'events',
89
+ filePath: 'events/FraudCheckCompleted/index.mdx',
90
+ schemaViewerProps: {},
91
+ collectionSchemas: [protoSchema],
92
+ index: 0,
93
+ });
94
+
95
+ expect(schema.exists).toBe(false);
96
+ expect(schema.parseError).toBeDefined();
97
+ });
98
+
36
99
  it('does not use the schema collection when a file is set and missing', async () => {
37
100
  const schema = await resolveSchemaViewer({
38
101
  id: 'OrderPlaced',
@@ -1,11 +1,17 @@
1
1
  import { readFile } from 'node:fs/promises';
2
2
  import { existsSync } from 'node:fs';
3
3
  import { load as loadYaml } from 'js-yaml';
4
- import { getAbsoluteFilePathForAstroFile, isAvroSchema } from '../../../utils/files';
4
+ import { getAbsoluteFilePathForAstroFile, isAvroSchema, isProtobufSchema } from '../../../utils/files';
5
+ import { parseProtobufSchema } from '../../../utils/protobuf-schema';
5
6
 
6
7
  type SchemaViewerProps = {
7
8
  id?: string;
8
9
  file?: string;
10
+ title?: string;
11
+ maxHeight?: string;
12
+ expand?: boolean;
13
+ search?: boolean;
14
+ showRequired?: boolean;
9
15
  [key: string]: any;
10
16
  };
11
17
 
@@ -48,13 +54,17 @@ const isYamlSchema = (schemaPath?: string, format?: string) =>
48
54
  const isAvroSchemaReference = (schemaPath?: string, format?: string) =>
49
55
  format === 'avro' || (schemaPath ? isAvroSchema(schemaPath) : false);
50
56
 
57
+ const isProtobufSchemaReference = (schemaPath?: string, format?: string) =>
58
+ format === 'protobuf' || format === 'proto' || (schemaPath ? isProtobufSchema(schemaPath) : false);
59
+
51
60
  const parseSchemaContent = (content: string, schemaPath?: string, format?: string) => {
61
+ if (isProtobufSchemaReference(schemaPath, format)) return parseProtobufSchema(content);
52
62
  if (isYamlSchema(schemaPath, format)) return loadYaml(content);
53
63
  return JSON.parse(content);
54
64
  };
55
65
 
56
- const shouldRenderSchema = (schema: any, isAvro: boolean) => {
57
- if (isAvro) return true;
66
+ const shouldRenderSchema = (schema: any, alwaysRender: boolean) => {
67
+ if (alwaysRender) return true;
58
68
  return schema?.['x-eventcatalog-render-schema-viewer'] !== undefined ? schema['x-eventcatalog-render-schema-viewer'] : true;
59
69
  };
60
70
 
@@ -94,14 +104,20 @@ export const resolveSchemaViewer = async ({
94
104
  let schema;
95
105
  let render = true;
96
106
  let isAvro = false;
107
+ let isProtobuf = false;
97
108
  let schemaPath = localSchemaPath;
98
109
  let parseError;
99
110
 
100
111
  if (localSchemaExists && localSchemaPath) {
101
112
  isAvro = isAvroSchema(localSchemaPath);
113
+ isProtobuf = isProtobufSchema(localSchemaPath);
102
114
  const content = await readFile(localSchemaPath, 'utf-8');
103
- schema = parseSchemaContent(content, localSchemaPath);
104
- render = shouldRenderSchema(schema, isAvro);
115
+ try {
116
+ schema = parseSchemaContent(content, localSchemaPath);
117
+ render = shouldRenderSchema(schema, isAvro || isProtobuf);
118
+ } catch (error) {
119
+ parseError = error instanceof Error ? error.message : 'Unknown parsing error';
120
+ }
105
121
  } else if (!schemaViewerProps.file) {
106
122
  const collectionSchema = getCollectionSchemaForViewer({ collectionSchemas, collection, id, version });
107
123
  const content = collectionSchema?.data.content;
@@ -110,8 +126,9 @@ export const resolveSchemaViewer = async ({
110
126
  if (content) {
111
127
  try {
112
128
  isAvro = isAvroSchemaReference(schemaPath, collectionSchema?.data.format);
129
+ isProtobuf = isProtobufSchemaReference(schemaPath, collectionSchema?.data.format);
113
130
  schema = parseSchemaContent(content, schemaPath, collectionSchema?.data.format);
114
- render = shouldRenderSchema(schema, isAvro);
131
+ render = shouldRenderSchema(schema, isAvro || isProtobuf);
115
132
  } catch (error) {
116
133
  parseError = error instanceof Error ? error.message : 'Unknown parsing error';
117
134
  }
@@ -120,11 +137,12 @@ export const resolveSchemaViewer = async ({
120
137
 
121
138
  return {
122
139
  id: schemaViewerProps.id || id,
123
- exists: localSchemaExists || schema !== undefined,
140
+ exists: schema !== undefined,
124
141
  schema,
125
142
  schemaPath,
126
143
  schemaKey,
127
144
  isAvroSchema: isAvro,
145
+ isProtobufSchema: isProtobuf,
128
146
  parseError,
129
147
  ...schemaViewerProps,
130
148
  render,