@eventcatalog/core 3.6.0 → 3.6.2

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.
@@ -0,0 +1,51 @@
1
+ import { findAndReplace } from 'mdast-util-find-and-replace';
2
+
3
+ /**
4
+ * Remark plugin that transforms [[type|Name]] or [[Name]] syntax into ResourceRef MDX components.
5
+ *
6
+ * Supported patterns:
7
+ * - [[entity|Order]] -> <ResourceRef type="entity">Order</ResourceRef>
8
+ * - [[service|OrderService@1.0.0]] -> <ResourceRef type="service" version="1.0.0">OrderService</ResourceRef>
9
+ * - [[diagram|target-architecture]] -> <ResourceRef type="diagram">target-architecture</ResourceRef>
10
+ * - [[Order]] -> <ResourceRef type="entity">Order</ResourceRef> (defaults to entity)
11
+ * - [[Order@0.0.1]] -> <ResourceRef type="entity" version="0.0.1">Order</ResourceRef>
12
+ */
13
+ export function remarkResourceRef() {
14
+ return function (tree: any) {
15
+ // First pass: match [[type|Name]] or [[type|Name@version]] pattern
16
+ findAndReplace(tree, [
17
+ /\[\[([a-z]+)\|([\w-]+)(?:@([\d.]+))?\]\]/g,
18
+ // @ts-ignore: Types are complex but it works
19
+ function (_match: string, type: string, resourceId: string, version?: string) {
20
+ const attributes: any[] = [{ type: 'mdxJsxAttribute', name: 'type', value: type }];
21
+ if (version) {
22
+ attributes.push({ type: 'mdxJsxAttribute', name: 'version', value: version });
23
+ }
24
+ return {
25
+ type: 'mdxJsxTextElement',
26
+ name: 'ResourceRef',
27
+ attributes,
28
+ children: [{ type: 'text', value: resourceId }],
29
+ };
30
+ },
31
+ ]);
32
+
33
+ // Second pass: match [[Name]] or [[Name@version]] pattern (defaults to entity)
34
+ findAndReplace(tree, [
35
+ /\[\[([\w-]+)(?:@([\d.]+))?\]\]/g,
36
+ // @ts-ignore: Types are complex but it works
37
+ function (_match: string, resourceId: string, version?: string) {
38
+ const attributes: any[] = [{ type: 'mdxJsxAttribute', name: 'type', value: 'entity' }];
39
+ if (version) {
40
+ attributes.push({ type: 'mdxJsxAttribute', name: 'version', value: version });
41
+ }
42
+ return {
43
+ type: 'mdxJsxTextElement',
44
+ name: 'ResourceRef',
45
+ attributes,
46
+ children: [{ type: 'text', value: resourceId }],
47
+ };
48
+ },
49
+ ]);
50
+ };
51
+ }
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": "3.6.0",
9
+ "version": "3.6.2",
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
@@ -73,7 +73,7 @@
73
73
  "elkjs": "^0.10.0",
74
74
  "glob": "^10.5.0",
75
75
  "gray-matter": "^4.0.3",
76
- "hono": "^4.11.3",
76
+ "hono": "^4.11.4",
77
77
  "html-to-image": "^1.11.11",
78
78
  "js-yaml": "^4.1.1",
79
79
  "jsonpath": "^1.1.1",
@@ -82,6 +82,7 @@
82
82
  "lodash.merge": "4.6.2",
83
83
  "lucide-react": "^0.453.0",
84
84
  "marked": "^15.0.6",
85
+ "mdast-util-find-and-replace": "^3.0.2",
85
86
  "mermaid": "^11.12.1",
86
87
  "nanostores": "^1.1.0",
87
88
  "pako": "^2.1.0",
@@ -157,6 +158,7 @@
157
158
  "release": "changeset publish",
158
159
  "format": "prettier --config .prettierrc --write \"**/*.{js,jsx,ts,tsx,json,astro}\"",
159
160
  "format:diff": "prettier --config .prettierrc --list-different \"**/*.{js,jsx,ts,tsx,json,astro}\"",
160
- "lint:catalog": "pnpm dlx @eventcatalog/linter examples/default"
161
+ "lint:catalog": "pnpm dlx @eventcatalog/linter examples/default",
162
+ "check": "node scripts/check-types.js"
161
163
  }
162
164
  }