@eventcatalog/core 2.6.2 → 2.6.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @eventcatalog/core
2
2
 
3
+ ## 2.6.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 0459eec: chore(core): fixed styled for openapi pages
8
+
9
+ ## 2.6.3
10
+
11
+ ### Patch Changes
12
+
13
+ - d35846b: chore(core): refactored the way pages are rendered reducing code
14
+
3
15
  ## 2.6.2
4
16
 
5
17
  ### Patch Changes
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@eventcatalog/core",
3
3
  "type": "module",
4
- "version": "2.6.2",
4
+ "version": "2.6.4",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -1,50 +1,40 @@
1
1
  ---
2
- import type { CollectionEntry } from 'astro:content';
3
- import type { CollectionTypes } from '@types';
4
2
  import path from 'path';
5
3
  import { readFileSync } from 'fs';
6
-
7
- import PlainPage from '@layouts/PlainPage.astro';
8
-
9
4
  import { createElement } from 'react';
10
5
  import { renderToString } from 'react-dom/server';
11
-
12
6
  import { Parser } from '@asyncapi/parser';
13
7
 
14
- import { getEvents } from '@utils/events';
15
- import { getServices } from '@utils/services/services';
16
- import { getCommands } from '@utils/commands';
17
- import { getDomains } from '@utils/domains/domains';
8
+ import type { CollectionTypes, PageTypes } from '@types';
9
+
10
+ import PlainPage from '@layouts/PlainPage.astro';
18
11
 
19
12
  import '@asyncapi/react-component/styles/default.min.css';
20
13
  import js from '@asyncapi/react-component/browser/standalone/without-parser.js?url';
21
14
  import { AsyncApiComponentWP, type ConfigInterface } from '@asyncapi/react-component';
15
+ import { pageDataLoader } from '@utils/pages/pages';
16
+ import type { CollectionEntry } from 'astro:content';
22
17
 
23
18
  export async function getStaticPaths() {
24
- const events = await getEvents();
25
- const commands = await getCommands();
26
- const services = await getServices();
27
- const domains = await getDomains();
19
+ const itemTypes: PageTypes[] = ['events', 'commands', 'services', 'domains'];
20
+ const allItems = await Promise.all(itemTypes.map((type) => pageDataLoader[type]()));
28
21
 
29
22
  const hasAsyncAPISpec = (item: CollectionEntry<CollectionTypes>) => item.data.specifications?.asyncapiPath !== undefined;
23
+ const filteredItems = allItems.map((items) => items.filter(hasAsyncAPISpec));
30
24
 
31
- const buildPages = (collection: CollectionEntry<CollectionTypes>[]) => {
32
- const filteredCollection = collection.filter(hasAsyncAPISpec);
33
-
34
- return filteredCollection.map((item) => ({
25
+ return filteredItems.flatMap((items, index) =>
26
+ items.map((item) => ({
35
27
  params: {
36
- type: item.collection,
37
28
  id: item.data.id,
29
+ type: itemTypes[index],
38
30
  version: item.data.version,
39
31
  },
40
32
  props: {
41
- type: item.collection,
33
+ type: itemTypes[index],
42
34
  ...item,
43
35
  },
44
- }));
45
- };
46
-
47
- return [...buildPages(domains), ...buildPages(events), ...buildPages(services), ...buildPages(commands)];
36
+ }))
37
+ );
48
38
  }
49
39
 
50
40
  // @ts-ignore
@@ -1,40 +1,31 @@
1
1
  ---
2
- import type { CollectionEntry } from 'astro:content';
3
-
4
2
  import Layout from '@layouts/DocsLayout.astro';
5
3
  import Footer from '@layouts/Footer.astro';
6
4
 
7
- import { getEvents } from '@utils/events';
8
- import { getServices } from '@utils/services/services';
9
- import { getCommands } from '@utils/commands';
10
- import { getDomains } from '@utils/domains/domains';
11
- import type { CollectionTypes } from '@types';
5
+ import type { PageTypes } from '@types';
12
6
  import { getChangeLogs } from '@utils/changelogs/changelogs';
13
7
  import { EnvelopeIcon, RectangleGroupIcon, ServerIcon } from '@heroicons/react/24/outline';
8
+ import { pageDataLoader } from '@utils/pages/pages';
14
9
 
15
10
  import { buildUrl } from '@utils/url-builder';
16
11
 
17
12
  export async function getStaticPaths() {
18
- const events = await getEvents();
19
- const commands = await getCommands();
20
- const services = await getServices();
21
- const domains = await getDomains();
13
+ const itemTypes: PageTypes[] = ['events', 'commands', 'services', 'domains'];
14
+ const allItems = await Promise.all(itemTypes.map((type) => pageDataLoader[type]()));
22
15
 
23
- const buildPages = (collection: CollectionEntry<CollectionTypes>[]) => {
24
- return collection.map((item) => ({
16
+ return allItems.flatMap((items, index) =>
17
+ items.map((item) => ({
25
18
  params: {
26
- type: item.collection,
19
+ type: itemTypes[index],
27
20
  id: item.data.id,
28
21
  version: item.data.version,
29
22
  },
30
23
  props: {
31
- type: item.collection,
24
+ type: itemTypes[index],
32
25
  ...item,
33
26
  },
34
- }));
35
- };
36
-
37
- return [...buildPages(domains), ...buildPages(events), ...buildPages(services), ...buildPages(commands)];
27
+ }))
28
+ );
38
29
  }
39
30
 
40
31
  const props = Astro.props;
@@ -1,5 +1,4 @@
1
1
  ---
2
- import type { CollectionEntry } from 'astro:content';
3
2
  import DocsLayout from '@layouts/DocsLayout.astro';
4
3
  import Footer from '@layouts/Footer.astro';
5
4
 
@@ -10,40 +9,39 @@ import SchemaViewer from '@components/MDX/SchemaViewer/SchemaViewer.astro';
10
9
  // SideBars
11
10
  import ServiceSideBar from '@components/SideBars/ServiceSideBar.astro';
12
11
  import MessageSideBar from '@components/SideBars/MessageSideBar.astro';
13
-
14
- import { getEvents } from '@utils/events';
15
- import { getServices } from '@utils/services/services';
16
- import { getCommands } from '@utils/commands';
17
- import { EnvelopeIcon, PencilIcon, QueueListIcon, RectangleGroupIcon, ServerIcon } from '@heroicons/react/24/outline';
18
- import { getDomains } from '@utils/domains/domains';
19
12
  import DomainSideBar from '@components/SideBars/DomainSideBar.astro';
20
- import type { CollectionTypes } from '@types';
13
+
14
+ import { EnvelopeIcon, QueueListIcon, RectangleGroupIcon, ServerIcon } from '@heroicons/react/24/outline';
15
+ import type { PageTypes } from '@types';
21
16
 
22
17
  import { buildUrl } from '@utils/url-builder';
23
18
  import { getFlows } from '@utils/flows/flows';
19
+ import { pageDataLoader } from '@utils/pages/pages';
20
+
21
+ type PageTypesWithFlows = PageTypes | 'flows';
24
22
 
25
23
  export async function getStaticPaths() {
26
- const events = await getEvents();
27
- const commands = await getCommands();
28
- const services = await getServices();
29
- const domains = await getDomains();
30
- const flows = await getFlows();
24
+ const loaders = {
25
+ ...pageDataLoader,
26
+ flows: getFlows,
27
+ };
31
28
 
32
- const buildPages = (collection: CollectionEntry<CollectionTypes>[]) => {
33
- return collection.map((item) => ({
29
+ const itemTypes: PageTypesWithFlows[] = ['events', 'commands', 'services', 'domains', 'flows'];
30
+ const allItems = await Promise.all(itemTypes.map((type) => loaders[type]()));
31
+
32
+ return allItems.flatMap((items, index) =>
33
+ items.map((item) => ({
34
34
  params: {
35
- type: item.collection,
35
+ type: itemTypes[index],
36
36
  id: item.data.id,
37
37
  version: item.data.version,
38
38
  },
39
39
  props: {
40
- type: item.collection,
40
+ type: itemTypes[index],
41
41
  ...item,
42
42
  },
43
- }));
44
- };
45
-
46
- return [...buildPages(domains), ...buildPages(events), ...buildPages(services), ...buildPages(commands), ...buildPages(flows)];
43
+ }))
44
+ );
47
45
  }
48
46
 
49
47
  const props = Astro.props;
@@ -3,40 +3,33 @@ import type { CollectionEntry } from 'astro:content';
3
3
  import * as path from 'path';
4
4
  import fs from 'node:fs';
5
5
 
6
- import { getEvents } from '@utils/events';
7
- import { getServices } from '@utils/services/services';
8
- import { getCommands } from '@utils/commands';
9
- import { getDomains } from '@utils/domains/domains';
10
- import type { CollectionTypes } from '@types';
6
+ import type { CollectionTypes, PageTypes } from '@types';
11
7
  import PlainPage from '@layouts/PlainPage.astro';
12
8
  import { DocumentMinusIcon } from '@heroicons/react/24/outline';
13
9
  import { buildUrl } from '@utils/url-builder';
10
+ import { pageDataLoader } from '@utils/pages/pages';
14
11
 
15
12
  export async function getStaticPaths() {
16
- const events = await getEvents();
17
- const commands = await getCommands();
18
- const services = await getServices();
19
- const domains = await getDomains();
13
+ const itemTypes: PageTypes[] = ['events', 'commands', 'services', 'domains'];
20
14
 
21
- const hasOpenAPISpec = (item: CollectionEntry<CollectionTypes>) => item.data.specifications?.openapiPath !== undefined;
15
+ const allItems = await Promise.all(itemTypes.map((type) => pageDataLoader[type]()));
22
16
 
23
- const buildPages = (collection: CollectionEntry<CollectionTypes>[]) => {
24
- const filteredCollection = collection.filter(hasOpenAPISpec);
17
+ const hasOpenAPISpec = (item: CollectionEntry<CollectionTypes>) => item.data.specifications?.openapiPath !== undefined;
18
+ const filteredItems = allItems.map((items) => items.filter(hasOpenAPISpec));
25
19
 
26
- return filteredCollection.map((item) => ({
20
+ return filteredItems.flatMap((items, index) =>
21
+ items.map((item) => ({
27
22
  params: {
28
- type: item.collection,
23
+ type: itemTypes[index],
29
24
  id: item.data.id,
30
25
  version: item.data.version,
31
26
  },
32
27
  props: {
33
- type: item.collection,
28
+ type: itemTypes[index],
34
29
  ...item,
35
30
  },
36
- }));
37
- };
38
-
39
- return [...buildPages(domains), ...buildPages(events), ...buildPages(services), ...buildPages(commands)];
31
+ }))
32
+ );
40
33
  }
41
34
 
42
35
  // @ts-ignore
@@ -60,16 +53,24 @@ const fileExists = fs.existsSync(pathOnDisk);
60
53
  ) : (
61
54
  <rapi-doc
62
55
  spec-url={buildUrl(pathToSpec, true)}
63
- render-style="table"
64
56
  show-header="false"
65
- allow-authentication="false"
66
- allow-try="false"
67
- style={{ height: '100vh', width: '100%' }}
68
- class="py-4"
69
- nav-bg-color="#fff"
57
+ allow-authentication="true"
58
+ allow-try="true"
59
+ class="relative top-0"
60
+ style={{ height: '100vh', width: '100%', zIndex: 100 }}
61
+ regular-font="ui-sans-serif, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji"
70
62
  schema-style="table"
71
- primary-color="#e0baff"
72
- bg-color="#fff"
63
+ default-schema-tab="schema"
64
+ bg-color="#ffffff"
65
+ text-color=""
66
+ nav-bg-color="#fff"
67
+ nav-text-color=""
68
+ nav-hover-bg-color="#fff"
69
+ nav-hover-text-color="#6b21a8"
70
+ nav-accent-color=""
71
+ primary-color="#6b21a8"
72
+ theme="light"
73
+ render-style="read"
73
74
  />
74
75
  )
75
76
  }
@@ -83,13 +84,44 @@ const fileExists = fs.existsSync(pathOnDisk);
83
84
  <style>
84
85
  rapi-doc::part(section-servers) {
85
86
  /* <<< targets the server div */
86
- background: #6b5b95;
87
- color: #d1c2e4;
87
+ /* background: #6b5b95; */
88
+ border: 2px solid #f1edff;
89
+ color: black;
88
90
  margin: 0 24px 0 24px;
89
91
  border-radius: 5px;
90
92
  }
91
93
  rapi-doc::part(label-selected-server) {
92
94
  /* <<< targets selected server label */
93
- color: #fff;
95
+ color: black;
96
+ }
97
+
98
+ rapi-doc::part(section-navbar-search) {
99
+ margin: 0;
100
+ padding: 0;
101
+ margin-bottom: 1em;
102
+ }
103
+ rapi-doc::part(section-overview) {
104
+ margin: 0 2em 0 2em;
105
+ padding: 1em 0 1em;
106
+ }
107
+ rapi-doc::part(section-auth) {
108
+ margin: 2em 2em;
109
+ padding: 0;
110
+ }
111
+ rapi-doc::part(section-tag) {
112
+ margin: 2em 2em;
113
+ padding: 0;
114
+ }
115
+ rapi-doc::part(section-tag-title) {
116
+ margin: 0.5em 0 0;
117
+ padding: 0;
118
+ }
119
+ rapi-doc::part(section-operations-in-tag) {
120
+ margin: 1em 2em;
121
+ padding: 0;
122
+ }
123
+ rapi-doc::part(section-navbar) {
124
+ border-right: 1px solid #f1edff;
125
+ padding: 1em 1em 0 0;
94
126
  }
95
127
  </style>
@@ -1,39 +1,35 @@
1
1
  ---
2
2
  import NodeGraph from '@components/MDX/NodeGraph/NodeGraph.astro';
3
3
  import VisualiserLayout from '@layouts/VisualiserLayout.astro';
4
- import type { CollectionTypes } from '@types';
5
- import { getCommands } from '@utils/commands';
6
- import { getDomains } from '@utils/domains/domains';
7
- import { getEvents } from '@utils/events';
4
+ import type { PageTypes } from '@types';
8
5
  import { getFlows } from '@utils/flows/flows';
9
- import { getServices } from '@utils/services/services';
10
6
  import { buildUrl } from '@utils/url-builder';
11
- import type { CollectionEntry } from 'astro:content';
7
+
8
+ import { pageDataLoader } from '@utils/pages/pages';
9
+ type PageTypesWithFlows = PageTypes | 'flows';
12
10
 
13
11
  export async function getStaticPaths() {
14
- const [services, events, commands, domains, flows] = await Promise.all([
15
- getServices(),
16
- getEvents(),
17
- getCommands(),
18
- getDomains(),
19
- getFlows(),
20
- ]);
12
+ const loaders = {
13
+ ...pageDataLoader,
14
+ flows: getFlows,
15
+ };
16
+
17
+ const itemTypes: PageTypesWithFlows[] = ['events', 'commands', 'services', 'domains', 'flows'];
18
+ const allItems = await Promise.all(itemTypes.map((type) => loaders[type]()));
21
19
 
22
- const buildPages = (collection: CollectionEntry<CollectionTypes>[]) => {
23
- return collection.map((item) => ({
20
+ return allItems.flatMap((items, index) =>
21
+ items.map((item) => ({
24
22
  params: {
25
- type: item.collection,
23
+ type: itemTypes[index],
26
24
  id: item.data.id,
27
25
  version: item.data.version,
28
26
  },
29
27
  props: {
30
- type: item.collection,
28
+ type: itemTypes[index],
31
29
  ...item,
32
30
  },
33
- }));
34
- };
35
-
36
- return [...buildPages(services), ...buildPages(events), ...buildPages(commands), ...buildPages(domains), ...buildPages(flows)];
31
+ }))
32
+ );
37
33
  }
38
34
 
39
35
  const props = Astro.props;
@@ -1,2 +1,4 @@
1
1
  export type CollectionTypes = 'commands' | 'events' | 'domains' | 'services' | 'flows';
2
2
  export type CollectionMessageTypes = 'commands' | 'events';
3
+
4
+ export type PageTypes = 'events' | 'commands' | 'services' | 'domains';
@@ -1,7 +1,13 @@
1
- // // import type { Domain, Message } from '@eventcatalog/types';
2
- // import { getCollection, } from 'astro:content';
1
+ // Exporting getCommands and getEvents directly
2
+ import { getCommands } from '@utils/commands';
3
+ import { getEvents } from '@utils/events';
4
+ export { getCommands } from '@utils/commands';
5
+ export { getEvents } from '@utils/events';
3
6
 
4
- // export const getMessages = async (): Promise<Message[]> => {
5
- // const commands = await getCollection('commands');
6
- // return commands.map((message: any) => message.data);
7
- // };
7
+ // Main function that uses the imported functions
8
+ export const getMessages = async () => {
9
+ const commands = await getCommands();
10
+ const events = await getEvents();
11
+
12
+ return { commands, events };
13
+ };
@@ -0,0 +1,12 @@
1
+ import type { CollectionTypes, PageTypes } from '@types';
2
+ import { getDomains } from '@utils/domains/domains';
3
+ import { getCommands, getEvents } from '@utils/messages';
4
+ import { getServices } from '@utils/services/services';
5
+ import type { CollectionEntry } from 'astro:content';
6
+
7
+ export const pageDataLoader: Record<PageTypes, () => Promise<CollectionEntry<CollectionTypes>[]>> = {
8
+ events: getEvents,
9
+ commands: getCommands,
10
+ services: getServices,
11
+ domains: getDomains,
12
+ };