@eventcatalog/core 4.10.15 → 4.11.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/astro-output.cjs +60 -1
- package/dist/astro-output.js +1 -1
- package/dist/{chunk-U52FCZQ6.js → chunk-2YJRF4ZX.js} +1 -1
- package/dist/chunk-634NFV5U.js +75 -0
- package/dist/{chunk-I6HUOX4R.js → chunk-AXDNSGAN.js} +1 -1
- package/dist/chunk-DHH5U5PF.js +53 -0
- package/dist/{chunk-A4JRWRCV.js → chunk-DSCIWCX2.js} +1 -1
- package/dist/chunk-FWXEV4LF.js +19 -0
- package/dist/{chunk-Q2ATWE7N.js → chunk-GZVDXCYF.js} +1 -1
- package/dist/{chunk-7LWOCX4R.js → chunk-RYNPEIHQ.js} +1 -1
- package/dist/{chunk-HBVTU6ZP.js → chunk-YYVW4DCO.js} +1 -1
- package/dist/constants.cjs +1 -1
- package/dist/constants.js +1 -1
- package/dist/copy-core.cjs +88 -0
- package/dist/copy-core.d.cts +4 -0
- package/dist/copy-core.d.ts +4 -0
- package/dist/copy-core.js +8 -0
- package/dist/eventcatalog.cjs +234 -115
- package/dist/eventcatalog.js +36 -30
- package/dist/federation/federate.js +3 -3
- package/dist/federation/source-provider.js +2 -2
- package/dist/generate.cjs +1 -1
- package/dist/generate.js +3 -3
- package/dist/update-check.cjs +44 -0
- package/dist/update-check.d.cts +18 -0
- package/dist/update-check.d.ts +18 -0
- package/dist/update-check.js +8 -0
- package/dist/utils/cli-logger.cjs +1 -1
- package/dist/utils/cli-logger.js +2 -2
- package/eventcatalog/astro.config.mjs +8 -1
- package/eventcatalog/public/icons/languages/android.svg +1 -0
- package/eventcatalog/public/icons/languages/angular.svg +1 -0
- package/eventcatalog/public/icons/languages/apple.svg +1 -0
- package/eventcatalog/public/icons/languages/arduino.svg +1 -0
- package/eventcatalog/public/icons/languages/bash.svg +1 -0
- package/eventcatalog/public/icons/languages/bun.svg +1 -0
- package/eventcatalog/public/icons/languages/c.svg +1 -0
- package/eventcatalog/public/icons/languages/clojure.svg +1 -0
- package/eventcatalog/public/icons/languages/cpp.svg +1 -0
- package/eventcatalog/public/icons/languages/crystal.svg +1 -0
- package/eventcatalog/public/icons/languages/csharp.svg +1 -0
- package/eventcatalog/public/icons/languages/css.svg +1 -0
- package/eventcatalog/public/icons/languages/curl.svg +1 -0
- package/eventcatalog/public/icons/languages/dart.svg +1 -0
- package/eventcatalog/public/icons/languages/deno.svg +1 -0
- package/eventcatalog/public/icons/languages/docker.svg +1 -0
- package/eventcatalog/public/icons/languages/elm.svg +1 -0
- package/eventcatalog/public/icons/languages/erlang.svg +1 -0
- package/eventcatalog/public/icons/languages/flutter.svg +1 -0
- package/eventcatalog/public/icons/languages/fortran.svg +1 -0
- package/eventcatalog/public/icons/languages/fsharp.svg +1 -0
- package/eventcatalog/public/icons/languages/git.svg +1 -0
- package/eventcatalog/public/icons/languages/gradle.svg +1 -0
- package/eventcatalog/public/icons/languages/graphql.svg +1 -0
- package/eventcatalog/public/icons/languages/grpc.svg +1 -0
- package/eventcatalog/public/icons/languages/haskell.svg +1 -0
- package/eventcatalog/public/icons/languages/hasura.svg +1 -0
- package/eventcatalog/public/icons/languages/html.svg +1 -0
- package/eventcatalog/public/icons/languages/httpie.svg +1 -0
- package/eventcatalog/public/icons/languages/javascript.svg +1 -0
- package/eventcatalog/public/icons/languages/json-schema.svg +1 -0
- package/eventcatalog/public/icons/languages/json.svg +1 -0
- package/eventcatalog/public/icons/languages/julia.svg +1 -0
- package/eventcatalog/public/icons/languages/jupyter.svg +1 -0
- package/eventcatalog/public/icons/languages/kafka.svg +1 -0
- package/eventcatalog/public/icons/languages/kotlin.svg +1 -0
- package/eventcatalog/public/icons/languages/lua.svg +1 -0
- package/eventcatalog/public/icons/languages/markdown.svg +1 -0
- package/eventcatalog/public/icons/languages/maven.svg +1 -0
- package/eventcatalog/public/icons/languages/mongodb.svg +1 -0
- package/eventcatalog/public/icons/languages/mysql.svg +1 -0
- package/eventcatalog/public/icons/languages/nginx.svg +1 -0
- package/eventcatalog/public/icons/languages/nim.svg +1 -0
- package/eventcatalog/public/icons/languages/ocaml.svg +1 -0
- package/eventcatalog/public/icons/languages/perl.svg +1 -0
- package/eventcatalog/public/icons/languages/php.svg +1 -0
- package/eventcatalog/public/icons/languages/postgresql.svg +1 -0
- package/eventcatalog/public/icons/languages/prisma.svg +1 -0
- package/eventcatalog/public/icons/languages/purescript.svg +1 -0
- package/eventcatalog/public/icons/languages/python.svg +1 -0
- package/eventcatalog/public/icons/languages/r.svg +1 -0
- package/eventcatalog/public/icons/languages/react.svg +1 -0
- package/eventcatalog/public/icons/languages/reasonml.svg +1 -0
- package/eventcatalog/public/icons/languages/redis.svg +1 -0
- package/eventcatalog/public/icons/languages/ruby.svg +1 -0
- package/eventcatalog/public/icons/languages/rust.svg +1 -0
- package/eventcatalog/public/icons/languages/sass.svg +1 -0
- package/eventcatalog/public/icons/languages/scala.svg +1 -0
- package/eventcatalog/public/icons/languages/solidity.svg +1 -0
- package/eventcatalog/public/icons/languages/spring.svg +1 -0
- package/eventcatalog/public/icons/languages/sqlite.svg +1 -0
- package/eventcatalog/public/icons/languages/svelte.svg +1 -0
- package/eventcatalog/public/icons/languages/swagger.svg +1 -0
- package/eventcatalog/public/icons/languages/swift.svg +1 -0
- package/eventcatalog/public/icons/languages/tailwind.svg +1 -0
- package/eventcatalog/public/icons/languages/terraform.svg +1 -0
- package/eventcatalog/public/icons/languages/toml.svg +1 -0
- package/eventcatalog/public/icons/languages/typescript.svg +1 -0
- package/eventcatalog/public/icons/languages/unity.svg +1 -0
- package/eventcatalog/public/icons/languages/vim.svg +1 -0
- package/eventcatalog/public/icons/languages/vue.svg +1 -0
- package/eventcatalog/public/icons/languages/webassembly.svg +1 -0
- package/eventcatalog/public/icons/languages/yaml.svg +1 -0
- package/eventcatalog/public/icons/languages/zig.svg +1 -0
- package/eventcatalog/src/components/MDX/CodeGroup/CodeGroup.astro +12 -0
- package/eventcatalog/src/components/MDX/CodeGroup/CodeGroup.tsx +176 -0
- package/eventcatalog/src/components/MDX/CodeGroup/MarkdownCodeGroup.tsx +22 -0
- package/eventcatalog/src/components/MDX/CodeGroup/code-group-icons.ts +345 -0
- package/eventcatalog/src/components/MDX/CodeGroup/code-group.css +22 -0
- package/eventcatalog/src/components/MDX/CodeGroup/parse-panels.ts +11 -0
- package/eventcatalog/src/components/MDX/Columns/Column.astro +10 -0
- package/eventcatalog/src/components/MDX/Columns/Columns.astro +14 -0
- package/eventcatalog/src/components/MDX/Columns/MarkdownColumns.tsx +37 -0
- package/eventcatalog/src/components/MDX/Columns/layout.ts +16 -0
- package/eventcatalog/src/components/MDX/components.tsx +6 -0
- package/eventcatalog/src/components/SchemaExplorer/ApiContentViewer.tsx +1 -1
- package/eventcatalog/src/components/SchemaExplorer/ExamplesViewer.tsx +151 -114
- package/eventcatalog/src/components/SchemaExplorer/SchemaDetailsPanel.tsx +510 -248
- package/eventcatalog/src/components/SchemaExplorer/SchemaFlows.tsx +76 -0
- package/eventcatalog/src/components/SchemaExplorer/SchemaGraph.tsx +47 -0
- package/eventcatalog/src/components/SchemaExplorer/SchemaPageViewer.tsx +11 -0
- package/eventcatalog/src/components/SchemaExplorer/SchemaUsage.tsx +17 -0
- package/eventcatalog/src/components/SchemaExplorer/types.ts +48 -3
- package/eventcatalog/src/components/SchemaExplorer/utils.ts +28 -1
- package/eventcatalog/src/content.config.ts +28 -0
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/examples/[...filename].astro +38 -7
- package/eventcatalog/src/pages/schemas/[type]/[id]/[version]/index.astro +144 -37
- package/eventcatalog/src/pages/schemas/explorer/index.astro +5 -0
- package/eventcatalog/src/plugins/empty-collection-warning.d.ts +21 -0
- package/eventcatalog/src/plugins/empty-collection-warning.mjs +107 -0
- package/eventcatalog/src/plugins/quiet-empty-collections-logger.mjs +11 -0
- package/eventcatalog/src/remark-plugins/code-group.ts +39 -0
- package/eventcatalog/src/remark-plugins/markdown-code-group.ts +59 -0
- package/eventcatalog/src/remark-plugins/markdown-columns.ts +66 -0
- package/eventcatalog/src/utils/collections/channels.ts +12 -4
- package/eventcatalog/src/utils/collections/examples.ts +133 -41
- package/eventcatalog/src/utils/collections/flows.ts +43 -0
- package/eventcatalog/src/utils/collections/messages.ts +2 -2
- package/eventcatalog/src/utils/collections/schemas.ts +15 -0
- package/eventcatalog/src/utils/node-graphs/message-node-graph.ts +17 -15
- package/eventcatalog/src/utils/schema-explorer.ts +73 -7
- package/eventcatalog/src/utils/schema-usage-graph.ts +92 -0
- package/package.json +5 -4
- package/dist/chunk-RDYYZQYU.js +0 -18
- package/eventcatalog/src/components/EnvironmentDropdown.test.ts +0 -64
- package/eventcatalog/src/components/Grids/message-link.spec.ts +0 -59
- package/eventcatalog/src/components/MDX/CustomProperties/custom-properties.spec.ts +0 -38
- package/eventcatalog/src/components/MDX/SchemaViewer/schema-viewer-utils.spec.ts +0 -116
- package/eventcatalog/src/components/SchemaExplorer/JSONSchemaViewer.test.tsx +0 -114
- package/eventcatalog/src/components/SchemaExplorer/ProtobufSchemaViewer.test.tsx +0 -91
- package/eventcatalog/src/components/SchemaExplorer/SchemaViewerHover.test.tsx +0 -33
- package/eventcatalog/src/components/SchemaExplorer/protobuf-validation.test.ts +0 -84
- package/eventcatalog/src/components/Search/search-utils.spec.ts +0 -173
- package/eventcatalog/src/components/SideNav/NestedSideBar/utils.spec.ts +0 -105
- package/eventcatalog/src/components/navigation-progress.spec.ts +0 -68
- package/eventcatalog/src/enterprise/directory/user-team-directory.spec.ts +0 -527
- package/eventcatalog/src/enterprise/fields/field-extractor.test.ts +0 -302
- package/eventcatalog/src/enterprise/fields/fields-db.test.ts +0 -185
- package/eventcatalog/src/stores/eventcatalog-store.spec.ts +0 -60
- package/eventcatalog/src/utils/collections/glob-loader.spec.ts +0 -87
- package/dist/{chunk-6K7XZAYI.js → chunk-A2RZR3U4.js} +3 -3
|
@@ -1,527 +0,0 @@
|
|
|
1
|
-
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
-
import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
|
|
3
|
-
import { tmpdir } from 'node:os';
|
|
4
|
-
import path from 'node:path';
|
|
5
|
-
|
|
6
|
-
const localLoad = vi.fn();
|
|
7
|
-
const isEventCatalogScaleEnabled = vi.fn();
|
|
8
|
-
const consoleLog = vi.spyOn(console, 'log').mockImplementation(() => undefined);
|
|
9
|
-
|
|
10
|
-
vi.mock('astro/loaders', () => ({
|
|
11
|
-
glob: vi.fn(() => ({
|
|
12
|
-
name: 'mock-glob-loader',
|
|
13
|
-
load: localLoad,
|
|
14
|
-
})),
|
|
15
|
-
}));
|
|
16
|
-
|
|
17
|
-
vi.mock('../feature', () => ({
|
|
18
|
-
isEventCatalogScaleEnabled: () => isEventCatalogScaleEnabled(),
|
|
19
|
-
}));
|
|
20
|
-
|
|
21
|
-
import { userTeamDirectoryLoader } from './user-team-directory';
|
|
22
|
-
|
|
23
|
-
const createContentStore = () => {
|
|
24
|
-
const entries = new Map<string, unknown>();
|
|
25
|
-
|
|
26
|
-
return {
|
|
27
|
-
has: (id: string) => entries.has(id),
|
|
28
|
-
set: (entry: { id: string; [key: string]: unknown }) => entries.set(entry.id, entry),
|
|
29
|
-
get: (id: string) => entries.get(id),
|
|
30
|
-
clear: () => entries.clear(),
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const createContext = () => ({
|
|
35
|
-
store: createContentStore(),
|
|
36
|
-
meta: new Map<string, string>(),
|
|
37
|
-
parseData: vi.fn(async ({ data }) => data),
|
|
38
|
-
renderMarkdown: vi.fn(async (markdown) => ({
|
|
39
|
-
html: `<p>${markdown}</p>`,
|
|
40
|
-
metadata: {
|
|
41
|
-
headings: [],
|
|
42
|
-
localImagePaths: [],
|
|
43
|
-
remoteImagePaths: [],
|
|
44
|
-
frontmatter: {},
|
|
45
|
-
imagePaths: [],
|
|
46
|
-
},
|
|
47
|
-
})),
|
|
48
|
-
generateDigest: vi.fn((data) => JSON.stringify(data)),
|
|
49
|
-
logger: {
|
|
50
|
-
info: vi.fn(),
|
|
51
|
-
warn: vi.fn(),
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
describe('userTeamDirectoryLoader', () => {
|
|
56
|
-
beforeEach(() => {
|
|
57
|
-
localLoad.mockReset();
|
|
58
|
-
isEventCatalogScaleEnabled.mockReset();
|
|
59
|
-
isEventCatalogScaleEnabled.mockReturnValue(false);
|
|
60
|
-
consoleLog.mockClear();
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('loads local users without requiring EventCatalog Scale when no directory sources are configured', async () => {
|
|
64
|
-
const context = createContext();
|
|
65
|
-
const loader = userTeamDirectoryLoader({
|
|
66
|
-
collection: 'users',
|
|
67
|
-
local: {
|
|
68
|
-
pattern: 'users/*.(md|mdx)',
|
|
69
|
-
base: '/catalog',
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
await loader.load(context as never);
|
|
74
|
-
|
|
75
|
-
expect(localLoad).toHaveBeenCalledWith(context);
|
|
76
|
-
expect(isEventCatalogScaleEnabled).not.toHaveBeenCalled();
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('requires EventCatalog Scale when directory sources are configured', async () => {
|
|
80
|
-
const context = createContext();
|
|
81
|
-
const loader = userTeamDirectoryLoader({
|
|
82
|
-
collection: 'users',
|
|
83
|
-
local: {
|
|
84
|
-
pattern: 'users/*.(md|mdx)',
|
|
85
|
-
base: '/catalog',
|
|
86
|
-
},
|
|
87
|
-
storePath: false,
|
|
88
|
-
sources: [
|
|
89
|
-
{
|
|
90
|
-
type: 'directory',
|
|
91
|
-
name: 'test-source',
|
|
92
|
-
loadUsers: async () => [],
|
|
93
|
-
},
|
|
94
|
-
],
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
await expect(loader.load(context as never)).rejects.toThrow('Directory sources require EventCatalog Scale.');
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('loads users from configured directory sources', async () => {
|
|
101
|
-
isEventCatalogScaleEnabled.mockReturnValue(true);
|
|
102
|
-
const context = createContext();
|
|
103
|
-
const loader = userTeamDirectoryLoader({
|
|
104
|
-
collection: 'users',
|
|
105
|
-
local: {
|
|
106
|
-
pattern: 'users/*.(md|mdx)',
|
|
107
|
-
base: '/catalog',
|
|
108
|
-
},
|
|
109
|
-
storePath: false,
|
|
110
|
-
sources: [
|
|
111
|
-
{
|
|
112
|
-
type: 'directory',
|
|
113
|
-
name: 'test-source',
|
|
114
|
-
loadUsers: async () => [
|
|
115
|
-
{
|
|
116
|
-
id: 'jane',
|
|
117
|
-
name: 'Jane Doe',
|
|
118
|
-
avatarUrl: 'https://example.com/jane.png',
|
|
119
|
-
markdown: '# Jane',
|
|
120
|
-
source: {
|
|
121
|
-
provider: 'github',
|
|
122
|
-
id: 'github-user-123',
|
|
123
|
-
url: 'https://github.com/jane',
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
],
|
|
127
|
-
},
|
|
128
|
-
],
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
await loader.load(context as never);
|
|
132
|
-
|
|
133
|
-
expect(context.parseData).toHaveBeenCalledWith({
|
|
134
|
-
id: 'jane',
|
|
135
|
-
data: {
|
|
136
|
-
id: 'jane',
|
|
137
|
-
name: 'Jane Doe',
|
|
138
|
-
avatarUrl: 'https://example.com/jane.png',
|
|
139
|
-
source: {
|
|
140
|
-
provider: 'github',
|
|
141
|
-
id: 'github-user-123',
|
|
142
|
-
url: 'https://github.com/jane',
|
|
143
|
-
},
|
|
144
|
-
readOnly: true,
|
|
145
|
-
},
|
|
146
|
-
});
|
|
147
|
-
expect(context.store.get('jane')).toEqual({
|
|
148
|
-
id: 'jane',
|
|
149
|
-
data: {
|
|
150
|
-
id: 'jane',
|
|
151
|
-
name: 'Jane Doe',
|
|
152
|
-
avatarUrl: 'https://example.com/jane.png',
|
|
153
|
-
source: {
|
|
154
|
-
provider: 'github',
|
|
155
|
-
id: 'github-user-123',
|
|
156
|
-
url: 'https://github.com/jane',
|
|
157
|
-
},
|
|
158
|
-
readOnly: true,
|
|
159
|
-
},
|
|
160
|
-
body: '# Jane',
|
|
161
|
-
rendered: {
|
|
162
|
-
html: '<p># Jane</p>',
|
|
163
|
-
metadata: {
|
|
164
|
-
headings: [],
|
|
165
|
-
localImagePaths: [],
|
|
166
|
-
remoteImagePaths: [],
|
|
167
|
-
frontmatter: {},
|
|
168
|
-
imagePaths: [],
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
digest: JSON.stringify({
|
|
172
|
-
id: 'jane',
|
|
173
|
-
name: 'Jane Doe',
|
|
174
|
-
avatarUrl: 'https://example.com/jane.png',
|
|
175
|
-
source: {
|
|
176
|
-
provider: 'github',
|
|
177
|
-
id: 'github-user-123',
|
|
178
|
-
url: 'https://github.com/jane',
|
|
179
|
-
},
|
|
180
|
-
readOnly: true,
|
|
181
|
-
body: '# Jane',
|
|
182
|
-
}),
|
|
183
|
-
});
|
|
184
|
-
expect(consoleLog).toHaveBeenCalledWith(expect.stringContaining('Loading users from directory source "test-source"'));
|
|
185
|
-
expect(consoleLog).toHaveBeenCalledWith(expect.stringContaining('Synced 1 users from directory source "test-source"'));
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
it('keeps local entries when the conflict strategy is local-wins', async () => {
|
|
189
|
-
isEventCatalogScaleEnabled.mockReturnValue(true);
|
|
190
|
-
const context = createContext();
|
|
191
|
-
context.store.set({
|
|
192
|
-
id: 'jane',
|
|
193
|
-
data: {
|
|
194
|
-
id: 'jane',
|
|
195
|
-
name: 'Local Jane',
|
|
196
|
-
},
|
|
197
|
-
});
|
|
198
|
-
const loader = userTeamDirectoryLoader({
|
|
199
|
-
collection: 'users',
|
|
200
|
-
local: {
|
|
201
|
-
pattern: 'users/*.(md|mdx)',
|
|
202
|
-
base: '/catalog',
|
|
203
|
-
},
|
|
204
|
-
storePath: false,
|
|
205
|
-
sources: [
|
|
206
|
-
{
|
|
207
|
-
type: 'directory',
|
|
208
|
-
name: 'test-source',
|
|
209
|
-
loadUsers: async () => [
|
|
210
|
-
{
|
|
211
|
-
id: 'jane',
|
|
212
|
-
name: 'Source Jane',
|
|
213
|
-
avatarUrl: 'https://example.com/jane.png',
|
|
214
|
-
},
|
|
215
|
-
],
|
|
216
|
-
},
|
|
217
|
-
],
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
await loader.load(context as never);
|
|
221
|
-
|
|
222
|
-
expect(context.store.get('jane')).toEqual({
|
|
223
|
-
id: 'jane',
|
|
224
|
-
data: {
|
|
225
|
-
id: 'jane',
|
|
226
|
-
name: 'Local Jane',
|
|
227
|
-
},
|
|
228
|
-
});
|
|
229
|
-
expect(consoleLog).toHaveBeenCalledWith(
|
|
230
|
-
expect.stringContaining('Synced 0 users from directory source "test-source" (1 skipped due to local conflicts)')
|
|
231
|
-
);
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
it('throws when the conflict strategy is error and a source returns a local id', async () => {
|
|
235
|
-
isEventCatalogScaleEnabled.mockReturnValue(true);
|
|
236
|
-
const context = createContext();
|
|
237
|
-
context.store.set({
|
|
238
|
-
id: 'jane',
|
|
239
|
-
data: {
|
|
240
|
-
id: 'jane',
|
|
241
|
-
name: 'Local Jane',
|
|
242
|
-
},
|
|
243
|
-
});
|
|
244
|
-
const loader = userTeamDirectoryLoader({
|
|
245
|
-
collection: 'users',
|
|
246
|
-
local: {
|
|
247
|
-
pattern: 'users/*.(md|mdx)',
|
|
248
|
-
base: '/catalog',
|
|
249
|
-
},
|
|
250
|
-
conflictStrategy: 'error',
|
|
251
|
-
storePath: false,
|
|
252
|
-
sources: [
|
|
253
|
-
{
|
|
254
|
-
type: 'directory',
|
|
255
|
-
name: 'test-source',
|
|
256
|
-
loadUsers: async () => [
|
|
257
|
-
{
|
|
258
|
-
id: 'jane',
|
|
259
|
-
name: 'Source Jane',
|
|
260
|
-
avatarUrl: 'https://example.com/jane.png',
|
|
261
|
-
},
|
|
262
|
-
],
|
|
263
|
-
},
|
|
264
|
-
],
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
await expect(loader.load(context as never)).rejects.toThrow(
|
|
268
|
-
'Directory source "test-source" returned duplicate users id "jane".'
|
|
269
|
-
);
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
it('refreshes source entries on subsequent loads', async () => {
|
|
273
|
-
isEventCatalogScaleEnabled.mockReturnValue(true);
|
|
274
|
-
const context = createContext();
|
|
275
|
-
const loadUsers = vi
|
|
276
|
-
.fn()
|
|
277
|
-
.mockResolvedValueOnce([
|
|
278
|
-
{
|
|
279
|
-
id: 'jane',
|
|
280
|
-
name: 'Jane Doe',
|
|
281
|
-
avatarUrl: 'https://example.com/jane.png',
|
|
282
|
-
},
|
|
283
|
-
])
|
|
284
|
-
.mockResolvedValueOnce([
|
|
285
|
-
{
|
|
286
|
-
id: 'jane',
|
|
287
|
-
name: 'Jane Updated',
|
|
288
|
-
avatarUrl: 'https://example.com/jane-updated.png',
|
|
289
|
-
},
|
|
290
|
-
]);
|
|
291
|
-
const loader = userTeamDirectoryLoader({
|
|
292
|
-
collection: 'users',
|
|
293
|
-
local: {
|
|
294
|
-
pattern: 'users/*.(md|mdx)',
|
|
295
|
-
base: '/catalog',
|
|
296
|
-
},
|
|
297
|
-
storePath: false,
|
|
298
|
-
sources: [
|
|
299
|
-
{
|
|
300
|
-
type: 'directory',
|
|
301
|
-
name: 'test-source',
|
|
302
|
-
loadUsers,
|
|
303
|
-
},
|
|
304
|
-
],
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
await loader.load(context as never);
|
|
308
|
-
context.store.clear();
|
|
309
|
-
await loader.load(context as never);
|
|
310
|
-
|
|
311
|
-
expect(loadUsers).toHaveBeenCalledTimes(2);
|
|
312
|
-
expect(context.store.get('jane')).toMatchObject({
|
|
313
|
-
data: {
|
|
314
|
-
name: 'Jane Updated',
|
|
315
|
-
avatarUrl: 'https://example.com/jane-updated.png',
|
|
316
|
-
},
|
|
317
|
-
});
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
it('writes synced source entries to the EventCatalog directory store', async () => {
|
|
321
|
-
isEventCatalogScaleEnabled.mockReturnValue(true);
|
|
322
|
-
const context = createContext();
|
|
323
|
-
const tempDir = await mkdtemp(path.join(tmpdir(), 'eventcatalog-directory-store-'));
|
|
324
|
-
const storePath = path.join(tempDir, '.eventcatalog', 'store', 'directory.json');
|
|
325
|
-
const loader = userTeamDirectoryLoader({
|
|
326
|
-
collection: 'teams',
|
|
327
|
-
local: {
|
|
328
|
-
pattern: 'teams/*.(md|mdx)',
|
|
329
|
-
base: tempDir,
|
|
330
|
-
},
|
|
331
|
-
storePath,
|
|
332
|
-
sources: [
|
|
333
|
-
{
|
|
334
|
-
type: 'directory',
|
|
335
|
-
name: 'github:event-catalog',
|
|
336
|
-
loadTeams: async () => [
|
|
337
|
-
{
|
|
338
|
-
id: 'core-maintainers',
|
|
339
|
-
name: 'Core Maintainers',
|
|
340
|
-
markdown: '# Core Maintainers',
|
|
341
|
-
source: {
|
|
342
|
-
provider: 'github',
|
|
343
|
-
id: 'github-team-123',
|
|
344
|
-
url: 'https://github.com/orgs/event-catalog/teams/core-maintainers',
|
|
345
|
-
},
|
|
346
|
-
},
|
|
347
|
-
],
|
|
348
|
-
},
|
|
349
|
-
],
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
try {
|
|
353
|
-
await loader.load(context as never);
|
|
354
|
-
|
|
355
|
-
const store = JSON.parse(await readFile(storePath, 'utf8'));
|
|
356
|
-
expect(store).toMatchObject({
|
|
357
|
-
version: '1',
|
|
358
|
-
resources: {
|
|
359
|
-
users: [],
|
|
360
|
-
teams: [
|
|
361
|
-
{
|
|
362
|
-
id: 'core-maintainers',
|
|
363
|
-
name: 'Core Maintainers',
|
|
364
|
-
markdown: '# Core Maintainers',
|
|
365
|
-
readOnly: true,
|
|
366
|
-
source: {
|
|
367
|
-
provider: 'github',
|
|
368
|
-
id: 'github-team-123',
|
|
369
|
-
url: 'https://github.com/orgs/event-catalog/teams/core-maintainers',
|
|
370
|
-
},
|
|
371
|
-
},
|
|
372
|
-
],
|
|
373
|
-
},
|
|
374
|
-
});
|
|
375
|
-
expect(store.generatedAt).toEqual(expect.any(String));
|
|
376
|
-
} finally {
|
|
377
|
-
await rm(tempDir, { recursive: true, force: true });
|
|
378
|
-
}
|
|
379
|
-
});
|
|
380
|
-
|
|
381
|
-
it('deduplicates synced store entries when source-wins replaces an earlier directory source entry', async () => {
|
|
382
|
-
isEventCatalogScaleEnabled.mockReturnValue(true);
|
|
383
|
-
const context = createContext();
|
|
384
|
-
const tempDir = await mkdtemp(path.join(tmpdir(), 'eventcatalog-directory-store-'));
|
|
385
|
-
const storePath = path.join(tempDir, '.eventcatalog', 'store', 'directory.json');
|
|
386
|
-
const loader = userTeamDirectoryLoader({
|
|
387
|
-
collection: 'users',
|
|
388
|
-
local: {
|
|
389
|
-
pattern: 'users/*.(md|mdx)',
|
|
390
|
-
base: tempDir,
|
|
391
|
-
},
|
|
392
|
-
conflictStrategy: 'source-wins',
|
|
393
|
-
storePath,
|
|
394
|
-
sources: [
|
|
395
|
-
{
|
|
396
|
-
type: 'directory',
|
|
397
|
-
name: 'github:first',
|
|
398
|
-
loadUsers: async () => [
|
|
399
|
-
{
|
|
400
|
-
id: 'jane',
|
|
401
|
-
name: 'Jane From First Source',
|
|
402
|
-
markdown: 'First source Jane',
|
|
403
|
-
source: {
|
|
404
|
-
provider: 'github',
|
|
405
|
-
id: 'first-source-jane',
|
|
406
|
-
},
|
|
407
|
-
},
|
|
408
|
-
],
|
|
409
|
-
},
|
|
410
|
-
{
|
|
411
|
-
type: 'directory',
|
|
412
|
-
name: 'github:second',
|
|
413
|
-
loadUsers: async () => [
|
|
414
|
-
{
|
|
415
|
-
id: 'jane',
|
|
416
|
-
name: 'Jane From Second Source',
|
|
417
|
-
markdown: 'Second source Jane',
|
|
418
|
-
source: {
|
|
419
|
-
provider: 'github',
|
|
420
|
-
id: 'second-source-jane',
|
|
421
|
-
},
|
|
422
|
-
},
|
|
423
|
-
],
|
|
424
|
-
},
|
|
425
|
-
],
|
|
426
|
-
});
|
|
427
|
-
|
|
428
|
-
try {
|
|
429
|
-
await loader.load(context as never);
|
|
430
|
-
|
|
431
|
-
const store = JSON.parse(await readFile(storePath, 'utf8'));
|
|
432
|
-
expect(store.resources.users).toEqual([
|
|
433
|
-
{
|
|
434
|
-
id: 'jane',
|
|
435
|
-
name: 'Jane From Second Source',
|
|
436
|
-
markdown: 'Second source Jane',
|
|
437
|
-
readOnly: true,
|
|
438
|
-
source: {
|
|
439
|
-
provider: 'github',
|
|
440
|
-
id: 'second-source-jane',
|
|
441
|
-
},
|
|
442
|
-
},
|
|
443
|
-
]);
|
|
444
|
-
expect(context.store.get('jane')).toMatchObject({
|
|
445
|
-
data: {
|
|
446
|
-
id: 'jane',
|
|
447
|
-
name: 'Jane From Second Source',
|
|
448
|
-
source: {
|
|
449
|
-
provider: 'github',
|
|
450
|
-
id: 'second-source-jane',
|
|
451
|
-
},
|
|
452
|
-
readOnly: true,
|
|
453
|
-
},
|
|
454
|
-
body: 'Second source Jane',
|
|
455
|
-
});
|
|
456
|
-
} finally {
|
|
457
|
-
await rm(tempDir, { recursive: true, force: true });
|
|
458
|
-
}
|
|
459
|
-
});
|
|
460
|
-
|
|
461
|
-
it('clears an existing directory store collection when sources are removed', async () => {
|
|
462
|
-
const context = createContext();
|
|
463
|
-
const tempDir = await mkdtemp(path.join(tmpdir(), 'eventcatalog-directory-store-'));
|
|
464
|
-
const storePath = path.join(tempDir, '.eventcatalog', 'store', 'directory.json');
|
|
465
|
-
const loader = userTeamDirectoryLoader({
|
|
466
|
-
collection: 'users',
|
|
467
|
-
local: {
|
|
468
|
-
pattern: 'users/*.(md|mdx)',
|
|
469
|
-
base: tempDir,
|
|
470
|
-
},
|
|
471
|
-
storePath,
|
|
472
|
-
});
|
|
473
|
-
|
|
474
|
-
try {
|
|
475
|
-
await mkdir(path.dirname(storePath), { recursive: true });
|
|
476
|
-
await writeFile(
|
|
477
|
-
storePath,
|
|
478
|
-
JSON.stringify({
|
|
479
|
-
version: '1',
|
|
480
|
-
generatedAt: '2026-05-27T00:00:00.000Z',
|
|
481
|
-
resources: {
|
|
482
|
-
users: [
|
|
483
|
-
{
|
|
484
|
-
id: 'stale-user',
|
|
485
|
-
name: 'Stale User',
|
|
486
|
-
markdown: 'Stale directory user',
|
|
487
|
-
readOnly: true,
|
|
488
|
-
source: {
|
|
489
|
-
provider: 'github',
|
|
490
|
-
},
|
|
491
|
-
},
|
|
492
|
-
],
|
|
493
|
-
teams: [
|
|
494
|
-
{
|
|
495
|
-
id: 'existing-team',
|
|
496
|
-
name: 'Existing Team',
|
|
497
|
-
markdown: 'Existing directory team',
|
|
498
|
-
readOnly: true,
|
|
499
|
-
source: {
|
|
500
|
-
provider: 'github',
|
|
501
|
-
},
|
|
502
|
-
},
|
|
503
|
-
],
|
|
504
|
-
},
|
|
505
|
-
})
|
|
506
|
-
);
|
|
507
|
-
|
|
508
|
-
await loader.load(context as never);
|
|
509
|
-
|
|
510
|
-
const store = JSON.parse(await readFile(storePath, 'utf8'));
|
|
511
|
-
expect(store.resources.users).toEqual([]);
|
|
512
|
-
expect(store.resources.teams).toEqual([
|
|
513
|
-
{
|
|
514
|
-
id: 'existing-team',
|
|
515
|
-
name: 'Existing Team',
|
|
516
|
-
markdown: 'Existing directory team',
|
|
517
|
-
readOnly: true,
|
|
518
|
-
source: {
|
|
519
|
-
provider: 'github',
|
|
520
|
-
},
|
|
521
|
-
},
|
|
522
|
-
]);
|
|
523
|
-
} finally {
|
|
524
|
-
await rm(tempDir, { recursive: true, force: true });
|
|
525
|
-
}
|
|
526
|
-
});
|
|
527
|
-
});
|