@eventcatalog/sdk 2.11.0 → 2.12.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/README.md +86 -1
- package/dist/cli/index.d.mts +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/{eventcatalog.js → cli/index.js} +588 -378
- package/dist/cli/index.js.map +1 -0
- package/dist/{eventcatalog.mjs → cli/index.mjs} +666 -436
- package/dist/cli/index.mjs.map +1 -0
- package/dist/cli-docs.d.mts +43 -0
- package/dist/cli-docs.d.ts +43 -0
- package/dist/cli-docs.js +1614 -0
- package/dist/cli-docs.js.map +1 -0
- package/dist/cli-docs.mjs +1586 -0
- package/dist/cli-docs.mjs.map +1 -0
- package/dist/index.d.mts +443 -25
- package/dist/index.d.ts +443 -25
- package/dist/index.js +204 -121
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +204 -121
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -4
- package/dist/channels.d.mts +0 -214
- package/dist/channels.d.ts +0 -214
- package/dist/channels.js +0 -432
- package/dist/channels.js.map +0 -1
- package/dist/channels.mjs +0 -384
- package/dist/channels.mjs.map +0 -1
- package/dist/commands.d.mts +0 -274
- package/dist/commands.d.ts +0 -274
- package/dist/commands.js +0 -394
- package/dist/commands.js.map +0 -1
- package/dist/commands.mjs +0 -350
- package/dist/commands.mjs.map +0 -1
- package/dist/containers.d.mts +0 -179
- package/dist/containers.d.ts +0 -179
- package/dist/containers.js +0 -388
- package/dist/containers.js.map +0 -1
- package/dist/containers.mjs +0 -345
- package/dist/containers.mjs.map +0 -1
- package/dist/custom-docs.d.mts +0 -89
- package/dist/custom-docs.d.ts +0 -89
- package/dist/custom-docs.js +0 -164
- package/dist/custom-docs.js.map +0 -1
- package/dist/custom-docs.mjs +0 -122
- package/dist/custom-docs.mjs.map +0 -1
- package/dist/data-products.d.mts +0 -225
- package/dist/data-products.d.ts +0 -225
- package/dist/data-products.js +0 -375
- package/dist/data-products.js.map +0 -1
- package/dist/data-products.mjs +0 -332
- package/dist/data-products.mjs.map +0 -1
- package/dist/data-stores.d.mts +0 -179
- package/dist/data-stores.d.ts +0 -179
- package/dist/data-stores.js +0 -401
- package/dist/data-stores.js.map +0 -1
- package/dist/data-stores.mjs +0 -356
- package/dist/data-stores.mjs.map +0 -1
- package/dist/domains.d.mts +0 -347
- package/dist/domains.d.ts +0 -347
- package/dist/domains.js +0 -547
- package/dist/domains.js.map +0 -1
- package/dist/domains.mjs +0 -498
- package/dist/domains.mjs.map +0 -1
- package/dist/entities.d.mts +0 -174
- package/dist/entities.d.ts +0 -174
- package/dist/entities.js +0 -348
- package/dist/entities.js.map +0 -1
- package/dist/entities.mjs +0 -307
- package/dist/entities.mjs.map +0 -1
- package/dist/eventcatalog.d.mts +0 -21
- package/dist/eventcatalog.d.ts +0 -21
- package/dist/eventcatalog.js.map +0 -1
- package/dist/eventcatalog.mjs.map +0 -1
- package/dist/events.d.mts +0 -276
- package/dist/events.d.ts +0 -276
- package/dist/events.js +0 -393
- package/dist/events.js.map +0 -1
- package/dist/events.mjs +0 -349
- package/dist/events.mjs.map +0 -1
- package/dist/messages.d.mts +0 -65
- package/dist/messages.d.ts +0 -65
- package/dist/messages.js +0 -312
- package/dist/messages.js.map +0 -1
- package/dist/messages.mjs +0 -269
- package/dist/messages.mjs.map +0 -1
- package/dist/queries.d.mts +0 -276
- package/dist/queries.d.ts +0 -276
- package/dist/queries.js +0 -394
- package/dist/queries.js.map +0 -1
- package/dist/queries.mjs +0 -350
- package/dist/queries.mjs.map +0 -1
- package/dist/services.d.mts +0 -384
- package/dist/services.d.ts +0 -384
- package/dist/services.js +0 -577
- package/dist/services.js.map +0 -1
- package/dist/services.mjs +0 -526
- package/dist/services.mjs.map +0 -1
- package/dist/teams.d.mts +0 -90
- package/dist/teams.d.ts +0 -90
- package/dist/teams.js +0 -246
- package/dist/teams.js.map +0 -1
- package/dist/teams.mjs +0 -202
- package/dist/teams.mjs.map +0 -1
- package/dist/types.d.d.mts +0 -331
- package/dist/types.d.d.ts +0 -331
- package/dist/types.d.js +0 -19
- package/dist/types.d.js.map +0 -1
- package/dist/types.d.mjs +0 -1
- package/dist/types.d.mjs.map +0 -1
- package/dist/users.d.mts +0 -83
- package/dist/users.d.ts +0 -83
- package/dist/users.js +0 -127
- package/dist/users.js.map +0 -1
- package/dist/users.mjs +0 -88
- package/dist/users.mjs.map +0 -1
package/dist/entities.mjs
DELETED
|
@@ -1,307 +0,0 @@
|
|
|
1
|
-
// src/entities.ts
|
|
2
|
-
import fs2 from "node:fs/promises";
|
|
3
|
-
import { join as join3 } from "node:path";
|
|
4
|
-
|
|
5
|
-
// src/internal/utils.ts
|
|
6
|
-
import { globSync } from "glob";
|
|
7
|
-
import fsSync from "node:fs";
|
|
8
|
-
import { copy } from "fs-extra";
|
|
9
|
-
import { join, dirname, normalize, resolve, relative } from "node:path";
|
|
10
|
-
import matter from "gray-matter";
|
|
11
|
-
import { satisfies, validRange } from "semver";
|
|
12
|
-
var versionExists = async (catalogDir, id, version) => {
|
|
13
|
-
const files = await getFiles(`${catalogDir}/**/index.{md,mdx}`);
|
|
14
|
-
const matchedFiles = await searchFilesForId(files, id, version) || [];
|
|
15
|
-
return matchedFiles.length > 0;
|
|
16
|
-
};
|
|
17
|
-
var findFileById = async (catalogDir, id, version) => {
|
|
18
|
-
const files = await getFiles(`${catalogDir}/**/index.{md,mdx}`);
|
|
19
|
-
const matchedFiles = await searchFilesForId(files, id) || [];
|
|
20
|
-
const latestVersion = matchedFiles.find((path2) => !path2.includes("versioned"));
|
|
21
|
-
if (!version) {
|
|
22
|
-
return latestVersion;
|
|
23
|
-
}
|
|
24
|
-
const parsedFiles = matchedFiles.map((path2) => {
|
|
25
|
-
const { data } = matter.read(path2);
|
|
26
|
-
return { ...data, path: path2 };
|
|
27
|
-
});
|
|
28
|
-
if (version === "latest") {
|
|
29
|
-
return latestVersion;
|
|
30
|
-
}
|
|
31
|
-
const exactMatch = parsedFiles.find((c) => c.version === version);
|
|
32
|
-
if (exactMatch) {
|
|
33
|
-
return exactMatch.path;
|
|
34
|
-
}
|
|
35
|
-
const semverRange = validRange(version);
|
|
36
|
-
if (semverRange) {
|
|
37
|
-
const match = parsedFiles.filter((c) => {
|
|
38
|
-
try {
|
|
39
|
-
return satisfies(c.version, semverRange);
|
|
40
|
-
} catch (error) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
return match.length > 0 ? match[0].path : void 0;
|
|
45
|
-
}
|
|
46
|
-
return void 0;
|
|
47
|
-
};
|
|
48
|
-
var getFiles = async (pattern, ignore = "") => {
|
|
49
|
-
try {
|
|
50
|
-
const normalizedInputPattern = normalize(pattern);
|
|
51
|
-
const absoluteBaseDir = resolve(
|
|
52
|
-
normalizedInputPattern.includes("**") ? normalizedInputPattern.split("**")[0] : dirname(normalizedInputPattern)
|
|
53
|
-
);
|
|
54
|
-
let relativePattern = relative(absoluteBaseDir, normalizedInputPattern);
|
|
55
|
-
relativePattern = relativePattern.replace(/\\/g, "/");
|
|
56
|
-
const ignoreList = Array.isArray(ignore) ? ignore : [ignore];
|
|
57
|
-
const files = globSync(relativePattern, {
|
|
58
|
-
cwd: absoluteBaseDir,
|
|
59
|
-
ignore: ["node_modules/**", ...ignoreList],
|
|
60
|
-
absolute: true,
|
|
61
|
-
nodir: true
|
|
62
|
-
});
|
|
63
|
-
return files.map(normalize);
|
|
64
|
-
} catch (error) {
|
|
65
|
-
const absoluteBaseDirForError = resolve(
|
|
66
|
-
normalize(pattern).includes("**") ? normalize(pattern).split("**")[0] : dirname(normalize(pattern))
|
|
67
|
-
);
|
|
68
|
-
const relativePatternForError = relative(absoluteBaseDirForError, normalize(pattern)).replace(/\\/g, "/");
|
|
69
|
-
throw new Error(
|
|
70
|
-
`Error finding files for pattern "${pattern}" (using cwd: "${absoluteBaseDirForError}", globPattern: "${relativePatternForError}"): ${error.message}`
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
var searchFilesForId = async (files, id, version) => {
|
|
75
|
-
const escapedId = id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
76
|
-
const idRegex = new RegExp(`^id:\\s*(['"]|>-)?\\s*${escapedId}['"]?\\s*$`, "m");
|
|
77
|
-
const versionRegex = new RegExp(`^version:\\s*['"]?${version}['"]?\\s*$`, "m");
|
|
78
|
-
const matches = files.map((file) => {
|
|
79
|
-
const content = fsSync.readFileSync(file, "utf-8");
|
|
80
|
-
const hasIdMatch = content.match(idRegex);
|
|
81
|
-
if (version && !content.match(versionRegex)) {
|
|
82
|
-
return void 0;
|
|
83
|
-
}
|
|
84
|
-
if (hasIdMatch) {
|
|
85
|
-
return file;
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
return matches.filter(Boolean).filter((file) => file !== void 0);
|
|
89
|
-
};
|
|
90
|
-
var copyDir = async (catalogDir, source, target, filter) => {
|
|
91
|
-
const tmpDirectory = join(catalogDir, "tmp");
|
|
92
|
-
fsSync.mkdirSync(tmpDirectory, { recursive: true });
|
|
93
|
-
await copy(source, tmpDirectory, {
|
|
94
|
-
overwrite: true,
|
|
95
|
-
filter
|
|
96
|
-
});
|
|
97
|
-
await copy(tmpDirectory, target, {
|
|
98
|
-
overwrite: true,
|
|
99
|
-
filter
|
|
100
|
-
});
|
|
101
|
-
fsSync.rmSync(tmpDirectory, { recursive: true });
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
// src/internal/resources.ts
|
|
105
|
-
import { dirname as dirname2, join as join2 } from "path";
|
|
106
|
-
import matter2 from "gray-matter";
|
|
107
|
-
import fs from "node:fs/promises";
|
|
108
|
-
import fsSync2 from "node:fs";
|
|
109
|
-
import { satisfies as satisfies2 } from "semver";
|
|
110
|
-
import { lock, unlock } from "proper-lockfile";
|
|
111
|
-
import { basename as basename2 } from "node:path";
|
|
112
|
-
import path from "node:path";
|
|
113
|
-
var versionResource = async (catalogDir, id) => {
|
|
114
|
-
const files = await getFiles(`${catalogDir}/**/index.{md,mdx}`);
|
|
115
|
-
const matchedFiles = await searchFilesForId(files, id);
|
|
116
|
-
if (matchedFiles.length === 0) {
|
|
117
|
-
throw new Error(`No resource found with id: ${id}`);
|
|
118
|
-
}
|
|
119
|
-
const file = matchedFiles[0];
|
|
120
|
-
const sourceDirectory = dirname2(file).replace(/[/\\]versioned[/\\][^/\\]+[/\\]/, path.sep);
|
|
121
|
-
const { data: { version = "0.0.1" } = {} } = matter2.read(file);
|
|
122
|
-
const targetDirectory = getVersionedDirectory(sourceDirectory, version);
|
|
123
|
-
fsSync2.mkdirSync(targetDirectory, { recursive: true });
|
|
124
|
-
const ignoreListToCopy = ["events", "commands", "queries", "versioned"];
|
|
125
|
-
await copyDir(catalogDir, sourceDirectory, targetDirectory, (src) => {
|
|
126
|
-
const folderName = basename2(src);
|
|
127
|
-
if (ignoreListToCopy.includes(folderName)) {
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
return true;
|
|
131
|
-
});
|
|
132
|
-
await fs.readdir(sourceDirectory).then(async (resourceFiles) => {
|
|
133
|
-
await Promise.all(
|
|
134
|
-
resourceFiles.map(async (file2) => {
|
|
135
|
-
if (ignoreListToCopy.includes(file2)) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
if (file2 !== "versioned") {
|
|
139
|
-
fsSync2.rmSync(join2(sourceDirectory, file2), { recursive: true });
|
|
140
|
-
}
|
|
141
|
-
})
|
|
142
|
-
);
|
|
143
|
-
});
|
|
144
|
-
};
|
|
145
|
-
var writeResource = async (catalogDir, resource, options = {
|
|
146
|
-
path: "",
|
|
147
|
-
type: "",
|
|
148
|
-
override: false,
|
|
149
|
-
versionExistingContent: false,
|
|
150
|
-
format: "mdx"
|
|
151
|
-
}) => {
|
|
152
|
-
const path2 = options.path || `/${resource.id}`;
|
|
153
|
-
const fullPath = join2(catalogDir, path2);
|
|
154
|
-
const format = options.format || "mdx";
|
|
155
|
-
fsSync2.mkdirSync(fullPath, { recursive: true });
|
|
156
|
-
const lockPath = join2(fullPath, `index.${format}`);
|
|
157
|
-
if (!fsSync2.existsSync(lockPath)) {
|
|
158
|
-
fsSync2.writeFileSync(lockPath, "");
|
|
159
|
-
}
|
|
160
|
-
try {
|
|
161
|
-
await lock(lockPath, {
|
|
162
|
-
retries: 5,
|
|
163
|
-
stale: 1e4
|
|
164
|
-
// 10 seconds
|
|
165
|
-
});
|
|
166
|
-
const exists = await versionExists(catalogDir, resource.id, resource.version);
|
|
167
|
-
if (exists && !options.override) {
|
|
168
|
-
throw new Error(`Failed to write ${resource.id} (${options.type}) as the version ${resource.version} already exists`);
|
|
169
|
-
}
|
|
170
|
-
const { markdown, ...frontmatter } = resource;
|
|
171
|
-
if (options.versionExistingContent && !exists) {
|
|
172
|
-
const currentResource = await getResource(catalogDir, resource.id);
|
|
173
|
-
if (currentResource) {
|
|
174
|
-
if (satisfies2(resource.version, `>${currentResource.version}`)) {
|
|
175
|
-
await versionResource(catalogDir, resource.id);
|
|
176
|
-
} else {
|
|
177
|
-
throw new Error(`New version ${resource.version} is not greater than current version ${currentResource.version}`);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
const document = matter2.stringify(markdown.trim(), frontmatter);
|
|
182
|
-
fsSync2.writeFileSync(lockPath, document);
|
|
183
|
-
} finally {
|
|
184
|
-
await unlock(lockPath).catch(() => {
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
var getResource = async (catalogDir, id, version, options, filePath) => {
|
|
189
|
-
const attachSchema = options?.attachSchema || false;
|
|
190
|
-
const file = filePath || (id ? await findFileById(catalogDir, id, version) : void 0);
|
|
191
|
-
if (!file || !fsSync2.existsSync(file)) return;
|
|
192
|
-
const { data, content } = matter2.read(file);
|
|
193
|
-
if (attachSchema && data?.schemaPath) {
|
|
194
|
-
const resourceDirectory = dirname2(file);
|
|
195
|
-
const pathToSchema = join2(resourceDirectory, data.schemaPath);
|
|
196
|
-
if (fsSync2.existsSync(pathToSchema)) {
|
|
197
|
-
const schema = fsSync2.readFileSync(pathToSchema, "utf8");
|
|
198
|
-
try {
|
|
199
|
-
data.schema = JSON.parse(schema);
|
|
200
|
-
} catch (error) {
|
|
201
|
-
data.schema = schema;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
return {
|
|
206
|
-
...data,
|
|
207
|
-
markdown: content.trim()
|
|
208
|
-
};
|
|
209
|
-
};
|
|
210
|
-
var getResources = async (catalogDir, {
|
|
211
|
-
type,
|
|
212
|
-
latestOnly = false,
|
|
213
|
-
ignore = [],
|
|
214
|
-
pattern = "",
|
|
215
|
-
attachSchema = false
|
|
216
|
-
}) => {
|
|
217
|
-
const ignoreList = latestOnly ? `**/versioned/**` : "";
|
|
218
|
-
const filePattern = pattern || `${catalogDir}/**/${type}/**/index.{md,mdx}`;
|
|
219
|
-
const files = await getFiles(filePattern, [ignoreList, ...ignore]);
|
|
220
|
-
if (files.length === 0) return;
|
|
221
|
-
return files.map((file) => {
|
|
222
|
-
const { data, content } = matter2.read(file);
|
|
223
|
-
if (attachSchema && data?.schemaPath) {
|
|
224
|
-
const resourceDirectory = dirname2(file);
|
|
225
|
-
const pathToSchema = join2(resourceDirectory, data.schemaPath);
|
|
226
|
-
if (fsSync2.existsSync(pathToSchema)) {
|
|
227
|
-
const schema = fsSync2.readFileSync(pathToSchema, "utf8");
|
|
228
|
-
try {
|
|
229
|
-
data.schema = JSON.parse(schema);
|
|
230
|
-
} catch (error) {
|
|
231
|
-
data.schema = schema;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
return {
|
|
236
|
-
...data,
|
|
237
|
-
markdown: content.trim()
|
|
238
|
-
};
|
|
239
|
-
});
|
|
240
|
-
};
|
|
241
|
-
var rmResourceById = async (catalogDir, id, version, options) => {
|
|
242
|
-
const files = await getFiles(`${catalogDir}/**/index.{md,mdx}`);
|
|
243
|
-
const matchedFiles = await searchFilesForId(files, id, version);
|
|
244
|
-
if (matchedFiles.length === 0) {
|
|
245
|
-
throw new Error(`No ${options?.type || "resource"} found with id: ${id}`);
|
|
246
|
-
}
|
|
247
|
-
if (options?.persistFiles) {
|
|
248
|
-
await Promise.all(
|
|
249
|
-
matchedFiles.map(async (file) => {
|
|
250
|
-
await fs.rm(file, { recursive: true });
|
|
251
|
-
await waitForFileRemoval(file);
|
|
252
|
-
})
|
|
253
|
-
);
|
|
254
|
-
} else {
|
|
255
|
-
await Promise.all(
|
|
256
|
-
matchedFiles.map(async (file) => {
|
|
257
|
-
const directory = dirname2(file);
|
|
258
|
-
await fs.rm(directory, { recursive: true, force: true });
|
|
259
|
-
await waitForFileRemoval(directory);
|
|
260
|
-
})
|
|
261
|
-
);
|
|
262
|
-
}
|
|
263
|
-
};
|
|
264
|
-
var waitForFileRemoval = async (path2, maxRetries = 50, delay = 10) => {
|
|
265
|
-
for (let i = 0; i < maxRetries; i++) {
|
|
266
|
-
try {
|
|
267
|
-
await fs.access(path2);
|
|
268
|
-
await new Promise((resolve2) => setTimeout(resolve2, delay));
|
|
269
|
-
} catch (error) {
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
throw new Error(`File/directory ${path2} was not removed after ${maxRetries} attempts`);
|
|
274
|
-
};
|
|
275
|
-
var getVersionedDirectory = (sourceDirectory, version) => {
|
|
276
|
-
return join2(sourceDirectory, "versioned", version);
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
// src/entities.ts
|
|
280
|
-
var getEntity = (directory) => async (id, version) => getResource(directory, id, version, { type: "entity" });
|
|
281
|
-
var getEntities = (directory) => async (options) => getResources(directory, { type: "entities", latestOnly: options?.latestOnly });
|
|
282
|
-
var writeEntity = (directory) => async (entity, options = {
|
|
283
|
-
path: "",
|
|
284
|
-
override: false,
|
|
285
|
-
format: "mdx"
|
|
286
|
-
}) => writeResource(directory, { ...entity }, { ...options, type: "entity" });
|
|
287
|
-
var rmEntity = (directory) => async (path2) => {
|
|
288
|
-
await fs2.rm(join3(directory, path2), { recursive: true });
|
|
289
|
-
};
|
|
290
|
-
var rmEntityById = (directory) => async (id, version, persistFiles) => {
|
|
291
|
-
await rmResourceById(directory, id, version, { type: "entity", persistFiles });
|
|
292
|
-
};
|
|
293
|
-
var versionEntity = (directory) => async (id) => versionResource(directory, id);
|
|
294
|
-
var entityHasVersion = (directory) => async (id, version) => {
|
|
295
|
-
const file = await findFileById(directory, id, version);
|
|
296
|
-
return !!file;
|
|
297
|
-
};
|
|
298
|
-
export {
|
|
299
|
-
entityHasVersion,
|
|
300
|
-
getEntities,
|
|
301
|
-
getEntity,
|
|
302
|
-
rmEntity,
|
|
303
|
-
rmEntityById,
|
|
304
|
-
versionEntity,
|
|
305
|
-
writeEntity
|
|
306
|
-
};
|
|
307
|
-
//# sourceMappingURL=entities.mjs.map
|
package/dist/entities.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/entities.ts","../src/internal/utils.ts","../src/internal/resources.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport { join, dirname } from 'node:path';\nimport { findFileById } from './internal/utils';\nimport type { Entity } from './types';\nimport { getResource, getResources, rmResourceById, versionResource, writeResource } from './internal/resources';\n\n/**\n * Returns an entity from EventCatalog.\n *\n * You can optionally specify a version to get a specific version of the entity\n *\n * @example\n * ```ts\n * import utils from '@eventcatalog/utils';\n *\n * const { getEntity } = utils('/path/to/eventcatalog');\n *\n * // Gets the latest version of the entity\n * const entity = await getEntity('User');\n *\n * // Gets a version of the entity\n * const entity = await getEntity('User', '0.0.1');\n *\n * ```\n */\nexport const getEntity =\n (directory: string) =>\n async (id: string, version?: string): Promise<Entity> =>\n getResource(directory, id, version, { type: 'entity' }) as Promise<Entity>;\n\n/**\n * Returns all entities from EventCatalog.\n *\n * You can optionally specify if you want to get the latest version of the entities.\n *\n * @example\n * ```ts\n * import utils from '@eventcatalog/utils';\n *\n * const { getEntities } = utils('/path/to/eventcatalog');\n *\n * // Gets all entities (and versions) from the catalog\n * const entities = await getEntities();\n *\n * // Gets all entities (only latest version) from the catalog\n * const entities = await getEntities({ latestOnly: true });\n *\n * ```\n */\nexport const getEntities =\n (directory: string) =>\n async (options?: { latestOnly?: boolean }): Promise<Entity[]> =>\n getResources(directory, { type: 'entities', latestOnly: options?.latestOnly }) as Promise<Entity[]>;\n\n/**\n * Write an entity to EventCatalog.\n *\n * You can optionally override the path of the entity.\n *\n * @example\n * ```ts\n * import utils from '@eventcatalog/utils';\n *\n * const { writeEntity } = utils('/path/to/eventcatalog');\n *\n * // Write an entity to the catalog\n * // Entity would be written to entities/User\n * await writeEntity({\n * id: 'User',\n * name: 'User',\n * version: '0.0.1',\n * summary: 'User entity',\n * markdown: '# User entity',\n * });\n *\n * // Write an entity to the catalog but override the path\n * // Entity would be written to entities/Account/User\n * await writeEntity({\n * id: 'User',\n * name: 'User',\n * version: '0.0.1',\n * summary: 'User entity',\n * markdown: '# User entity',\n * }, { path: \"/Account/User\"});\n *\n * // Write an entity to the catalog and override the existing content (if there is any)\n * await writeEntity({\n * id: 'User',\n * name: 'User',\n * version: '0.0.1',\n * summary: 'User entity',\n * markdown: '# User entity',\n * }, { override: true });\n *\n * // Write an entity to the catalog and version the previous version\n * // only works if the new version is greater than the previous version\n * await writeEntity({\n * id: 'User',\n * name: 'User',\n * version: '0.0.1',\n * summary: 'User entity',\n * markdown: '# User entity',\n * }, { versionExistingContent: true });\n *\n * ```\n */\nexport const writeEntity =\n (directory: string) =>\n async (\n entity: Entity,\n options: { path?: string; override?: boolean; versionExistingContent?: boolean; format?: 'md' | 'mdx' } = {\n path: '',\n override: false,\n format: 'mdx',\n }\n ) =>\n writeResource(directory, { ...entity }, { ...options, type: 'entity' });\n\n/**\n * Delete an entity at its given path.\n *\n * @example\n * ```ts\n * import utils from '@eventcatalog/utils';\n *\n * const { rmEntity } = utils('/path/to/eventcatalog');\n *\n * // removes an entity at the given path (entities dir is appended to the given path)\n * // Removes the entity at entities/User\n * await rmEntity('/User');\n * ```\n */\nexport const rmEntity = (directory: string) => async (path: string) => {\n await fs.rm(join(directory, path), { recursive: true });\n};\n\n/**\n * Delete an entity by its id.\n *\n * Optionally specify a version to delete a specific version of the entity.\n *\n * @example\n * ```ts\n * import utils from '@eventcatalog/utils';\n *\n * const { rmEntityById } = utils('/path/to/eventcatalog');\n *\n * // deletes the latest User entity\n * await rmEntityById('User');\n *\n * // deletes a specific version of the User entity\n * await rmEntityById('User', '0.0.1');\n * ```\n */\nexport const rmEntityById = (directory: string) => async (id: string, version?: string, persistFiles?: boolean) => {\n await rmResourceById(directory, id, version, { type: 'entity', persistFiles });\n};\n\n/**\n * Version an entity by its id.\n *\n * Takes the latest entity and moves it to a versioned directory.\n * All files with this entity are also versioned (e.g /entities/User/schema.json)\n *\n * @example\n * ```ts\n * import utils from '@eventcatalog/utils';\n *\n * const { versionEntity } = utils('/path/to/eventcatalog');\n *\n * // moves the latest User entity to a versioned directory\n * // the version within that entity is used as the version number.\n * await versionEntity('User');\n *\n * ```\n */\nexport const versionEntity = (directory: string) => async (id: string) => versionResource(directory, id);\n\n/**\n * Check to see if the catalog has a version for the given entity.\n *\n * @example\n * ```ts\n * import utils from '@eventcatalog/utils';\n *\n * const { entityHasVersion } = utils('/path/to/eventcatalog');\n *\n * // returns true if version is found for the given entity and version (supports semver)\n * await entityHasVersion('User', '0.0.1');\n * await entityHasVersion('User', 'latest');\n * await entityHasVersion('User', '0.0.x');\n *\n * ```\n */\nexport const entityHasVersion = (directory: string) => async (id: string, version?: string) => {\n const file = await findFileById(directory, id, version);\n return !!file;\n};\n","import { globSync } from 'glob';\nimport fsSync from 'node:fs';\nimport { copy, CopyFilterAsync, CopyFilterSync } from 'fs-extra';\nimport { join, dirname, normalize, sep as pathSeparator, resolve, basename, relative } from 'node:path';\nimport matter from 'gray-matter';\nimport { satisfies, validRange, valid } from 'semver';\n\n/**\n * Returns true if a given version of a resource id exists in the catalog\n */\nexport const versionExists = async (catalogDir: string, id: string, version: string) => {\n const files = await getFiles(`${catalogDir}/**/index.{md,mdx}`);\n const matchedFiles = (await searchFilesForId(files, id, version)) || [];\n return matchedFiles.length > 0;\n};\n\nexport const findFileById = async (catalogDir: string, id: string, version?: string): Promise<string | undefined> => {\n const files = await getFiles(`${catalogDir}/**/index.{md,mdx}`);\n\n const matchedFiles = (await searchFilesForId(files, id)) || [];\n const latestVersion = matchedFiles.find((path) => !path.includes('versioned'));\n\n // If no version is provided, return the latest version\n if (!version) {\n return latestVersion;\n }\n\n // map files into gray matter to get versions\n const parsedFiles = matchedFiles.map((path) => {\n const { data } = matter.read(path);\n return { ...data, path };\n }) as any[];\n\n // Handle 'latest' version - return the latest (non-versioned) file\n if (version === 'latest') {\n return latestVersion;\n }\n\n // First, check for exact version match (handles non-semver versions like '1', '2', etc.)\n const exactMatch = parsedFiles.find((c) => c.version === version);\n if (exactMatch) {\n return exactMatch.path;\n }\n\n // Try semver range matching\n const semverRange = validRange(version);\n\n if (semverRange) {\n const match = parsedFiles.filter((c) => {\n try {\n return satisfies(c.version, semverRange);\n } catch (error) {\n // If satisfies fails (e.g., comparing semver range with non-semver version), skip this file\n return false;\n }\n });\n return match.length > 0 ? match[0].path : undefined;\n }\n\n // If no exact match and no valid semver range, return undefined\n return undefined;\n};\n\nexport const getFiles = async (pattern: string, ignore: string | string[] = '') => {\n try {\n // 1. Normalize the input pattern to handle mixed separators potentially\n const normalizedInputPattern = normalize(pattern);\n\n // 2. Determine the absolute base directory (cwd for glob)\n // Resolve ensures it's absolute. Handles cases with/without globstar.\n const absoluteBaseDir = resolve(\n normalizedInputPattern.includes('**') ? normalizedInputPattern.split('**')[0] : dirname(normalizedInputPattern)\n );\n\n // 3. Determine the pattern part relative to the absolute base directory\n // We extract the part of the normalized pattern that comes *after* the absoluteBaseDir\n let relativePattern = relative(absoluteBaseDir, normalizedInputPattern);\n\n // On Windows, relative() might return empty string if paths are identical,\n // or might need normalization if the original pattern didn't have `**`\n // Example: pattern = 'dir/file.md', absoluteBaseDir='.../dir', normalized='...\\dir\\file.md'\n // relative() -> 'file.md'\n // Example: pattern = 'dir/**/file.md', absoluteBaseDir='.../dir', normalized='...\\dir\\**\\file.md'\n // relative() -> '**\\file.md'\n // Convert separators in the relative pattern to forward slashes for glob\n relativePattern = relativePattern.replace(/\\\\/g, '/');\n\n const ignoreList = Array.isArray(ignore) ? ignore : [ignore];\n\n const files = globSync(relativePattern, {\n cwd: absoluteBaseDir,\n ignore: ['node_modules/**', ...ignoreList],\n absolute: true,\n nodir: true,\n });\n\n // 5. Normalize results for consistency before returning\n return files.map(normalize);\n } catch (error: any) {\n // Add more diagnostic info to the error\n const absoluteBaseDirForError = resolve(\n normalize(pattern).includes('**') ? normalize(pattern).split('**')[0] : dirname(normalize(pattern))\n );\n const relativePatternForError = relative(absoluteBaseDirForError, normalize(pattern)).replace(/\\\\/g, '/');\n throw new Error(\n `Error finding files for pattern \"${pattern}\" (using cwd: \"${absoluteBaseDirForError}\", globPattern: \"${relativePatternForError}\"): ${error.message}`\n );\n }\n};\n\nexport const readMdxFile = async (path: string) => {\n const { data } = matter.read(path);\n const { markdown, ...frontmatter } = data;\n return { ...frontmatter, markdown };\n};\n\nexport const searchFilesForId = async (files: string[], id: string, version?: string) => {\n // Escape the id to avoid regex issues\n const escapedId = id.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n const idRegex = new RegExp(`^id:\\\\s*(['\"]|>-)?\\\\s*${escapedId}['\"]?\\\\s*$`, 'm');\n\n const versionRegex = new RegExp(`^version:\\\\s*['\"]?${version}['\"]?\\\\s*$`, 'm');\n\n const matches = files.map((file) => {\n const content = fsSync.readFileSync(file, 'utf-8');\n const hasIdMatch = content.match(idRegex);\n\n // Check version if provided\n if (version && !content.match(versionRegex)) {\n return undefined;\n }\n\n if (hasIdMatch) {\n return file;\n }\n });\n\n return matches.filter(Boolean).filter((file) => file !== undefined);\n};\n\n/**\n * Function to copy a directory from source to target, uses a tmp directory\n * @param catalogDir\n * @param source\n * @param target\n * @param filter\n */\nexport const copyDir = async (catalogDir: string, source: string, target: string, filter?: CopyFilterAsync | CopyFilterSync) => {\n const tmpDirectory = join(catalogDir, 'tmp');\n fsSync.mkdirSync(tmpDirectory, { recursive: true });\n\n // Copy everything over\n await copy(source, tmpDirectory, {\n overwrite: true,\n filter,\n });\n\n await copy(tmpDirectory, target, {\n overwrite: true,\n filter,\n });\n\n // Remove the tmp directory\n fsSync.rmSync(tmpDirectory, { recursive: true });\n};\n\n// Makes sure values in sends/recieves are unique\nexport const uniqueVersions = (messages: { id: string; version: string }[]): { id: string; version: string }[] => {\n const uniqueSet = new Set();\n\n return messages.filter((message) => {\n const key = `${message.id}-${message.version}`;\n if (!uniqueSet.has(key)) {\n uniqueSet.add(key);\n return true;\n }\n return false;\n });\n};\n","import { dirname, join } from 'path';\nimport { copyDir, findFileById, getFiles, searchFilesForId, versionExists } from './utils';\nimport matter from 'gray-matter';\nimport fs from 'node:fs/promises';\nimport fsSync from 'node:fs';\nimport { Message, Service, CustomDoc } from '../types';\nimport { satisfies } from 'semver';\nimport { lock, unlock } from 'proper-lockfile';\nimport { basename } from 'node:path';\nimport path from 'node:path';\n\ntype Resource = Service | Message | CustomDoc;\n\nexport const versionResource = async (catalogDir: string, id: string) => {\n // Find all the events in the directory\n const files = await getFiles(`${catalogDir}/**/index.{md,mdx}`);\n const matchedFiles = await searchFilesForId(files, id);\n\n if (matchedFiles.length === 0) {\n throw new Error(`No resource found with id: ${id}`);\n }\n\n // Event that is in the route of the project\n const file = matchedFiles[0];\n // Handle both forward and back slashes for cross-platform compatibility (Windows uses \\, Unix uses /)\n const sourceDirectory = dirname(file).replace(/[/\\\\]versioned[/\\\\][^/\\\\]+[/\\\\]/, path.sep);\n const { data: { version = '0.0.1' } = {} } = matter.read(file);\n const targetDirectory = getVersionedDirectory(sourceDirectory, version);\n\n fsSync.mkdirSync(targetDirectory, { recursive: true });\n\n const ignoreListToCopy = ['events', 'commands', 'queries', 'versioned'];\n\n // Copy the event to the versioned directory\n await copyDir(catalogDir, sourceDirectory, targetDirectory, (src) => {\n // get the folder name\n const folderName = basename(src);\n\n if (ignoreListToCopy.includes(folderName)) {\n return false;\n }\n return true;\n });\n\n // Remove all the files in the root of the resource as they have now been versioned\n await fs.readdir(sourceDirectory).then(async (resourceFiles) => {\n await Promise.all(\n resourceFiles.map(async (file) => {\n // Dont remove anything in the ignore list\n if (ignoreListToCopy.includes(file)) {\n return;\n }\n if (file !== 'versioned') {\n fsSync.rmSync(join(sourceDirectory, file), { recursive: true });\n }\n })\n );\n });\n};\n\nexport const writeResource = async (\n catalogDir: string,\n resource: Resource,\n options: { path?: string; type: string; override?: boolean; versionExistingContent?: boolean; format?: 'md' | 'mdx' } = {\n path: '',\n type: '',\n override: false,\n versionExistingContent: false,\n format: 'mdx',\n }\n) => {\n const path = options.path || `/${resource.id}`;\n const fullPath = join(catalogDir, path);\n const format = options.format || 'mdx';\n\n // Create directory if it doesn't exist\n fsSync.mkdirSync(fullPath, { recursive: true });\n\n // Create or get lock file path\n const lockPath = join(fullPath, `index.${format}`);\n\n // Ensure the file exists before attempting to lock it\n if (!fsSync.existsSync(lockPath)) {\n fsSync.writeFileSync(lockPath, '');\n }\n\n try {\n // Acquire lock with retry\n await lock(lockPath, {\n retries: 5,\n stale: 10000, // 10 seconds\n });\n\n const exists = await versionExists(catalogDir, resource.id, resource.version);\n\n if (exists && !options.override) {\n throw new Error(`Failed to write ${resource.id} (${options.type}) as the version ${resource.version} already exists`);\n }\n\n const { markdown, ...frontmatter } = resource;\n\n if (options.versionExistingContent && !exists) {\n const currentResource = await getResource(catalogDir, resource.id);\n\n if (currentResource) {\n if (satisfies(resource.version, `>${currentResource.version}`)) {\n await versionResource(catalogDir, resource.id);\n } else {\n throw new Error(`New version ${resource.version} is not greater than current version ${currentResource.version}`);\n }\n }\n }\n\n const document = matter.stringify(markdown.trim(), frontmatter);\n fsSync.writeFileSync(lockPath, document);\n } finally {\n // Always release the lock\n await unlock(lockPath).catch(() => {});\n }\n};\n\nexport const getResource = async (\n catalogDir: string,\n id?: string,\n version?: string,\n options?: { type: string; attachSchema?: boolean },\n filePath?: string\n): Promise<Resource | undefined> => {\n const attachSchema = options?.attachSchema || false;\n const file = filePath || (id ? await findFileById(catalogDir, id, version) : undefined);\n if (!file || !fsSync.existsSync(file)) return;\n\n const { data, content } = matter.read(file);\n\n if (attachSchema && data?.schemaPath) {\n const resourceDirectory = dirname(file);\n const pathToSchema = join(resourceDirectory, data.schemaPath);\n if (fsSync.existsSync(pathToSchema)) {\n const schema = fsSync.readFileSync(pathToSchema, 'utf8');\n // Try to parse the schema\n try {\n data.schema = JSON.parse(schema);\n } catch (error) {\n data.schema = schema;\n }\n }\n }\n\n return {\n ...data,\n markdown: content.trim(),\n } as Resource;\n};\n\nexport const getResourcePath = async (catalogDir: string, id: string, version?: string) => {\n const file = await findFileById(catalogDir, id, version);\n if (!file) return;\n\n return {\n fullPath: file,\n relativePath: file.replace(catalogDir, ''),\n directory: dirname(file.replace(catalogDir, '')),\n };\n};\n\nexport const getResourceFolderName = async (catalogDir: string, id: string, version?: string) => {\n const paths = await getResourcePath(catalogDir, id, version);\n if (!paths) return;\n return paths?.directory.split(path.sep).filter(Boolean).pop();\n};\n\nexport const toResource = async (catalogDir: string, rawContents: string) => {\n const { data, content } = matter(rawContents);\n return {\n ...data,\n markdown: content.trim(),\n } as Resource;\n};\n\nexport const getResources = async (\n catalogDir: string,\n {\n type,\n latestOnly = false,\n ignore = [],\n pattern = '',\n attachSchema = false,\n }: { type: string; pattern?: string; latestOnly?: boolean; ignore?: string[]; attachSchema?: boolean }\n): Promise<Resource[] | undefined> => {\n const ignoreList = latestOnly ? `**/versioned/**` : '';\n const filePattern = pattern || `${catalogDir}/**/${type}/**/index.{md,mdx}`;\n const files = await getFiles(filePattern, [ignoreList, ...ignore]);\n\n if (files.length === 0) return;\n\n return files.map((file) => {\n const { data, content } = matter.read(file);\n\n // Attach the schema if the attachSchema option is set to true\n if (attachSchema && data?.schemaPath) {\n const resourceDirectory = dirname(file);\n const pathToSchema = join(resourceDirectory, data.schemaPath);\n if (fsSync.existsSync(pathToSchema)) {\n const schema = fsSync.readFileSync(pathToSchema, 'utf8');\n // Try to parse the schema\n try {\n data.schema = JSON.parse(schema);\n } catch (error) {\n data.schema = schema;\n }\n }\n }\n return {\n ...data,\n markdown: content.trim(),\n } as Resource;\n });\n};\n\nexport const rmResourceById = async (\n catalogDir: string,\n id: string,\n version?: string,\n options?: { type: string; persistFiles?: boolean }\n) => {\n const files = await getFiles(`${catalogDir}/**/index.{md,mdx}`);\n\n const matchedFiles = await searchFilesForId(files, id, version);\n\n if (matchedFiles.length === 0) {\n throw new Error(`No ${options?.type || 'resource'} found with id: ${id}`);\n }\n\n if (options?.persistFiles) {\n await Promise.all(\n matchedFiles.map(async (file) => {\n await fs.rm(file, { recursive: true });\n // Verify file is actually removed\n await waitForFileRemoval(file);\n })\n );\n } else {\n await Promise.all(\n matchedFiles.map(async (file) => {\n const directory = dirname(file);\n await fs.rm(directory, { recursive: true, force: true });\n // Verify directory is actually removed\n await waitForFileRemoval(directory);\n })\n );\n }\n};\n\n// Helper function to ensure file/directory is completely removed\nconst waitForFileRemoval = async (path: string, maxRetries: number = 50, delay: number = 10): Promise<void> => {\n for (let i = 0; i < maxRetries; i++) {\n try {\n await fs.access(path);\n // If access succeeds, file still exists, wait and retry\n await new Promise((resolve) => setTimeout(resolve, delay));\n } catch (error) {\n // If access fails, file is removed\n return;\n }\n }\n // If we reach here, file still exists after all retries\n throw new Error(`File/directory ${path} was not removed after ${maxRetries} attempts`);\n};\n\nexport const addFileToResource = async (\n catalogDir: string,\n id: string,\n file: { content: string; fileName: string },\n version?: string,\n options?: { path?: string }\n) => {\n let pathToResource: string | undefined;\n\n if (options?.path) {\n pathToResource = join(catalogDir, options.path, 'index.mdx');\n } else {\n // Fall back to global lookup (existing behavior)\n pathToResource = await findFileById(catalogDir, id, version);\n }\n\n if (!pathToResource) throw new Error('Cannot find directory to write file to');\n\n // Create the directory if it doesn't exist\n fsSync.mkdirSync(path.dirname(pathToResource), { recursive: true });\n\n let fileContent = file.content.trim();\n\n try {\n const json = JSON.parse(fileContent);\n fileContent = JSON.stringify(json, null, 2);\n } catch (error) {\n // Just silently fail if the file is not valid JSON\n // Write it as it is\n }\n\n fsSync.writeFileSync(join(dirname(pathToResource), file.fileName), fileContent);\n};\n\nexport const getFileFromResource = async (catalogDir: string, id: string, file: { fileName: string }, version?: string) => {\n const pathToResource = await findFileById(catalogDir, id, version);\n\n if (!pathToResource) throw new Error('Cannot find directory of resource');\n\n const exists = await fs\n .access(join(dirname(pathToResource), file.fileName))\n .then(() => true)\n .catch(() => false);\n if (!exists) throw new Error(`File ${file.fileName} does not exist in resource ${id} v(${version})`);\n\n return fsSync.readFileSync(join(dirname(pathToResource), file.fileName), 'utf-8');\n};\nexport const getVersionedDirectory = (sourceDirectory: string, version: any): string => {\n return join(sourceDirectory, 'versioned', version);\n};\n\nexport const isLatestVersion = async (catalogDir: string, id: string, version?: string) => {\n const resource = await getResource(catalogDir, id, version);\n if (!resource) return false;\n\n const pathToResource = await getResourcePath(catalogDir, id, version);\n\n return !pathToResource?.relativePath.replace(/\\\\/g, '/').includes('/versioned/');\n};\n"],"mappings":";AAAA,OAAOA,SAAQ;AACf,SAAS,QAAAC,aAAqB;;;ACD9B,SAAS,gBAAgB;AACzB,OAAO,YAAY;AACnB,SAAS,YAA6C;AACtD,SAAS,MAAM,SAAS,WAAiC,SAAmB,gBAAgB;AAC5F,OAAO,YAAY;AACnB,SAAS,WAAW,kBAAyB;AAKtC,IAAM,gBAAgB,OAAO,YAAoB,IAAY,YAAoB;AACtF,QAAM,QAAQ,MAAM,SAAS,GAAG,UAAU,oBAAoB;AAC9D,QAAM,eAAgB,MAAM,iBAAiB,OAAO,IAAI,OAAO,KAAM,CAAC;AACtE,SAAO,aAAa,SAAS;AAC/B;AAEO,IAAM,eAAe,OAAO,YAAoB,IAAY,YAAkD;AAC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AAM,aAAa,WAAW,IAAI,OAAO;AACtD,SAAO,CAAC,CAAC;AACX;","names":["fs","join","path","dirname","join","matter","fsSync","satisfies","basename","dirname","file","join","path","matter","dirname","join","fsSync","path","resolve","join","path","fs","join"]}
|
package/dist/eventcatalog.d.mts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { EventCatalog } from './types.d.mjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Returns the event catalog configuration file.
|
|
5
|
-
* The event catalog configuration file is the file that contains the configuration for the event catalog.
|
|
6
|
-
*
|
|
7
|
-
* @param directory - The directory of the catalog.
|
|
8
|
-
* @returns A JSON object with the configuration for the event catalog.
|
|
9
|
-
*/
|
|
10
|
-
declare const getEventCatalogConfigurationFile: (directory: string) => () => Promise<any>;
|
|
11
|
-
/**
|
|
12
|
-
* Dumps the catalog to a JSON file.
|
|
13
|
-
*
|
|
14
|
-
* @param directory - The directory of the catalog.
|
|
15
|
-
* @returns A JSON file with the catalog.
|
|
16
|
-
*/
|
|
17
|
-
declare const dumpCatalog: (directory: string) => (options?: {
|
|
18
|
-
includeMarkdown?: boolean;
|
|
19
|
-
}) => Promise<EventCatalog>;
|
|
20
|
-
|
|
21
|
-
export { dumpCatalog, getEventCatalogConfigurationFile };
|
package/dist/eventcatalog.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { EventCatalog } from './types.d.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Returns the event catalog configuration file.
|
|
5
|
-
* The event catalog configuration file is the file that contains the configuration for the event catalog.
|
|
6
|
-
*
|
|
7
|
-
* @param directory - The directory of the catalog.
|
|
8
|
-
* @returns A JSON object with the configuration for the event catalog.
|
|
9
|
-
*/
|
|
10
|
-
declare const getEventCatalogConfigurationFile: (directory: string) => () => Promise<any>;
|
|
11
|
-
/**
|
|
12
|
-
* Dumps the catalog to a JSON file.
|
|
13
|
-
*
|
|
14
|
-
* @param directory - The directory of the catalog.
|
|
15
|
-
* @returns A JSON file with the catalog.
|
|
16
|
-
*/
|
|
17
|
-
declare const dumpCatalog: (directory: string) => (options?: {
|
|
18
|
-
includeMarkdown?: boolean;
|
|
19
|
-
}) => Promise<EventCatalog>;
|
|
20
|
-
|
|
21
|
-
export { dumpCatalog, getEventCatalogConfigurationFile };
|