@eventcatalog/sdk 2.12.1 → 2.13.0

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/index.js DELETED
@@ -1,2434 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
33
- default: () => src_default
34
- });
35
- module.exports = __toCommonJS(src_exports);
36
- var import_node_path20 = require("path");
37
-
38
- // src/events.ts
39
- var import_promises2 = __toESM(require("fs/promises"));
40
- var import_node_path4 = require("path");
41
-
42
- // src/internal/utils.ts
43
- var import_glob = require("glob");
44
- var import_node_fs = __toESM(require("fs"));
45
- var import_fs_extra = require("fs-extra");
46
- var import_node_path = require("path");
47
- var import_gray_matter = __toESM(require("gray-matter"));
48
- var import_semver = require("semver");
49
- var versionExists = async (catalogDir, id, version) => {
50
- const files = await getFiles(`${catalogDir}/**/index.{md,mdx}`);
51
- const matchedFiles = await searchFilesForId(files, id, version) || [];
52
- return matchedFiles.length > 0;
53
- };
54
- var findFileById = async (catalogDir, id, version) => {
55
- const files = await getFiles(`${catalogDir}/**/index.{md,mdx}`);
56
- const matchedFiles = await searchFilesForId(files, id) || [];
57
- const latestVersion = matchedFiles.find((path6) => !path6.includes("versioned"));
58
- if (!version) {
59
- return latestVersion;
60
- }
61
- const parsedFiles = matchedFiles.map((path6) => {
62
- const { data } = import_gray_matter.default.read(path6);
63
- return { ...data, path: path6 };
64
- });
65
- if (version === "latest") {
66
- return latestVersion;
67
- }
68
- const exactMatch = parsedFiles.find((c) => c.version === version);
69
- if (exactMatch) {
70
- return exactMatch.path;
71
- }
72
- const semverRange = (0, import_semver.validRange)(version);
73
- if (semverRange) {
74
- const match = parsedFiles.filter((c) => {
75
- try {
76
- return (0, import_semver.satisfies)(c.version, semverRange);
77
- } catch (error) {
78
- return false;
79
- }
80
- });
81
- return match.length > 0 ? match[0].path : void 0;
82
- }
83
- return void 0;
84
- };
85
- var getFiles = async (pattern, ignore = "") => {
86
- try {
87
- const normalizedInputPattern = (0, import_node_path.normalize)(pattern);
88
- const absoluteBaseDir = (0, import_node_path.resolve)(
89
- normalizedInputPattern.includes("**") ? normalizedInputPattern.split("**")[0] : (0, import_node_path.dirname)(normalizedInputPattern)
90
- );
91
- let relativePattern = (0, import_node_path.relative)(absoluteBaseDir, normalizedInputPattern);
92
- relativePattern = relativePattern.replace(/\\/g, "/");
93
- const ignoreList = Array.isArray(ignore) ? ignore : [ignore];
94
- const files = (0, import_glob.globSync)(relativePattern, {
95
- cwd: absoluteBaseDir,
96
- ignore: ["node_modules/**", ...ignoreList],
97
- absolute: true,
98
- nodir: true
99
- });
100
- return files.map(import_node_path.normalize);
101
- } catch (error) {
102
- const absoluteBaseDirForError = (0, import_node_path.resolve)(
103
- (0, import_node_path.normalize)(pattern).includes("**") ? (0, import_node_path.normalize)(pattern).split("**")[0] : (0, import_node_path.dirname)((0, import_node_path.normalize)(pattern))
104
- );
105
- const relativePatternForError = (0, import_node_path.relative)(absoluteBaseDirForError, (0, import_node_path.normalize)(pattern)).replace(/\\/g, "/");
106
- throw new Error(
107
- `Error finding files for pattern "${pattern}" (using cwd: "${absoluteBaseDirForError}", globPattern: "${relativePatternForError}"): ${error.message}`
108
- );
109
- }
110
- };
111
- var readMdxFile = async (path6) => {
112
- const { data } = import_gray_matter.default.read(path6);
113
- const { markdown, ...frontmatter } = data;
114
- return { ...frontmatter, markdown };
115
- };
116
- var searchFilesForId = async (files, id, version) => {
117
- const escapedId = id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
118
- const idRegex = new RegExp(`^id:\\s*(['"]|>-)?\\s*${escapedId}['"]?\\s*$`, "m");
119
- const versionRegex = new RegExp(`^version:\\s*['"]?${version}['"]?\\s*$`, "m");
120
- const matches = files.map((file) => {
121
- const content = import_node_fs.default.readFileSync(file, "utf-8");
122
- const hasIdMatch = content.match(idRegex);
123
- if (version && !content.match(versionRegex)) {
124
- return void 0;
125
- }
126
- if (hasIdMatch) {
127
- return file;
128
- }
129
- });
130
- return matches.filter(Boolean).filter((file) => file !== void 0);
131
- };
132
- var copyDir = async (catalogDir, source, target, filter) => {
133
- const tmpDirectory = (0, import_node_path.join)(catalogDir, "tmp");
134
- import_node_fs.default.mkdirSync(tmpDirectory, { recursive: true });
135
- await (0, import_fs_extra.copy)(source, tmpDirectory, {
136
- overwrite: true,
137
- filter
138
- });
139
- await (0, import_fs_extra.copy)(tmpDirectory, target, {
140
- overwrite: true,
141
- filter
142
- });
143
- import_node_fs.default.rmSync(tmpDirectory, { recursive: true });
144
- };
145
- var uniqueVersions = (messages) => {
146
- const uniqueSet = /* @__PURE__ */ new Set();
147
- return messages.filter((message) => {
148
- const key = `${message.id}-${message.version}`;
149
- if (!uniqueSet.has(key)) {
150
- uniqueSet.add(key);
151
- return true;
152
- }
153
- return false;
154
- });
155
- };
156
-
157
- // src/internal/resources.ts
158
- var import_path = require("path");
159
- var import_gray_matter2 = __toESM(require("gray-matter"));
160
- var import_promises = __toESM(require("fs/promises"));
161
- var import_node_fs2 = __toESM(require("fs"));
162
- var import_semver2 = require("semver");
163
- var import_proper_lockfile = require("proper-lockfile");
164
- var import_node_path2 = require("path");
165
- var import_node_path3 = __toESM(require("path"));
166
- var versionResource = async (catalogDir, id) => {
167
- const files = await getFiles(`${catalogDir}/**/index.{md,mdx}`);
168
- const matchedFiles = await searchFilesForId(files, id);
169
- if (matchedFiles.length === 0) {
170
- throw new Error(`No resource found with id: ${id}`);
171
- }
172
- const file = matchedFiles[0];
173
- const sourceDirectory = (0, import_path.dirname)(file).replace(/[/\\]versioned[/\\][^/\\]+[/\\]/, import_node_path3.default.sep);
174
- const { data: { version = "0.0.1" } = {} } = import_gray_matter2.default.read(file);
175
- const targetDirectory = getVersionedDirectory(sourceDirectory, version);
176
- import_node_fs2.default.mkdirSync(targetDirectory, { recursive: true });
177
- const ignoreListToCopy = ["events", "commands", "queries", "versioned"];
178
- await copyDir(catalogDir, sourceDirectory, targetDirectory, (src) => {
179
- const folderName = (0, import_node_path2.basename)(src);
180
- if (ignoreListToCopy.includes(folderName)) {
181
- return false;
182
- }
183
- return true;
184
- });
185
- await import_promises.default.readdir(sourceDirectory).then(async (resourceFiles) => {
186
- await Promise.all(
187
- resourceFiles.map(async (file2) => {
188
- if (ignoreListToCopy.includes(file2)) {
189
- return;
190
- }
191
- if (file2 !== "versioned") {
192
- import_node_fs2.default.rmSync((0, import_path.join)(sourceDirectory, file2), { recursive: true });
193
- }
194
- })
195
- );
196
- });
197
- };
198
- var writeResource = async (catalogDir, resource, options = {
199
- path: "",
200
- type: "",
201
- override: false,
202
- versionExistingContent: false,
203
- format: "mdx"
204
- }) => {
205
- const path6 = options.path || `/${resource.id}`;
206
- const fullPath = (0, import_path.join)(catalogDir, path6);
207
- const format = options.format || "mdx";
208
- import_node_fs2.default.mkdirSync(fullPath, { recursive: true });
209
- const lockPath = (0, import_path.join)(fullPath, `index.${format}`);
210
- if (!import_node_fs2.default.existsSync(lockPath)) {
211
- import_node_fs2.default.writeFileSync(lockPath, "");
212
- }
213
- try {
214
- await (0, import_proper_lockfile.lock)(lockPath, {
215
- retries: 5,
216
- stale: 1e4
217
- // 10 seconds
218
- });
219
- const exists = await versionExists(catalogDir, resource.id, resource.version);
220
- if (exists && !options.override) {
221
- throw new Error(`Failed to write ${resource.id} (${options.type}) as the version ${resource.version} already exists`);
222
- }
223
- const { markdown, ...frontmatter } = resource;
224
- if (options.versionExistingContent && !exists) {
225
- const currentResource = await getResource(catalogDir, resource.id);
226
- if (currentResource) {
227
- if ((0, import_semver2.satisfies)(resource.version, `>${currentResource.version}`)) {
228
- await versionResource(catalogDir, resource.id);
229
- } else {
230
- throw new Error(`New version ${resource.version} is not greater than current version ${currentResource.version}`);
231
- }
232
- }
233
- }
234
- const document = import_gray_matter2.default.stringify(markdown.trim(), frontmatter);
235
- import_node_fs2.default.writeFileSync(lockPath, document);
236
- } finally {
237
- await (0, import_proper_lockfile.unlock)(lockPath).catch(() => {
238
- });
239
- }
240
- };
241
- var getResource = async (catalogDir, id, version, options, filePath) => {
242
- const attachSchema = options?.attachSchema || false;
243
- const file = filePath || (id ? await findFileById(catalogDir, id, version) : void 0);
244
- if (!file || !import_node_fs2.default.existsSync(file)) return;
245
- const { data, content } = import_gray_matter2.default.read(file);
246
- if (attachSchema && data?.schemaPath) {
247
- const resourceDirectory = (0, import_path.dirname)(file);
248
- const pathToSchema = (0, import_path.join)(resourceDirectory, data.schemaPath);
249
- if (import_node_fs2.default.existsSync(pathToSchema)) {
250
- const schema = import_node_fs2.default.readFileSync(pathToSchema, "utf8");
251
- try {
252
- data.schema = JSON.parse(schema);
253
- } catch (error) {
254
- data.schema = schema;
255
- }
256
- }
257
- }
258
- return {
259
- ...data,
260
- markdown: content.trim()
261
- };
262
- };
263
- var getResourcePath = async (catalogDir, id, version) => {
264
- const file = await findFileById(catalogDir, id, version);
265
- if (!file) return;
266
- return {
267
- fullPath: file,
268
- relativePath: file.replace(catalogDir, ""),
269
- directory: (0, import_path.dirname)(file.replace(catalogDir, ""))
270
- };
271
- };
272
- var getResourceFolderName = async (catalogDir, id, version) => {
273
- const paths = await getResourcePath(catalogDir, id, version);
274
- if (!paths) return;
275
- return paths?.directory.split(import_node_path3.default.sep).filter(Boolean).pop();
276
- };
277
- var toResource = async (catalogDir, rawContents) => {
278
- const { data, content } = (0, import_gray_matter2.default)(rawContents);
279
- return {
280
- ...data,
281
- markdown: content.trim()
282
- };
283
- };
284
- var getResources = async (catalogDir, {
285
- type,
286
- latestOnly = false,
287
- ignore = [],
288
- pattern = "",
289
- attachSchema = false
290
- }) => {
291
- const ignoreList = latestOnly ? `**/versioned/**` : "";
292
- const filePattern = pattern || `${catalogDir}/**/${type}/**/index.{md,mdx}`;
293
- const files = await getFiles(filePattern, [ignoreList, ...ignore]);
294
- if (files.length === 0) return;
295
- return files.map((file) => {
296
- const { data, content } = import_gray_matter2.default.read(file);
297
- if (attachSchema && data?.schemaPath) {
298
- const resourceDirectory = (0, import_path.dirname)(file);
299
- const pathToSchema = (0, import_path.join)(resourceDirectory, data.schemaPath);
300
- if (import_node_fs2.default.existsSync(pathToSchema)) {
301
- const schema = import_node_fs2.default.readFileSync(pathToSchema, "utf8");
302
- try {
303
- data.schema = JSON.parse(schema);
304
- } catch (error) {
305
- data.schema = schema;
306
- }
307
- }
308
- }
309
- return {
310
- ...data,
311
- markdown: content.trim()
312
- };
313
- });
314
- };
315
- var rmResourceById = async (catalogDir, id, version, options) => {
316
- const files = await getFiles(`${catalogDir}/**/index.{md,mdx}`);
317
- const matchedFiles = await searchFilesForId(files, id, version);
318
- if (matchedFiles.length === 0) {
319
- throw new Error(`No ${options?.type || "resource"} found with id: ${id}`);
320
- }
321
- if (options?.persistFiles) {
322
- await Promise.all(
323
- matchedFiles.map(async (file) => {
324
- await import_promises.default.rm(file, { recursive: true });
325
- await waitForFileRemoval(file);
326
- })
327
- );
328
- } else {
329
- await Promise.all(
330
- matchedFiles.map(async (file) => {
331
- const directory = (0, import_path.dirname)(file);
332
- await import_promises.default.rm(directory, { recursive: true, force: true });
333
- await waitForFileRemoval(directory);
334
- })
335
- );
336
- }
337
- };
338
- var waitForFileRemoval = async (path6, maxRetries = 50, delay = 10) => {
339
- for (let i = 0; i < maxRetries; i++) {
340
- try {
341
- await import_promises.default.access(path6);
342
- await new Promise((resolve2) => setTimeout(resolve2, delay));
343
- } catch (error) {
344
- return;
345
- }
346
- }
347
- throw new Error(`File/directory ${path6} was not removed after ${maxRetries} attempts`);
348
- };
349
- var addFileToResource = async (catalogDir, id, file, version, options) => {
350
- let pathToResource;
351
- if (options?.path) {
352
- pathToResource = (0, import_path.join)(catalogDir, options.path, "index.mdx");
353
- } else {
354
- pathToResource = await findFileById(catalogDir, id, version);
355
- }
356
- if (!pathToResource) throw new Error("Cannot find directory to write file to");
357
- import_node_fs2.default.mkdirSync(import_node_path3.default.dirname(pathToResource), { recursive: true });
358
- let fileContent = file.content.trim();
359
- try {
360
- const json = JSON.parse(fileContent);
361
- fileContent = JSON.stringify(json, null, 2);
362
- } catch (error) {
363
- }
364
- import_node_fs2.default.writeFileSync((0, import_path.join)((0, import_path.dirname)(pathToResource), file.fileName), fileContent);
365
- };
366
- var getFileFromResource = async (catalogDir, id, file, version) => {
367
- const pathToResource = await findFileById(catalogDir, id, version);
368
- if (!pathToResource) throw new Error("Cannot find directory of resource");
369
- const exists = await import_promises.default.access((0, import_path.join)((0, import_path.dirname)(pathToResource), file.fileName)).then(() => true).catch(() => false);
370
- if (!exists) throw new Error(`File ${file.fileName} does not exist in resource ${id} v(${version})`);
371
- return import_node_fs2.default.readFileSync((0, import_path.join)((0, import_path.dirname)(pathToResource), file.fileName), "utf-8");
372
- };
373
- var getVersionedDirectory = (sourceDirectory, version) => {
374
- return (0, import_path.join)(sourceDirectory, "versioned", version);
375
- };
376
- var isLatestVersion = async (catalogDir, id, version) => {
377
- const resource = await getResource(catalogDir, id, version);
378
- if (!resource) return false;
379
- const pathToResource = await getResourcePath(catalogDir, id, version);
380
- return !pathToResource?.relativePath.replace(/\\/g, "/").includes("/versioned/");
381
- };
382
-
383
- // src/events.ts
384
- var getEvent = (directory) => async (id, version, options) => getResource(directory, id, version, { type: "event", ...options });
385
- var getEvents = (directory) => async (options) => getResources(directory, { type: "events", ...options });
386
- var writeEvent = (directory) => async (event, options = {
387
- path: "",
388
- override: false,
389
- format: "mdx"
390
- }) => writeResource(directory, { ...event }, { ...options, type: "event" });
391
- var writeEventToService = (directory) => async (event, service, options = { path: "", format: "mdx", override: false }) => {
392
- const resourcePath = await getResourcePath(directory, service.id, service.version);
393
- if (!resourcePath) {
394
- throw new Error("Service not found");
395
- }
396
- let pathForEvent = service.version && service.version !== "latest" ? `${resourcePath.directory}/versioned/${service.version}/events` : `${resourcePath.directory}/events`;
397
- pathForEvent = (0, import_node_path4.join)(pathForEvent, event.id);
398
- await writeResource(directory, { ...event }, { ...options, path: pathForEvent, type: "event" });
399
- };
400
- var rmEvent = (directory) => async (path6) => {
401
- await import_promises2.default.rm((0, import_node_path4.join)(directory, path6), { recursive: true });
402
- };
403
- var rmEventById = (directory) => async (id, version, persistFiles) => {
404
- await rmResourceById(directory, id, version, { type: "event", persistFiles });
405
- };
406
- var versionEvent = (directory) => async (id) => versionResource(directory, id);
407
- var addFileToEvent = (directory) => async (id, file, version, options) => addFileToResource(directory, id, file, version, options);
408
- var addSchemaToEvent = (directory) => async (id, schema, version, options) => {
409
- await addFileToEvent(directory)(id, { content: schema.schema, fileName: schema.fileName }, version, options);
410
- };
411
- var eventHasVersion = (directory) => async (id, version) => {
412
- const file = await findFileById(directory, id, version);
413
- return !!file;
414
- };
415
-
416
- // src/commands.ts
417
- var import_promises3 = __toESM(require("fs/promises"));
418
- var import_node_path5 = require("path");
419
- var getCommand = (directory) => async (id, version, options) => getResource(directory, id, version, { type: "command", ...options });
420
- var getCommands = (directory) => async (options) => getResources(directory, { type: "commands", ...options });
421
- var writeCommand = (directory) => async (command, options = {
422
- path: "",
423
- override: false,
424
- versionExistingContent: false,
425
- format: "mdx"
426
- }) => writeResource(directory, { ...command }, { ...options, type: "command" });
427
- var writeCommandToService = (directory) => async (command, service, options = { path: "", format: "mdx", override: false }) => {
428
- const resourcePath = await getResourcePath(directory, service.id, service.version);
429
- if (!resourcePath) {
430
- throw new Error("Service not found");
431
- }
432
- let pathForCommand = service.version && service.version !== "latest" ? `${resourcePath.directory}/versioned/${service.version}/commands` : `${resourcePath.directory}/commands`;
433
- pathForCommand = (0, import_node_path5.join)(pathForCommand, command.id);
434
- await writeResource(directory, { ...command }, { ...options, path: pathForCommand, type: "command" });
435
- };
436
- var rmCommand = (directory) => async (path6) => {
437
- await import_promises3.default.rm((0, import_node_path5.join)(directory, path6), { recursive: true });
438
- };
439
- var rmCommandById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "command", persistFiles });
440
- var versionCommand = (directory) => async (id) => versionResource(directory, id);
441
- var addFileToCommand = (directory) => async (id, file, version, options) => addFileToResource(directory, id, file, version, options);
442
- var addSchemaToCommand = (directory) => async (id, schema, version, options) => {
443
- await addFileToCommand(directory)(id, { content: schema.schema, fileName: schema.fileName }, version, options);
444
- };
445
- var commandHasVersion = (directory) => async (id, version) => {
446
- const file = await findFileById(directory, id, version);
447
- return !!file;
448
- };
449
-
450
- // src/queries.ts
451
- var import_promises4 = __toESM(require("fs/promises"));
452
- var import_node_path6 = require("path");
453
- var getQuery = (directory) => async (id, version, options) => getResource(directory, id, version, { type: "query", ...options });
454
- var writeQuery = (directory) => async (query, options = {
455
- path: "",
456
- override: false,
457
- versionExistingContent: false,
458
- format: "mdx"
459
- }) => writeResource(directory, { ...query }, { ...options, type: "query" });
460
- var getQueries = (directory) => async (options) => getResources(directory, { type: "queries", ...options });
461
- var writeQueryToService = (directory) => async (query, service, options = { path: "", format: "mdx", override: false }) => {
462
- const resourcePath = await getResourcePath(directory, service.id, service.version);
463
- if (!resourcePath) {
464
- throw new Error("Service not found");
465
- }
466
- let pathForQuery = service.version && service.version !== "latest" ? `${resourcePath.directory}/versioned/${service.version}/queries` : `${resourcePath.directory}/queries`;
467
- pathForQuery = (0, import_node_path6.join)(pathForQuery, query.id);
468
- await writeResource(directory, { ...query }, { ...options, path: pathForQuery, type: "query" });
469
- };
470
- var rmQuery = (directory) => async (path6) => {
471
- await import_promises4.default.rm((0, import_node_path6.join)(directory, path6), { recursive: true });
472
- };
473
- var rmQueryById = (directory) => async (id, version, persistFiles) => {
474
- await rmResourceById(directory, id, version, { type: "query", persistFiles });
475
- };
476
- var versionQuery = (directory) => async (id) => versionResource(directory, id);
477
- var addFileToQuery = (directory) => async (id, file, version, options) => addFileToResource(directory, id, file, version, options);
478
- var addSchemaToQuery = (directory) => async (id, schema, version, options) => {
479
- await addFileToQuery(directory)(id, { content: schema.schema, fileName: schema.fileName }, version, options);
480
- };
481
- var queryHasVersion = (directory) => async (id, version) => {
482
- const file = await findFileById(directory, id, version);
483
- return !!file;
484
- };
485
-
486
- // src/services.ts
487
- var import_promises5 = __toESM(require("fs/promises"));
488
- var import_node_path7 = require("path");
489
- var getService = (directory) => async (id, version) => getResource(directory, id, version, { type: "service" });
490
- var getServiceByPath = (directory) => async (path6) => {
491
- const service = await getResource(directory, void 0, void 0, { type: "service" }, path6);
492
- return service;
493
- };
494
- var getServices = (directory) => async (options) => getResources(directory, {
495
- type: "services",
496
- ignore: ["**/events/**", "**/commands/**", "**/queries/**", "**/entities/**", "**/subdomains/**/entities/**"],
497
- ...options
498
- });
499
- var writeService = (directory) => async (service, options = {
500
- path: "",
501
- override: false,
502
- format: "mdx"
503
- }) => {
504
- const resource = { ...service };
505
- if (Array.isArray(service.sends)) {
506
- resource.sends = uniqueVersions(service.sends);
507
- }
508
- if (Array.isArray(service.receives)) {
509
- resource.receives = uniqueVersions(service.receives);
510
- }
511
- return await writeResource(directory, resource, { ...options, type: "service" });
512
- };
513
- var writeVersionedService = (directory) => async (service) => {
514
- const resource = { ...service };
515
- const path6 = getVersionedDirectory(service.id, service.version);
516
- return await writeService(directory)(resource, { path: path6 });
517
- };
518
- var writeServiceToDomain = (directory) => async (service, domain, options = { path: "", format: "mdx", override: false }) => {
519
- let pathForService = domain.version && domain.version !== "latest" ? `/${domain.id}/versioned/${domain.version}/services` : `/${domain.id}/services`;
520
- pathForService = (0, import_node_path7.join)(pathForService, service.id);
521
- await writeResource(directory, { ...service }, { ...options, path: pathForService, type: "service" });
522
- };
523
- var versionService = (directory) => async (id) => versionResource(directory, id);
524
- var rmService = (directory) => async (path6) => {
525
- await import_promises5.default.rm((0, import_node_path7.join)(directory, path6), { recursive: true });
526
- };
527
- var rmServiceById = (directory) => async (id, version, persistFiles) => {
528
- await rmResourceById(directory, id, version, { type: "service", persistFiles });
529
- };
530
- var addFileToService = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
531
- var getSpecificationFilesForService = (directory) => async (id, version) => {
532
- let service = await getService(directory)(id, version);
533
- const filePathToService = await findFileById(directory, id, version);
534
- if (!filePathToService) throw new Error("Cannot find directory of service");
535
- let specs = [];
536
- if (service.specifications) {
537
- const serviceSpecifications = service.specifications;
538
- let specificationFiles;
539
- if (Array.isArray(serviceSpecifications)) {
540
- specificationFiles = serviceSpecifications.map((spec) => ({ key: spec.type, path: spec.path }));
541
- } else {
542
- specificationFiles = Object.keys(serviceSpecifications).map((spec) => ({
543
- key: spec,
544
- path: serviceSpecifications[spec]
545
- }));
546
- }
547
- const getSpecs = specificationFiles.map(async ({ key, path: fileName }) => {
548
- if (!fileName) {
549
- throw new Error(`Specification file name for ${fileName} is undefined`);
550
- }
551
- const rawFile = await getFileFromResource(directory, id, { fileName }, version);
552
- return { key, content: rawFile, fileName, path: (0, import_node_path7.join)((0, import_node_path7.dirname)(filePathToService), fileName) };
553
- });
554
- specs = await Promise.all(getSpecs);
555
- }
556
- return specs;
557
- };
558
- var addMessageToService = (directory) => async (id, direction, event, version) => {
559
- let service = await getService(directory)(id, version);
560
- const servicePath = await getResourcePath(directory, id, version);
561
- const extension = (0, import_node_path7.extname)(servicePath?.fullPath || "");
562
- if (direction === "sends") {
563
- if (service.sends === void 0) {
564
- service.sends = [];
565
- }
566
- for (let i = 0; i < service.sends.length; i++) {
567
- if (service.sends[i].id === event.id && service.sends[i].version === event.version) {
568
- return;
569
- }
570
- }
571
- service.sends.push({ id: event.id, version: event.version });
572
- } else if (direction === "receives") {
573
- if (service.receives === void 0) {
574
- service.receives = [];
575
- }
576
- for (let i = 0; i < service.receives.length; i++) {
577
- if (service.receives[i].id === event.id && service.receives[i].version === event.version) {
578
- return;
579
- }
580
- }
581
- service.receives.push({ id: event.id, version: event.version });
582
- } else {
583
- throw new Error(`Direction ${direction} is invalid, only 'receives' and 'sends' are supported`);
584
- }
585
- const existingResource = await findFileById(directory, id, version);
586
- if (!existingResource) {
587
- throw new Error(`Cannot find service ${id} in the catalog`);
588
- }
589
- const path6 = existingResource.split(/[\\/]+services/)[0];
590
- const pathToResource = (0, import_node_path7.join)(path6, "services");
591
- await rmServiceById(directory)(id, version);
592
- await writeService(pathToResource)(service, { format: extension === ".md" ? "md" : "mdx" });
593
- };
594
- var serviceHasVersion = (directory) => async (id, version) => {
595
- const file = await findFileById(directory, id, version);
596
- return !!file;
597
- };
598
- var isService = (directory) => async (path6) => {
599
- const service = await getServiceByPath(directory)(path6);
600
- const relativePath = (0, import_node_path7.relative)(directory, path6);
601
- const segments = relativePath.split(/[/\\]+/);
602
- return !!service && segments.includes("services");
603
- };
604
- var toService = (directory) => async (file) => toResource(directory, file);
605
- var addEntityToService = (directory) => async (id, entity, version) => {
606
- let service = await getService(directory)(id, version);
607
- const servicePath = await getResourcePath(directory, id, version);
608
- const extension = (0, import_node_path7.extname)(servicePath?.fullPath || "");
609
- if (service.entities === void 0) {
610
- service.entities = [];
611
- }
612
- for (let i = 0; i < service.entities.length; i++) {
613
- if (service.entities[i].id === entity.id && service.entities[i].version === entity.version) {
614
- return;
615
- }
616
- }
617
- service.entities.push({ id: entity.id, version: entity.version });
618
- const existingResource = await findFileById(directory, id, version);
619
- if (!existingResource) {
620
- throw new Error(`Cannot find service ${id} in the catalog`);
621
- }
622
- const path6 = existingResource.split(/[\\/]+services/)[0];
623
- const pathToResource = (0, import_node_path7.join)(path6, "services");
624
- await rmServiceById(directory)(id, version);
625
- await writeService(pathToResource)(service, { format: extension === ".md" ? "md" : "mdx" });
626
- };
627
- var addDataStoreToService = (directory) => async (id, operation, dataStore, version) => {
628
- let service = await getService(directory)(id, version);
629
- const servicePath = await getResourcePath(directory, id, version);
630
- const extension = (0, import_node_path7.extname)(servicePath?.fullPath || "");
631
- if (operation === "writesTo") {
632
- if (service.writesTo === void 0) {
633
- service.writesTo = [];
634
- }
635
- for (let i = 0; i < service.writesTo.length; i++) {
636
- if (service.writesTo[i].id === dataStore.id && service.writesTo[i].version === dataStore.version) {
637
- return;
638
- }
639
- }
640
- service.writesTo.push({ id: dataStore.id, version: dataStore.version });
641
- } else if (operation === "readsFrom") {
642
- if (service.readsFrom === void 0) {
643
- service.readsFrom = [];
644
- }
645
- for (let i = 0; i < service.readsFrom.length; i++) {
646
- if (service.readsFrom[i].id === dataStore.id && service.readsFrom[i].version === dataStore.version) {
647
- return;
648
- }
649
- }
650
- service.readsFrom.push({ id: dataStore.id, version: dataStore.version });
651
- } else {
652
- throw new Error(`Operation ${operation} is invalid, only 'writesTo' and 'readsFrom' are supported`);
653
- }
654
- const existingResource = await findFileById(directory, id, version);
655
- if (!existingResource) {
656
- throw new Error(`Cannot find service ${id} in the catalog`);
657
- }
658
- const path6 = existingResource.split(/[\\/]+services/)[0];
659
- const pathToResource = (0, import_node_path7.join)(path6, "services");
660
- await rmServiceById(directory)(id, version);
661
- await writeService(pathToResource)(service, { format: extension === ".md" ? "md" : "mdx" });
662
- };
663
-
664
- // src/domains.ts
665
- var import_promises6 = __toESM(require("fs/promises"));
666
- var import_node_path8 = __toESM(require("path"));
667
- var import_node_fs3 = __toESM(require("fs"));
668
- var import_gray_matter3 = __toESM(require("gray-matter"));
669
- var getDomain = (directory) => async (id, version) => getResource(directory, id, version, { type: "domain" });
670
- var getDomains = (directory) => async (options) => getResources(directory, {
671
- type: "domains",
672
- ignore: ["**/services/**", "**/events/**", "**/commands/**", "**/queries/**", "**/flows/**", "**/entities/**"],
673
- ...options
674
- });
675
- var writeDomain = (directory) => async (domain, options = {
676
- path: "",
677
- override: false,
678
- versionExistingContent: false,
679
- format: "mdx"
680
- }) => {
681
- const resource = { ...domain };
682
- if (Array.isArray(domain.services)) {
683
- resource.services = uniqueVersions(domain.services);
684
- }
685
- if (Array.isArray(domain.domains)) {
686
- resource.domains = uniqueVersions(domain.domains);
687
- }
688
- if (Array.isArray(domain.sends)) {
689
- resource.sends = uniqueVersions(domain.sends);
690
- }
691
- if (Array.isArray(domain.receives)) {
692
- resource.receives = uniqueVersions(domain.receives);
693
- }
694
- if (Array.isArray(domain.dataProducts)) {
695
- resource.dataProducts = uniqueVersions(domain.dataProducts);
696
- }
697
- return await writeResource(directory, resource, { ...options, type: "domain" });
698
- };
699
- var versionDomain = (directory) => async (id) => versionResource(directory, id);
700
- var rmDomain = (directory) => async (path6) => {
701
- await import_promises6.default.rm((0, import_node_path8.join)(directory, path6), { recursive: true });
702
- };
703
- var rmDomainById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "domain", persistFiles });
704
- var addFileToDomain = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
705
- var addUbiquitousLanguageToDomain = (directory) => async (id, ubiquitousLanguageDictionary, version) => {
706
- const content = import_gray_matter3.default.stringify("", {
707
- ...ubiquitousLanguageDictionary
708
- });
709
- await addFileToResource(directory, id, { content, fileName: "ubiquitous-language.mdx" }, version);
710
- };
711
- var getUbiquitousLanguageFromDomain = (directory) => async (id, version) => {
712
- const pathToDomain = await findFileById(directory, id, version) || "";
713
- const pathToUbiquitousLanguage = import_node_path8.default.join(import_node_path8.default.dirname(pathToDomain), "ubiquitous-language.mdx");
714
- const fileExists = import_node_fs3.default.existsSync(pathToUbiquitousLanguage);
715
- if (!fileExists) {
716
- return void 0;
717
- }
718
- const content = await readMdxFile(pathToUbiquitousLanguage);
719
- return content;
720
- };
721
- var domainHasVersion = (directory) => async (id, version) => {
722
- const file = await findFileById(directory, id, version);
723
- return !!file;
724
- };
725
- var addServiceToDomain = (directory) => async (id, service, version) => {
726
- let domain = await getDomain(directory)(id, version);
727
- const domainPath = await getResourcePath(directory, id, version);
728
- const extension = import_node_path8.default.extname(domainPath?.fullPath || "");
729
- if (domain.services === void 0) {
730
- domain.services = [];
731
- }
732
- const serviceExistsInList = domain.services.some((s) => s.id === service.id && s.version === service.version);
733
- if (serviceExistsInList) {
734
- return;
735
- }
736
- domain.services.push(service);
737
- await rmDomainById(directory)(id, version, true);
738
- await writeDomain(directory)(domain, { format: extension === ".md" ? "md" : "mdx" });
739
- };
740
- var addSubDomainToDomain = (directory) => async (id, subDomain, version) => {
741
- let domain = await getDomain(directory)(id, version);
742
- const domainPath = await getResourcePath(directory, id, version);
743
- const extension = import_node_path8.default.extname(domainPath?.fullPath || "");
744
- if (domain.domains === void 0) {
745
- domain.domains = [];
746
- }
747
- const subDomainExistsInList = domain.domains.some((s) => s.id === subDomain.id && s.version === subDomain.version);
748
- if (subDomainExistsInList) {
749
- return;
750
- }
751
- domain.domains.push(subDomain);
752
- await rmDomainById(directory)(id, version, true);
753
- await writeDomain(directory)(domain, { format: extension === ".md" ? "md" : "mdx" });
754
- };
755
- var addEntityToDomain = (directory) => async (id, entity, version) => {
756
- let domain = await getDomain(directory)(id, version);
757
- const domainPath = await getResourcePath(directory, id, version);
758
- const extension = import_node_path8.default.extname(domainPath?.fullPath || "");
759
- if (domain.entities === void 0) {
760
- domain.entities = [];
761
- }
762
- const entityExistsInList = domain.entities.some((e) => e.id === entity.id && e.version === entity.version);
763
- if (entityExistsInList) {
764
- return;
765
- }
766
- domain.entities.push(entity);
767
- await rmDomainById(directory)(id, version, true);
768
- await writeDomain(directory)(domain, { format: extension === ".md" ? "md" : "mdx" });
769
- };
770
- var addDataProductToDomain = (directory) => async (id, dataProduct, version) => {
771
- let domain = await getDomain(directory)(id, version);
772
- const domainPath = await getResourcePath(directory, id, version);
773
- const extension = import_node_path8.default.extname(domainPath?.fullPath || "");
774
- if (domain.dataProducts === void 0) {
775
- domain.dataProducts = [];
776
- }
777
- const dataProductExistsInList = domain.dataProducts.some(
778
- (dp) => dp.id === dataProduct.id && dp.version === dataProduct.version
779
- );
780
- if (dataProductExistsInList) {
781
- return;
782
- }
783
- domain.dataProducts.push(dataProduct);
784
- await rmDomainById(directory)(id, version, true);
785
- await writeDomain(directory)(domain, { format: extension === ".md" ? "md" : "mdx" });
786
- };
787
- var addMessageToDomain = (directory) => async (id, direction, message, version) => {
788
- let domain = await getDomain(directory)(id, version);
789
- const domainPath = await getResourcePath(directory, id, version);
790
- const extension = import_node_path8.default.extname(domainPath?.fullPath || "");
791
- if (direction === "sends") {
792
- if (domain.sends === void 0) {
793
- domain.sends = [];
794
- }
795
- for (let i = 0; i < domain.sends.length; i++) {
796
- if (domain.sends[i].id === message.id && domain.sends[i].version === message.version) {
797
- return;
798
- }
799
- }
800
- domain.sends.push({ id: message.id, version: message.version });
801
- } else if (direction === "receives") {
802
- if (domain.receives === void 0) {
803
- domain.receives = [];
804
- }
805
- for (let i = 0; i < domain.receives.length; i++) {
806
- if (domain.receives[i].id === message.id && domain.receives[i].version === message.version) {
807
- return;
808
- }
809
- }
810
- domain.receives.push({ id: message.id, version: message.version });
811
- } else {
812
- throw new Error(`Direction ${direction} is invalid, only 'receives' and 'sends' are supported`);
813
- }
814
- const existingResource = await findFileById(directory, id, version);
815
- if (!existingResource) {
816
- throw new Error(`Cannot find domain ${id} in the catalog`);
817
- }
818
- const normalizedPath = existingResource.replace(/\\/g, "/");
819
- const lastDomainsIndex = normalizedPath.lastIndexOf("/domains/");
820
- const pathToResource = existingResource.substring(0, lastDomainsIndex + "/domains".length);
821
- await rmDomainById(directory)(id, version, true);
822
- await writeDomain(pathToResource)(domain, { format: extension === ".md" ? "md" : "mdx" });
823
- };
824
-
825
- // src/channels.ts
826
- var import_promises7 = __toESM(require("fs/promises"));
827
- var import_node_path9 = require("path");
828
- var getChannel = (directory) => async (id, version) => getResource(directory, id, version, { type: "channel" });
829
- var getChannels = (directory) => async (options) => getResources(directory, { type: "channels", ...options });
830
- var writeChannel = (directory) => async (channel, options = { path: "" }) => writeResource(directory, { ...channel }, { ...options, type: "channel" });
831
- var rmChannel = (directory) => async (path6) => {
832
- await import_promises7.default.rm((0, import_node_path9.join)(directory, path6), { recursive: true });
833
- };
834
- var rmChannelById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "channel", persistFiles });
835
- var versionChannel = (directory) => async (id) => versionResource(directory, id);
836
- var channelHasVersion = (directory) => async (id, version) => {
837
- const file = await findFileById(directory, id, version);
838
- return !!file;
839
- };
840
- var addMessageToChannel = (directory, collection) => async (id, _message, version) => {
841
- let channel = await getChannel(directory)(id, version);
842
- const functions = {
843
- events: {
844
- getMessage: getEvent,
845
- rmMessageById: rmEventById,
846
- writeMessage: writeEvent
847
- },
848
- commands: {
849
- getMessage: getCommand,
850
- rmMessageById: rmCommandById,
851
- writeMessage: writeCommand
852
- },
853
- queries: {
854
- getMessage: getQuery,
855
- rmMessageById: rmQueryById,
856
- writeMessage: writeQuery
857
- }
858
- };
859
- const { getMessage, rmMessageById, writeMessage } = functions[collection];
860
- const message = await getMessage(directory)(_message.id, _message.version);
861
- const messagePath = await getResourcePath(directory, _message.id, _message.version);
862
- const extension = (0, import_node_path9.extname)(messagePath?.fullPath || "");
863
- if (!message) throw new Error(`Message ${_message.id} with version ${_message.version} not found`);
864
- if (message.channels === void 0) {
865
- message.channels = [];
866
- }
867
- const channelInfo = { id, version: channel.version, ..._message.parameters && { parameters: _message.parameters } };
868
- message.channels.push(channelInfo);
869
- const existingResource = await findFileById(directory, _message.id, _message.version);
870
- if (!existingResource) {
871
- throw new Error(`Cannot find message ${id} in the catalog`);
872
- }
873
- const path6 = existingResource.split(`/[\\/]+${collection}`)[0];
874
- const pathToResource = (0, import_node_path9.join)(path6, collection);
875
- await rmMessageById(directory)(_message.id, _message.version, true);
876
- await writeMessage(pathToResource)(message, { format: extension === ".md" ? "md" : "mdx" });
877
- };
878
-
879
- // src/messages.ts
880
- var import_node_path10 = require("path");
881
- var import_gray_matter4 = __toESM(require("gray-matter"));
882
- var import_semver3 = require("semver");
883
- var getMessageBySchemaPath = (directory) => async (path6, options) => {
884
- const pathToMessage = (0, import_node_path10.dirname)(path6);
885
- try {
886
- const files = await getFiles(`${directory}/${pathToMessage}/index.{md,mdx}`);
887
- if (!files || files.length === 0) {
888
- throw new Error(`No message definition file (index.md or index.mdx) found in directory: ${pathToMessage}`);
889
- }
890
- const messageFile = files[0];
891
- const { data } = import_gray_matter4.default.read(messageFile);
892
- const { id, version } = data;
893
- if (!id || !version) {
894
- throw new Error(`Message definition file at ${messageFile} is missing 'id' or 'version' in its frontmatter.`);
895
- }
896
- const message = await getResource(directory, id, version, { type: "message", ...options });
897
- if (!message) {
898
- throw new Error(`Message resource with id '${id}' and version '${version}' not found, as referenced in ${messageFile}.`);
899
- }
900
- return message;
901
- } catch (error) {
902
- if (error instanceof Error) {
903
- error.message = `Failed to retrieve message from ${pathToMessage}: ${error.message}`;
904
- throw error;
905
- }
906
- throw new Error(`Failed to retrieve message from ${pathToMessage} due to an unknown error.`);
907
- }
908
- };
909
- var getProducersAndConsumersForMessage = (directory) => async (id, version, options) => {
910
- const services = await getServices(directory)({ latestOnly: options?.latestOnly ?? true });
911
- const message = await getResource(directory, id, version, { type: "message" });
912
- const isMessageLatestVersion = await isLatestVersion(directory, id, version);
913
- if (!message) {
914
- throw new Error(`Message resource with id '${id}' and version '${version}' not found.`);
915
- }
916
- const producers = [];
917
- const consumers = [];
918
- for (const service of services) {
919
- const servicePublishesMessage = service.sends?.some((_message) => {
920
- if (_message.version) {
921
- const isServiceUsingSemverRange = (0, import_semver3.validRange)(_message.version);
922
- if (isServiceUsingSemverRange) {
923
- return _message.id === message.id && (0, import_semver3.satisfies)(message.version, _message.version);
924
- } else {
925
- return _message.id === message.id && message.version === _message.version;
926
- }
927
- }
928
- if (isMessageLatestVersion && _message.id === message.id) {
929
- return true;
930
- }
931
- return false;
932
- });
933
- const serviceSubscribesToMessage = service.receives?.some((_message) => {
934
- if (_message.version) {
935
- const isServiceUsingSemverRange = (0, import_semver3.validRange)(_message.version);
936
- if (isServiceUsingSemverRange) {
937
- return _message.id === message.id && (0, import_semver3.satisfies)(message.version, _message.version);
938
- } else {
939
- return _message.id === message.id && message.version === _message.version;
940
- }
941
- }
942
- if (isMessageLatestVersion && _message.id === message.id) {
943
- return true;
944
- }
945
- return false;
946
- });
947
- if (servicePublishesMessage) {
948
- producers.push(service);
949
- }
950
- if (serviceSubscribesToMessage) {
951
- consumers.push(service);
952
- }
953
- }
954
- return { producers, consumers };
955
- };
956
- var getConsumersOfSchema = (directory) => async (path6) => {
957
- try {
958
- const message = await getMessageBySchemaPath(directory)(path6);
959
- const { consumers } = await getProducersAndConsumersForMessage(directory)(message.id, message.version);
960
- return consumers;
961
- } catch (error) {
962
- return [];
963
- }
964
- };
965
- var getProducersOfSchema = (directory) => async (path6) => {
966
- try {
967
- const message = await getMessageBySchemaPath(directory)(path6);
968
- const { producers } = await getProducersAndConsumersForMessage(directory)(message.id, message.version);
969
- return producers;
970
- } catch (error) {
971
- return [];
972
- }
973
- };
974
-
975
- // src/custom-docs.ts
976
- var import_node_path11 = __toESM(require("path"));
977
- var import_node_fs4 = __toESM(require("fs"));
978
- var import_promises8 = __toESM(require("fs/promises"));
979
- var import_gray_matter5 = __toESM(require("gray-matter"));
980
- var import_slugify = __toESM(require("slugify"));
981
- var getCustomDoc = (directory) => async (filePath) => {
982
- const fullPath = import_node_path11.default.join(directory, filePath);
983
- const fullPathWithExtension = fullPath.endsWith(".mdx") ? fullPath : `${fullPath}.mdx`;
984
- const fileExists = import_node_fs4.default.existsSync(fullPathWithExtension);
985
- if (!fileExists) {
986
- return void 0;
987
- }
988
- return readMdxFile(fullPathWithExtension);
989
- };
990
- var getCustomDocs = (directory) => async (options) => {
991
- if (options?.path) {
992
- const pattern = `${directory}/${options.path}/**/*.{md,mdx}`;
993
- return getResources(directory, { type: "docs", pattern });
994
- }
995
- return getResources(directory, { type: "docs", pattern: `${directory}/**/*.{md,mdx}` });
996
- };
997
- var writeCustomDoc = (directory) => async (customDoc, options = { path: "" }) => {
998
- const { fileName, ...rest } = customDoc;
999
- const name = fileName || (0, import_slugify.default)(customDoc.title, { lower: true });
1000
- const withExtension = name.endsWith(".mdx") ? name : `${name}.mdx`;
1001
- const fullPath = import_node_path11.default.join(directory, options.path || "", withExtension);
1002
- import_node_fs4.default.mkdirSync(import_node_path11.default.dirname(fullPath), { recursive: true });
1003
- const document = import_gray_matter5.default.stringify(customDoc.markdown.trim(), rest);
1004
- import_node_fs4.default.writeFileSync(fullPath, document);
1005
- };
1006
- var rmCustomDoc = (directory) => async (filePath) => {
1007
- const withExtension = filePath.endsWith(".mdx") ? filePath : `${filePath}.mdx`;
1008
- await import_promises8.default.rm((0, import_node_path11.join)(directory, withExtension), { recursive: true });
1009
- };
1010
-
1011
- // src/teams.ts
1012
- var import_promises9 = __toESM(require("fs/promises"));
1013
- var import_node_fs6 = __toESM(require("fs"));
1014
- var import_node_path13 = require("path");
1015
- var import_gray_matter7 = __toESM(require("gray-matter"));
1016
- var import_node_path14 = __toESM(require("path"));
1017
-
1018
- // src/users.ts
1019
- var import_node_fs5 = __toESM(require("fs"));
1020
- var import_node_path12 = require("path");
1021
- var import_gray_matter6 = __toESM(require("gray-matter"));
1022
- var getUser = (catalogDir) => async (id) => {
1023
- const files = await getFiles(`${catalogDir}/${id}.{md,mdx}`);
1024
- if (files.length == 0) return void 0;
1025
- const file = files[0];
1026
- const { data, content } = import_gray_matter6.default.read(file);
1027
- return {
1028
- ...data,
1029
- id: data.id,
1030
- name: data.name,
1031
- avatarUrl: data.avatarUrl,
1032
- markdown: content.trim()
1033
- };
1034
- };
1035
- var getUsers = (catalogDir) => async (options) => {
1036
- const files = await getFiles(`${catalogDir}/users/*.{md,mdx}`);
1037
- if (files.length === 0) return [];
1038
- return files.map((file) => {
1039
- const { data, content } = import_gray_matter6.default.read(file);
1040
- return {
1041
- ...data,
1042
- id: data.id,
1043
- name: data.name,
1044
- avatarUrl: data.avatarUrl,
1045
- markdown: content.trim()
1046
- };
1047
- });
1048
- };
1049
- var writeUser = (catalogDir) => async (user, options = {}) => {
1050
- const resource = { ...user };
1051
- const currentUser = await getUser(catalogDir)(resource.id);
1052
- const exists = currentUser !== void 0;
1053
- if (exists && !options.override) {
1054
- throw new Error(`Failed to write ${resource.id} (user) as it already exists`);
1055
- }
1056
- const { markdown, ...frontmatter } = resource;
1057
- const document = import_gray_matter6.default.stringify(markdown, frontmatter);
1058
- import_node_fs5.default.mkdirSync((0, import_node_path12.join)(catalogDir, ""), { recursive: true });
1059
- import_node_fs5.default.writeFileSync((0, import_node_path12.join)(catalogDir, "", `${resource.id}.mdx`), document);
1060
- };
1061
- var rmUserById = (catalogDir) => async (id) => {
1062
- import_node_fs5.default.rmSync((0, import_node_path12.join)(catalogDir, `${id}.mdx`), { recursive: true });
1063
- };
1064
-
1065
- // src/teams.ts
1066
- var getTeam = (catalogDir) => async (id) => {
1067
- const files = await getFiles(`${catalogDir}/${id}.{md,mdx}`);
1068
- if (files.length == 0) return void 0;
1069
- const file = files[0];
1070
- const { data, content } = import_gray_matter7.default.read(file);
1071
- return {
1072
- ...data,
1073
- id: data.id,
1074
- name: data.name,
1075
- markdown: content.trim()
1076
- };
1077
- };
1078
- var getTeams = (catalogDir) => async (options) => {
1079
- const files = await getFiles(`${catalogDir}/*.{md,mdx}`);
1080
- if (files.length === 0) return [];
1081
- return files.map((file) => {
1082
- const { data, content } = import_gray_matter7.default.read(file);
1083
- return {
1084
- ...data,
1085
- id: data.id,
1086
- name: data.name,
1087
- markdown: content.trim()
1088
- };
1089
- });
1090
- };
1091
- var writeTeam = (catalogDir) => async (team, options = {}) => {
1092
- const resource = { ...team };
1093
- const currentTeam = await getTeam(catalogDir)(resource.id);
1094
- const exists = currentTeam !== void 0;
1095
- if (exists && !options.override) {
1096
- throw new Error(`Failed to write ${resource.id} (team) as it already exists`);
1097
- }
1098
- const { markdown, ...frontmatter } = resource;
1099
- const document = import_gray_matter7.default.stringify(markdown, frontmatter);
1100
- import_node_fs6.default.mkdirSync((0, import_node_path13.join)(catalogDir, ""), { recursive: true });
1101
- import_node_fs6.default.writeFileSync((0, import_node_path13.join)(catalogDir, "", `${resource.id}.mdx`), document);
1102
- };
1103
- var rmTeamById = (catalogDir) => async (id) => {
1104
- await import_promises9.default.rm((0, import_node_path13.join)(catalogDir, `${id}.mdx`), { recursive: true });
1105
- };
1106
- var getOwnersForResource = (catalogDir) => async (id, version) => {
1107
- const resource = await getResource(catalogDir, id, version);
1108
- let owners = [];
1109
- if (!resource) return [];
1110
- if (!resource.owners) return [];
1111
- for (const owner of resource.owners) {
1112
- const team = await getTeam(import_node_path14.default.join(catalogDir, "teams"))(owner);
1113
- if (team) {
1114
- owners.push(team);
1115
- } else {
1116
- const user = await getUser(import_node_path14.default.join(catalogDir, "users"))(owner);
1117
- if (user) {
1118
- owners.push(user);
1119
- }
1120
- }
1121
- }
1122
- return owners;
1123
- };
1124
-
1125
- // src/eventcatalog.ts
1126
- var import_fs = __toESM(require("fs"));
1127
- var import_node_path15 = __toESM(require("path"));
1128
- var DUMP_VERSION = "0.0.1";
1129
- var getEventCatalogVersion = async (catalogDir) => {
1130
- try {
1131
- const packageJson = import_fs.default.readFileSync((0, import_node_path15.join)(catalogDir, "package.json"), "utf8");
1132
- const packageJsonObject = JSON.parse(packageJson);
1133
- return packageJsonObject["dependencies"]["@eventcatalog/core"];
1134
- } catch (error) {
1135
- return "unknown";
1136
- }
1137
- };
1138
- var hydrateResource = async (catalogDir, resources = [], { attachSchema = false } = {}) => {
1139
- return await Promise.all(
1140
- resources.map(async (resource) => {
1141
- const resourcePath = await getResourcePath(catalogDir, resource.id, resource.version);
1142
- let schema = "";
1143
- if (resource.schemaPath && resourcePath?.fullPath) {
1144
- const pathToSchema = import_node_path15.default.join(import_node_path15.default.dirname(resourcePath?.fullPath), resource.schemaPath);
1145
- if (import_fs.default.existsSync(pathToSchema)) {
1146
- schema = import_fs.default.readFileSync(pathToSchema, "utf8");
1147
- }
1148
- }
1149
- const eventcatalog = schema ? { directory: resourcePath?.directory, schema } : { directory: resourcePath?.directory };
1150
- return {
1151
- ...resource,
1152
- _eventcatalog: eventcatalog
1153
- };
1154
- })
1155
- );
1156
- };
1157
- var filterCollection = (collection, options) => {
1158
- return collection.map((item) => ({
1159
- ...item,
1160
- markdown: options?.includeMarkdown ? item.markdown : void 0
1161
- }));
1162
- };
1163
- var getEventCatalogConfigurationFile = (directory) => async () => {
1164
- try {
1165
- const path6 = (0, import_node_path15.join)(directory, "eventcatalog.config.js");
1166
- const configModule = await import(path6);
1167
- return configModule.default;
1168
- } catch (error) {
1169
- console.error("Error getting event catalog configuration file", error);
1170
- return null;
1171
- }
1172
- };
1173
- var dumpCatalog = (directory) => async (options) => {
1174
- const { getDomains: getDomains2, getServices: getServices2, getEvents: getEvents2, getQueries: getQueries2, getCommands: getCommands2, getChannels: getChannels2, getTeams: getTeams2, getUsers: getUsers3 } = src_default(directory);
1175
- const { includeMarkdown = true } = options || {};
1176
- const domains = await getDomains2();
1177
- const services = await getServices2();
1178
- const events = await getEvents2();
1179
- const commands = await getCommands2();
1180
- const queries = await getQueries2();
1181
- const teams = await getTeams2();
1182
- const users = await getUsers3();
1183
- const channels = await getChannels2();
1184
- const [
1185
- hydratedDomains,
1186
- hydratedServices,
1187
- hydratedEvents,
1188
- hydratedQueries,
1189
- hydratedCommands,
1190
- hydratedTeams,
1191
- hydratedUsers,
1192
- hydratedChannels
1193
- ] = await Promise.all([
1194
- hydrateResource(directory, domains),
1195
- hydrateResource(directory, services),
1196
- hydrateResource(directory, events),
1197
- hydrateResource(directory, queries),
1198
- hydrateResource(directory, commands),
1199
- hydrateResource(directory, teams),
1200
- hydrateResource(directory, users),
1201
- hydrateResource(directory, channels)
1202
- ]);
1203
- return {
1204
- version: DUMP_VERSION,
1205
- catalogVersion: await getEventCatalogVersion(directory),
1206
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1207
- resources: {
1208
- domains: filterCollection(hydratedDomains, { includeMarkdown }),
1209
- services: filterCollection(hydratedServices, { includeMarkdown }),
1210
- messages: {
1211
- events: filterCollection(hydratedEvents, { includeMarkdown }),
1212
- queries: filterCollection(hydratedQueries, { includeMarkdown }),
1213
- commands: filterCollection(hydratedCommands, { includeMarkdown })
1214
- },
1215
- teams: filterCollection(hydratedTeams, { includeMarkdown }),
1216
- users: filterCollection(hydratedUsers, { includeMarkdown }),
1217
- channels: filterCollection(hydratedChannels, { includeMarkdown })
1218
- }
1219
- };
1220
- };
1221
-
1222
- // src/entities.ts
1223
- var import_promises10 = __toESM(require("fs/promises"));
1224
- var import_node_path16 = require("path");
1225
- var getEntity = (directory) => async (id, version) => getResource(directory, id, version, { type: "entity" });
1226
- var getEntities = (directory) => async (options) => getResources(directory, { type: "entities", latestOnly: options?.latestOnly });
1227
- var writeEntity = (directory) => async (entity, options = {
1228
- path: "",
1229
- override: false,
1230
- format: "mdx"
1231
- }) => writeResource(directory, { ...entity }, { ...options, type: "entity" });
1232
- var rmEntity = (directory) => async (path6) => {
1233
- await import_promises10.default.rm((0, import_node_path16.join)(directory, path6), { recursive: true });
1234
- };
1235
- var rmEntityById = (directory) => async (id, version, persistFiles) => {
1236
- await rmResourceById(directory, id, version, { type: "entity", persistFiles });
1237
- };
1238
- var versionEntity = (directory) => async (id) => versionResource(directory, id);
1239
- var entityHasVersion = (directory) => async (id, version) => {
1240
- const file = await findFileById(directory, id, version);
1241
- return !!file;
1242
- };
1243
-
1244
- // src/containers.ts
1245
- var import_promises11 = __toESM(require("fs/promises"));
1246
- var import_node_path17 = require("path");
1247
- var getContainer = (directory) => async (id, version) => getResource(directory, id, version, { type: "container" });
1248
- var getContainers = (directory) => async (options) => getResources(directory, { type: "containers", latestOnly: options?.latestOnly });
1249
- var writeContainer = (directory) => async (data, options = {
1250
- path: "",
1251
- override: false,
1252
- format: "mdx"
1253
- }) => writeResource(directory, { ...data }, { ...options, type: "container" });
1254
- var versionContainer = (directory) => async (id) => versionResource(directory, id);
1255
- var rmContainer = (directory) => async (path6) => {
1256
- await import_promises11.default.rm((0, import_node_path17.join)(directory, path6), { recursive: true });
1257
- };
1258
- var rmContainerById = (directory) => async (id, version, persistFiles) => {
1259
- await rmResourceById(directory, id, version, { type: "container", persistFiles });
1260
- };
1261
- var containerHasVersion = (directory) => async (id, version) => {
1262
- const file = await findFileById(directory, id, version);
1263
- return !!file;
1264
- };
1265
- var addFileToContainer = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
1266
- var writeContainerToService = (directory) => async (container, service, options = { path: "", format: "mdx", override: false }) => {
1267
- const resourcePath = await getResourcePath(directory, service.id, service.version);
1268
- if (!resourcePath) {
1269
- throw new Error("Service not found");
1270
- }
1271
- let pathForContainer = service.version && service.version !== "latest" ? `${resourcePath.directory}/versioned/${service.version}/containers` : `${resourcePath.directory}/containers`;
1272
- pathForContainer = (0, import_node_path17.join)(pathForContainer, container.id);
1273
- await writeResource(directory, { ...container }, { ...options, path: pathForContainer, type: "container" });
1274
- };
1275
-
1276
- // src/data-stores.ts
1277
- var getDataStore = getContainer;
1278
- var getDataStores = getContainers;
1279
- var writeDataStore = writeContainer;
1280
- var versionDataStore = versionContainer;
1281
- var rmDataStore = rmContainer;
1282
- var rmDataStoreById = rmContainerById;
1283
- var dataStoreHasVersion = containerHasVersion;
1284
- var addFileToDataStore = addFileToContainer;
1285
- var writeDataStoreToService = writeContainerToService;
1286
-
1287
- // src/data-products.ts
1288
- var import_promises12 = __toESM(require("fs/promises"));
1289
- var import_node_path18 = require("path");
1290
- var getDataProduct = (directory) => async (id, version) => getResource(directory, id, version, { type: "data-product" });
1291
- var getDataProducts = (directory) => async (options) => getResources(directory, { type: "data-products", latestOnly: options?.latestOnly });
1292
- var writeDataProduct = (directory) => async (dataProduct, options = {
1293
- path: "",
1294
- override: false,
1295
- format: "mdx"
1296
- }) => writeResource(directory, { ...dataProduct }, { ...options, type: "data-product" });
1297
- var writeDataProductToDomain = (directory) => async (dataProduct, domain, options = { path: "", format: "mdx", override: false }) => {
1298
- let pathForDataProduct = domain.version && domain.version !== "latest" ? `/${domain.id}/versioned/${domain.version}/data-products` : `/${domain.id}/data-products`;
1299
- pathForDataProduct = (0, import_node_path18.join)(pathForDataProduct, dataProduct.id);
1300
- await writeResource(directory, { ...dataProduct }, { ...options, path: pathForDataProduct, type: "data-product" });
1301
- };
1302
- var rmDataProduct = (directory) => async (path6) => {
1303
- await import_promises12.default.rm((0, import_node_path18.join)(directory, path6), { recursive: true });
1304
- };
1305
- var rmDataProductById = (directory) => async (id, version, persistFiles) => {
1306
- await rmResourceById(directory, id, version, { type: "data-product", persistFiles });
1307
- };
1308
- var versionDataProduct = (directory) => async (id) => versionResource(directory, id);
1309
- var dataProductHasVersion = (directory) => async (id, version) => {
1310
- const file = await findFileById(directory, id, version);
1311
- return !!file;
1312
- };
1313
- var addFileToDataProduct = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
1314
-
1315
- // src/diagrams.ts
1316
- var import_promises13 = __toESM(require("fs/promises"));
1317
- var import_node_path19 = require("path");
1318
- var getDiagram = (directory) => async (id, version) => getResource(directory, id, version, { type: "diagram" });
1319
- var getDiagrams = (directory) => async (options) => getResources(directory, { type: "diagrams", latestOnly: options?.latestOnly });
1320
- var writeDiagram = (directory) => async (diagram, options = {
1321
- path: "",
1322
- override: false,
1323
- format: "mdx"
1324
- }) => writeResource(directory, { ...diagram }, { ...options, type: "diagram" });
1325
- var rmDiagram = (directory) => async (path6) => {
1326
- await import_promises13.default.rm((0, import_node_path19.join)(directory, path6), { recursive: true });
1327
- };
1328
- var rmDiagramById = (directory) => async (id, version, persistFiles) => {
1329
- await rmResourceById(directory, id, version, { type: "diagram", persistFiles });
1330
- };
1331
- var versionDiagram = (directory) => async (id) => versionResource(directory, id);
1332
- var diagramHasVersion = (directory) => async (id, version) => {
1333
- const file = await findFileById(directory, id, version);
1334
- return !!file;
1335
- };
1336
- var addFileToDiagram = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version, { type: "diagram" });
1337
-
1338
- // src/index.ts
1339
- var src_default = (path6) => {
1340
- return {
1341
- /**
1342
- * Returns an events from EventCatalog
1343
- * @param id - The id of the event to retrieve
1344
- * @param version - Optional id of the version to get (supports semver)
1345
- * @returns Event|Undefined
1346
- */
1347
- getEvent: getEvent((0, import_node_path20.join)(path6)),
1348
- /**
1349
- * Returns all events from EventCatalog
1350
- * @param latestOnly - optional boolean, set to true to get only latest versions
1351
- * @returns Event[]|Undefined
1352
- */
1353
- getEvents: getEvents((0, import_node_path20.join)(path6)),
1354
- /**
1355
- * Adds an event to EventCatalog
1356
- *
1357
- * @param event - The event to write
1358
- * @param options - Optional options to write the event
1359
- *
1360
- */
1361
- writeEvent: writeEvent((0, import_node_path20.join)(path6, "events")),
1362
- /**
1363
- * Adds an event to a service in EventCatalog
1364
- *
1365
- * @param event - The event to write to the service
1366
- * @param service - The service and it's id to write to the event to
1367
- * @param options - Optional options to write the event
1368
- *
1369
- */
1370
- writeEventToService: writeEventToService((0, import_node_path20.join)(path6)),
1371
- /**
1372
- * Remove an event to EventCatalog (modeled on the standard POSIX rm utility)
1373
- *
1374
- * @param path - The path to your event, e.g. `/Inventory/InventoryAdjusted`
1375
- *
1376
- */
1377
- rmEvent: rmEvent((0, import_node_path20.join)(path6, "events")),
1378
- /**
1379
- * Remove an event by an Event id
1380
- *
1381
- * @param id - The id of the event you want to remove
1382
- *
1383
- */
1384
- rmEventById: rmEventById((0, import_node_path20.join)(path6)),
1385
- /**
1386
- * Moves a given event id to the version directory
1387
- * @param directory
1388
- */
1389
- versionEvent: versionEvent((0, import_node_path20.join)(path6)),
1390
- /**
1391
- * Adds a file to the given event
1392
- * @param id - The id of the event to add the file to
1393
- * @param file - File contents to add including the content and the file name
1394
- * @param version - Optional version of the event to add the file to
1395
- * @returns
1396
- */
1397
- addFileToEvent: addFileToEvent((0, import_node_path20.join)(path6)),
1398
- /**
1399
- * Adds a schema to the given event
1400
- * @param id - The id of the event to add the schema to
1401
- * @param schema - Schema contents to add including the content and the file name
1402
- * @param version - Optional version of the event to add the schema to
1403
- * @returns
1404
- */
1405
- addSchemaToEvent: addSchemaToEvent((0, import_node_path20.join)(path6)),
1406
- /**
1407
- * Check to see if an event version exists
1408
- * @param id - The id of the event
1409
- * @param version - The version of the event (supports semver)
1410
- * @returns
1411
- */
1412
- eventHasVersion: eventHasVersion((0, import_node_path20.join)(path6)),
1413
- /**
1414
- * ================================
1415
- * Commands
1416
- * ================================
1417
- */
1418
- /**
1419
- * Returns a command from EventCatalog
1420
- * @param id - The id of the command to retrieve
1421
- * @param version - Optional id of the version to get (supports semver)
1422
- * @returns Command|Undefined
1423
- */
1424
- getCommand: getCommand((0, import_node_path20.join)(path6)),
1425
- /**
1426
- * Returns all commands from EventCatalog
1427
- * @param latestOnly - optional boolean, set to true to get only latest versions
1428
- * @returns Command[]|Undefined
1429
- */
1430
- getCommands: getCommands((0, import_node_path20.join)(path6)),
1431
- /**
1432
- * Adds an command to EventCatalog
1433
- *
1434
- * @param command - The command to write
1435
- * @param options - Optional options to write the command
1436
- *
1437
- */
1438
- writeCommand: writeCommand((0, import_node_path20.join)(path6, "commands")),
1439
- /**
1440
- * Adds a command to a service in EventCatalog
1441
- *
1442
- * @param command - The command to write to the service
1443
- * @param service - The service and it's id to write to the command to
1444
- * @param options - Optional options to write the command
1445
- *
1446
- */
1447
- writeCommandToService: writeCommandToService((0, import_node_path20.join)(path6)),
1448
- /**
1449
- * Remove an command to EventCatalog (modeled on the standard POSIX rm utility)
1450
- *
1451
- * @param path - The path to your command, e.g. `/Inventory/InventoryAdjusted`
1452
- *
1453
- */
1454
- rmCommand: rmCommand((0, import_node_path20.join)(path6, "commands")),
1455
- /**
1456
- * Remove an command by an Event id
1457
- *
1458
- * @param id - The id of the command you want to remove
1459
- *
1460
- */
1461
- rmCommandById: rmCommandById((0, import_node_path20.join)(path6)),
1462
- /**
1463
- * Moves a given command id to the version directory
1464
- * @param directory
1465
- */
1466
- versionCommand: versionCommand((0, import_node_path20.join)(path6)),
1467
- /**
1468
- * Adds a file to the given command
1469
- * @param id - The id of the command to add the file to
1470
- * @param file - File contents to add including the content and the file name
1471
- * @param version - Optional version of the command to add the file to
1472
- * @returns
1473
- */
1474
- addFileToCommand: addFileToCommand((0, import_node_path20.join)(path6)),
1475
- /**
1476
- * Adds a schema to the given command
1477
- * @param id - The id of the command to add the schema to
1478
- * @param schema - Schema contents to add including the content and the file name
1479
- * @param version - Optional version of the command to add the schema to
1480
- * @returns
1481
- */
1482
- addSchemaToCommand: addSchemaToCommand((0, import_node_path20.join)(path6)),
1483
- /**
1484
- * Check to see if a command version exists
1485
- * @param id - The id of the command
1486
- * @param version - The version of the command (supports semver)
1487
- * @returns
1488
- */
1489
- commandHasVersion: commandHasVersion((0, import_node_path20.join)(path6)),
1490
- /**
1491
- * ================================
1492
- * Queries
1493
- * ================================
1494
- */
1495
- /**
1496
- * Returns a query from EventCatalog
1497
- * @param id - The id of the query to retrieve
1498
- * @param version - Optional id of the version to get (supports semver)
1499
- * @returns Query|Undefined
1500
- */
1501
- getQuery: getQuery((0, import_node_path20.join)(path6)),
1502
- /**
1503
- * Returns all queries from EventCatalog
1504
- * @param latestOnly - optional boolean, set to true to get only latest versions
1505
- * @returns Query[]|Undefined
1506
- */
1507
- getQueries: getQueries((0, import_node_path20.join)(path6)),
1508
- /**
1509
- * Adds a query to EventCatalog
1510
- *
1511
- * @param query - The query to write
1512
- * @param options - Optional options to write the event
1513
- *
1514
- */
1515
- writeQuery: writeQuery((0, import_node_path20.join)(path6, "queries")),
1516
- /**
1517
- * Adds a query to a service in EventCatalog
1518
- *
1519
- * @param query - The query to write to the service
1520
- * @param service - The service and it's id to write to the query to
1521
- * @param options - Optional options to write the query
1522
- *
1523
- */
1524
- writeQueryToService: writeQueryToService((0, import_node_path20.join)(path6)),
1525
- /**
1526
- * Remove an query to EventCatalog (modeled on the standard POSIX rm utility)
1527
- *
1528
- * @param path - The path to your query, e.g. `/Orders/GetOrder`
1529
- *
1530
- */
1531
- rmQuery: rmQuery((0, import_node_path20.join)(path6, "queries")),
1532
- /**
1533
- * Remove a query by a Query id
1534
- *
1535
- * @param id - The id of the query you want to remove
1536
- *
1537
- */
1538
- rmQueryById: rmQueryById((0, import_node_path20.join)(path6)),
1539
- /**
1540
- * Moves a given query id to the version directory
1541
- * @param directory
1542
- */
1543
- versionQuery: versionQuery((0, import_node_path20.join)(path6)),
1544
- /**
1545
- * Adds a file to the given query
1546
- * @param id - The id of the query to add the file to
1547
- * @param file - File contents to add including the content and the file name
1548
- * @param version - Optional version of the query to add the file to
1549
- * @returns
1550
- */
1551
- addFileToQuery: addFileToQuery((0, import_node_path20.join)(path6)),
1552
- /**
1553
- * Adds a schema to the given query
1554
- * @param id - The id of the query to add the schema to
1555
- * @param schema - Schema contents to add including the content and the file name
1556
- * @param version - Optional version of the query to add the schema to
1557
- * @returns
1558
- */
1559
- addSchemaToQuery: addSchemaToQuery((0, import_node_path20.join)(path6)),
1560
- /**
1561
- * Check to see if an query version exists
1562
- * @param id - The id of the query
1563
- * @param version - The version of the query (supports semver)
1564
- * @returns
1565
- */
1566
- queryHasVersion: queryHasVersion((0, import_node_path20.join)(path6)),
1567
- /**
1568
- * ================================
1569
- * Channels
1570
- * ================================
1571
- */
1572
- /**
1573
- * Returns a channel from EventCatalog
1574
- * @param id - The id of the channel to retrieve
1575
- * @param version - Optional id of the version to get (supports semver)
1576
- * @returns Channel|Undefined
1577
- */
1578
- getChannel: getChannel((0, import_node_path20.join)(path6)),
1579
- /**
1580
- * Returns all channels from EventCatalog
1581
- * @param latestOnly - optional boolean, set to true to get only latest versions
1582
- * @returns Channel[]|Undefined
1583
- */
1584
- getChannels: getChannels((0, import_node_path20.join)(path6)),
1585
- /**
1586
- * Adds an channel to EventCatalog
1587
- *
1588
- * @param command - The channel to write
1589
- * @param options - Optional options to write the channel
1590
- *
1591
- */
1592
- writeChannel: writeChannel((0, import_node_path20.join)(path6, "channels")),
1593
- /**
1594
- * Remove an channel to EventCatalog (modeled on the standard POSIX rm utility)
1595
- *
1596
- * @param path - The path to your channel, e.g. `/Inventory/InventoryAdjusted`
1597
- *
1598
- */
1599
- rmChannel: rmChannel((0, import_node_path20.join)(path6, "channels")),
1600
- /**
1601
- * Remove an channel by an Event id
1602
- *
1603
- * @param id - The id of the channel you want to remove
1604
- *
1605
- */
1606
- rmChannelById: rmChannelById((0, import_node_path20.join)(path6)),
1607
- /**
1608
- * Moves a given channel id to the version directory
1609
- * @param directory
1610
- */
1611
- versionChannel: versionChannel((0, import_node_path20.join)(path6)),
1612
- /**
1613
- * Check to see if a channel version exists
1614
- * @param id - The id of the channel
1615
- * @param version - The version of the channel (supports semver)
1616
- * @returns
1617
- */
1618
- channelHasVersion: channelHasVersion((0, import_node_path20.join)(path6)),
1619
- /**
1620
- * Add a channel to an event
1621
- *
1622
- * Optionally specify a version to add the channel to a specific version of the event.
1623
- *
1624
- * @example
1625
- * ```ts
1626
- * import utils from '@eventcatalog/utils';
1627
- *
1628
- * const { addEventToChannel } = utils('/path/to/eventcatalog');
1629
- *
1630
- * // adds a new event (InventoryUpdatedEvent) to the inventory.{env}.events channel
1631
- * await addEventToChannel('inventory.{env}.events channel', { id: 'InventoryUpdatedEvent', version: '2.0.0', parameters: { env: 'dev' } });
1632
- *
1633
- * ```
1634
- */
1635
- addEventToChannel: addMessageToChannel((0, import_node_path20.join)(path6), "events"),
1636
- /**
1637
- * Add a channel to an command
1638
- *
1639
- * Optionally specify a version to add the channel to a specific version of the command.
1640
- *
1641
- * @example
1642
- * ```ts
1643
- * import utils from '@eventcatalog/utils';
1644
- *
1645
- * const { addCommandToChannel } = utils('/path/to/eventcatalog');
1646
- *
1647
- * // adds a new command (UpdateInventory) to the inventory.{env}.events channel
1648
- * await addCommandToChannel('inventory.{env}.events channel', { id: 'UpdateInventory', version: '2.0.0', parameters: { env: 'dev' } });
1649
- *
1650
- * ```
1651
- */
1652
- addCommandToChannel: addMessageToChannel((0, import_node_path20.join)(path6), "commands"),
1653
- /**
1654
- * Add a channel to an query
1655
- *
1656
- * Optionally specify a version to add the channel to a specific version of the query.
1657
- *
1658
- * @example
1659
- * ```ts
1660
- * import utils from '@eventcatalog/utils';
1661
- *
1662
- * const { addQueryToChannel } = utils('/path/to/eventcatalog');
1663
- *
1664
- * // adds a new query (GetInventory) to the inventory.{env}.events channel
1665
- * await addQueryToChannel('inventory.{env}.events channel', { id: 'GetInventory', version: '2.0.0', parameters: { env: 'dev' } });
1666
- *
1667
- * ```
1668
- */
1669
- addQueryToChannel: addMessageToChannel((0, import_node_path20.join)(path6), "queries"),
1670
- /**
1671
- * ================================
1672
- * SERVICES
1673
- * ================================
1674
- */
1675
- /**
1676
- * Adds a service to EventCatalog
1677
- *
1678
- * @param service - The service to write
1679
- * @param options - Optional options to write the event
1680
- *
1681
- */
1682
- writeService: writeService((0, import_node_path20.join)(path6, "services")),
1683
- /**
1684
- * Adds a versioned service to EventCatalog
1685
- *
1686
- * @param service - The service to write
1687
- *
1688
- */
1689
- writeVersionedService: writeVersionedService((0, import_node_path20.join)(path6, "services")),
1690
- /**
1691
- * Adds a service to a domain in EventCatalog
1692
- *
1693
- * @param service - The service to write
1694
- * @param domain - The domain to add the service to
1695
- * @param options - Optional options to write the event
1696
- *
1697
- */
1698
- writeServiceToDomain: writeServiceToDomain((0, import_node_path20.join)(path6, "domains")),
1699
- /**
1700
- * Returns a service from EventCatalog
1701
- * @param id - The id of the service to retrieve
1702
- * @param version - Optional id of the version to get (supports semver)
1703
- * @returns Service|Undefined
1704
- */
1705
- getService: getService((0, import_node_path20.join)(path6)),
1706
- /**
1707
- * Returns a service from EventCatalog by it's path.
1708
- * @param path - The path to the service to retrieve
1709
- * @returns Service|Undefined
1710
- */
1711
- getServiceByPath: getServiceByPath((0, import_node_path20.join)(path6)),
1712
- /**
1713
- * Returns all services from EventCatalog
1714
- * @param latestOnly - optional boolean, set to true to get only latest versions
1715
- * @returns Service[]|Undefined
1716
- */
1717
- getServices: getServices((0, import_node_path20.join)(path6)),
1718
- /**
1719
- * Moves a given service id to the version directory
1720
- * @param directory
1721
- */
1722
- versionService: versionService((0, import_node_path20.join)(path6)),
1723
- /**
1724
- * Remove a service from EventCatalog (modeled on the standard POSIX rm utility)
1725
- *
1726
- * @param path - The path to your service, e.g. `/InventoryService`
1727
- *
1728
- */
1729
- rmService: rmService((0, import_node_path20.join)(path6, "services")),
1730
- /**
1731
- * Remove an service by an service id
1732
- *
1733
- * @param id - The id of the service you want to remove
1734
- *
1735
- */
1736
- rmServiceById: rmServiceById((0, import_node_path20.join)(path6)),
1737
- /**
1738
- * Adds a file to the given service
1739
- * @param id - The id of the service to add the file to
1740
- * @param file - File contents to add including the content and the file name
1741
- * @param version - Optional version of the service to add the file to
1742
- * @returns
1743
- */
1744
- addFileToService: addFileToService((0, import_node_path20.join)(path6)),
1745
- /**
1746
- * Returns the specifications for a given service
1747
- * @param id - The id of the service to retrieve the specifications for
1748
- * @param version - Optional version of the service
1749
- * @returns
1750
- */
1751
- getSpecificationFilesForService: getSpecificationFilesForService((0, import_node_path20.join)(path6)),
1752
- /**
1753
- * Check to see if a service version exists
1754
- * @param id - The id of the service
1755
- * @param version - The version of the service (supports semver)
1756
- * @returns
1757
- */
1758
- serviceHasVersion: serviceHasVersion((0, import_node_path20.join)(path6)),
1759
- /**
1760
- * Add an event to a service by it's id.
1761
- *
1762
- * Optionally specify a version to add the event to a specific version of the service.
1763
- *
1764
- * @example
1765
- * ```ts
1766
- * import utils from '@eventcatalog/utils';
1767
- *
1768
- * const { addEventToService } = utils('/path/to/eventcatalog');
1769
- *
1770
- * // adds a new event (InventoryUpdatedEvent) that the InventoryService will send
1771
- * await addEventToService('InventoryService', 'sends', { event: 'InventoryUpdatedEvent', version: '2.0.0' });
1772
- *
1773
- * // adds a new event (OrderComplete) that the InventoryService will receive
1774
- * await addEventToService('InventoryService', 'receives', { event: 'OrderComplete', version: '2.0.0' });
1775
- *
1776
- * ```
1777
- */
1778
- addEventToService: addMessageToService((0, import_node_path20.join)(path6)),
1779
- /**
1780
- * Add a data store to a service by it's id.
1781
- *
1782
- * Optionally specify a version to add the data store to a specific version of the service.
1783
- *
1784
- * @example
1785
- * ```ts
1786
- * import utils from '@eventcatalog/utils';
1787
- *
1788
- * const { addDataStoreToService } = utils('/path/to/eventcatalog');
1789
- *
1790
- * // adds a new data store (orders-db) that the InventoryService will write to
1791
- * await addDataStoreToService('InventoryService', 'writesTo', { id: 'orders-db', version: '2.0.0' });
1792
- *
1793
- * ```
1794
- */
1795
- addDataStoreToService: addDataStoreToService((0, import_node_path20.join)(path6)),
1796
- /**
1797
- * Add a command to a service by it's id.
1798
- *
1799
- * Optionally specify a version to add the event to a specific version of the service.
1800
- *
1801
- * @example
1802
- * ```ts
1803
- * import utils from '@eventcatalog/utils';
1804
- *
1805
- * const { addCommandToService } = utils('/path/to/eventcatalog');
1806
- *
1807
- * // adds a new command (UpdateInventoryCommand) that the InventoryService will send
1808
- * await addCommandToService('InventoryService', 'sends', { command: 'UpdateInventoryCommand', version: '2.0.0' });
1809
- *
1810
- * // adds a new command (VerifyInventory) that the InventoryService will receive
1811
- * await addCommandToService('InventoryService', 'receives', { command: 'VerifyInventory', version: '2.0.0' });
1812
- *
1813
- * ```
1814
- */
1815
- addCommandToService: addMessageToService((0, import_node_path20.join)(path6)),
1816
- /**
1817
- * Add a query to a service by it's id.
1818
- *
1819
- * Optionally specify a version to add the event to a specific version of the service.
1820
- *
1821
- * @example
1822
- * ```ts
1823
- * import utils from '@eventcatalog/utils';
1824
- *
1825
- * const { addQueryToService } = utils('/path/to/eventcatalog');
1826
- *
1827
- * // adds a new query (UpdateInventory) that the InventoryService will send
1828
- * await addQueryToService('InventoryService', 'sends', { command: 'UpdateInventory', version: '2.0.0' });
1829
- *
1830
- * // adds a new command (VerifyInventory) that the InventoryService will receive
1831
- * await addQueryToService('InventoryService', 'receives', { command: 'VerifyInventory', version: '2.0.0' });
1832
- *
1833
- * ```
1834
- */
1835
- addQueryToService: addMessageToService((0, import_node_path20.join)(path6)),
1836
- /**
1837
- * Add an entity to a service by its id.
1838
- *
1839
- * @example
1840
- * ```ts
1841
- * import utils from '@eventcatalog/utils';
1842
- *
1843
- * const { addEntityToService } = utils('/path/to/eventcatalog');
1844
- *
1845
- * // adds a new entity (User) to the InventoryService
1846
- * await addEntityToService('InventoryService', { id: 'User', version: '1.0.0' });
1847
- *
1848
- * // adds a new entity (Product) to a specific version of the InventoryService
1849
- * await addEntityToService('InventoryService', { id: 'Product', version: '1.0.0' }, '2.0.0');
1850
- *
1851
- * ```
1852
- */
1853
- addEntityToService: addEntityToService((0, import_node_path20.join)(path6)),
1854
- /**
1855
- * Check to see if a service exists by it's path.
1856
- *
1857
- * @example
1858
- * ```ts
1859
- * import utils from '@eventcatalog/utils';
1860
- *
1861
- * const { isService } = utils('/path/to/eventcatalog');
1862
- *
1863
- * // returns true if the path is a service
1864
- * await isService('/services/InventoryService/index.mdx');
1865
- * ```
1866
- *
1867
- * @param path - The path to the service to check
1868
- * @returns boolean
1869
- */
1870
- isService: isService((0, import_node_path20.join)(path6)),
1871
- /**
1872
- * Converts a file to a service.
1873
- * @param file - The file to convert to a service.
1874
- * @returns The service.
1875
- */
1876
- toService: toService((0, import_node_path20.join)(path6)),
1877
- /**
1878
- * ================================
1879
- * Domains
1880
- * ================================
1881
- */
1882
- /**
1883
- * Adds a domain to EventCatalog
1884
- *
1885
- * @param domain - The domain to write
1886
- * @param options - Optional options to write the event
1887
- *
1888
- */
1889
- writeDomain: writeDomain((0, import_node_path20.join)(path6, "domains")),
1890
- /**
1891
- * Returns a domain from EventCatalog
1892
- * @param id - The id of the domain to retrieve
1893
- * @param version - Optional id of the version to get (supports semver)
1894
- * @returns Domain|Undefined
1895
- */
1896
- getDomain: getDomain((0, import_node_path20.join)(path6, "domains")),
1897
- /**
1898
- * Returns all domains from EventCatalog
1899
- * @param latestOnly - optional boolean, set to true to get only latest versions
1900
- * @returns Domain[]|Undefined
1901
- */
1902
- getDomains: getDomains((0, import_node_path20.join)(path6)),
1903
- /**
1904
- * Moves a given domain id to the version directory
1905
- * @param directory
1906
- */
1907
- versionDomain: versionDomain((0, import_node_path20.join)(path6, "domains")),
1908
- /**
1909
- * Remove a domain from EventCatalog (modeled on the standard POSIX rm utility)
1910
- *
1911
- * @param path - The path to your domain, e.g. `/Payment`
1912
- *
1913
- */
1914
- rmDomain: rmDomain((0, import_node_path20.join)(path6, "domains")),
1915
- /**
1916
- * Remove an service by an domain id
1917
- *
1918
- * @param id - The id of the domain you want to remove
1919
- *
1920
- */
1921
- rmDomainById: rmDomainById((0, import_node_path20.join)(path6, "domains")),
1922
- /**
1923
- * Adds a file to the given domain
1924
- * @param id - The id of the domain to add the file to
1925
- * @param file - File contents to add including the content and the file name
1926
- * @param version - Optional version of the domain to add the file to
1927
- * @returns
1928
- */
1929
- addFileToDomain: addFileToDomain((0, import_node_path20.join)(path6, "domains")),
1930
- /**
1931
- * Adds an ubiquitous language dictionary to a domain
1932
- * @param id - The id of the domain to add the ubiquitous language to
1933
- * @param ubiquitousLanguageDictionary - The ubiquitous language dictionary to add
1934
- * @param version - Optional version of the domain to add the ubiquitous language to
1935
- */
1936
- addUbiquitousLanguageToDomain: addUbiquitousLanguageToDomain((0, import_node_path20.join)(path6, "domains")),
1937
- /**
1938
- * Get the ubiquitous language dictionary from a domain
1939
- * @param id - The id of the domain to get the ubiquitous language from
1940
- * @param version - Optional version of the domain to get the ubiquitous language from
1941
- * @returns
1942
- */
1943
- getUbiquitousLanguageFromDomain: getUbiquitousLanguageFromDomain((0, import_node_path20.join)(path6, "domains")),
1944
- /**
1945
- * Check to see if a domain version exists
1946
- * @param id - The id of the domain
1947
- * @param version - The version of the domain (supports semver)
1948
- * @returns
1949
- */
1950
- domainHasVersion: domainHasVersion((0, import_node_path20.join)(path6)),
1951
- /**
1952
- * Adds a given service to a domain
1953
- * @param id - The id of the domain
1954
- * @param service - The id and version of the service to add
1955
- * @param version - (Optional) The version of the domain to add the service to
1956
- * @returns
1957
- */
1958
- addServiceToDomain: addServiceToDomain((0, import_node_path20.join)(path6, "domains")),
1959
- /**
1960
- * Adds a given subdomain to a domain
1961
- * @param id - The id of the domain
1962
- * @param subDomain - The id and version of the subdomain to add
1963
- * @param version - (Optional) The version of the domain to add the subdomain to
1964
- * @returns
1965
- */
1966
- addSubDomainToDomain: addSubDomainToDomain((0, import_node_path20.join)(path6, "domains")),
1967
- /**
1968
- * Adds an entity to a domain
1969
- * @param id - The id of the domain
1970
- * @param entity - The id and version of the entity to add
1971
- * @param version - (Optional) The version of the domain to add the entity to
1972
- * @returns
1973
- */
1974
- addEntityToDomain: addEntityToDomain((0, import_node_path20.join)(path6, "domains")),
1975
- /**
1976
- * Add an event to a domain by its id.
1977
- *
1978
- * @example
1979
- * ```ts
1980
- * import utils from '@eventcatalog/utils';
1981
- *
1982
- * const { addEventToDomain } = utils('/path/to/eventcatalog');
1983
- *
1984
- * // adds a new event (OrderCreated) that the Orders domain will send
1985
- * await addEventToDomain('Orders', 'sends', { id: 'OrderCreated', version: '2.0.0' });
1986
- *
1987
- * // adds a new event (PaymentProcessed) that the Orders domain will receive
1988
- * await addEventToDomain('Orders', 'receives', { id: 'PaymentProcessed', version: '2.0.0' });
1989
- *
1990
- * ```
1991
- */
1992
- addEventToDomain: addMessageToDomain((0, import_node_path20.join)(path6, "domains")),
1993
- /**
1994
- * Add a command to a domain by its id.
1995
- *
1996
- * @example
1997
- * ```ts
1998
- * import utils from '@eventcatalog/utils';
1999
- *
2000
- * const { addCommandToDomain } = utils('/path/to/eventcatalog');
2001
- *
2002
- * // adds a new command (ProcessOrder) that the Orders domain will send
2003
- * await addCommandToDomain('Orders', 'sends', { id: 'ProcessOrder', version: '2.0.0' });
2004
- *
2005
- * // adds a new command (CancelOrder) that the Orders domain will receive
2006
- * await addCommandToDomain('Orders', 'receives', { id: 'CancelOrder', version: '2.0.0' });
2007
- *
2008
- * ```
2009
- */
2010
- addCommandToDomain: addMessageToDomain((0, import_node_path20.join)(path6, "domains")),
2011
- /**
2012
- * Add a query to a domain by its id.
2013
- *
2014
- * @example
2015
- * ```ts
2016
- * import utils from '@eventcatalog/utils';
2017
- *
2018
- * const { addQueryToDomain } = utils('/path/to/eventcatalog');
2019
- *
2020
- * // adds a new query (GetOrderStatus) that the Orders domain will send
2021
- * await addQueryToDomain('Orders', 'sends', { id: 'GetOrderStatus', version: '2.0.0' });
2022
- *
2023
- * // adds a new query (GetInventory) that the Orders domain will receive
2024
- * await addQueryToDomain('Orders', 'receives', { id: 'GetInventory', version: '2.0.0' });
2025
- *
2026
- * ```
2027
- */
2028
- addQueryToDomain: addMessageToDomain((0, import_node_path20.join)(path6, "domains")),
2029
- /**
2030
- * ================================
2031
- * Teams
2032
- * ================================
2033
- */
2034
- /**
2035
- * Adds a team to EventCatalog
2036
- *
2037
- * @param team - The team to write
2038
- * @param options - Optional options to write the team
2039
- *
2040
- */
2041
- writeTeam: writeTeam((0, import_node_path20.join)(path6, "teams")),
2042
- /**
2043
- * Returns a team from EventCatalog
2044
- * @param id - The id of the team to retrieve
2045
- * @returns Team|Undefined
2046
- */
2047
- getTeam: getTeam((0, import_node_path20.join)(path6, "teams")),
2048
- /**
2049
- * Returns all teams from EventCatalog
2050
- * @returns Team[]|Undefined
2051
- */
2052
- getTeams: getTeams((0, import_node_path20.join)(path6, "teams")),
2053
- /**
2054
- * Remove a team by the team id
2055
- *
2056
- * @param id - The id of the team you want to remove
2057
- *
2058
- */
2059
- rmTeamById: rmTeamById((0, import_node_path20.join)(path6, "teams")),
2060
- /**
2061
- * ================================
2062
- * Users
2063
- * ================================
2064
- */
2065
- /**
2066
- * Adds a user to EventCatalog
2067
- *
2068
- * @param user - The user to write
2069
- * @param options - Optional options to write the user
2070
- *
2071
- */
2072
- writeUser: writeUser((0, import_node_path20.join)(path6, "users")),
2073
- /**
2074
- * Returns a user from EventCatalog
2075
- * @param id - The id of the user to retrieve
2076
- * @returns User|Undefined
2077
- */
2078
- getUser: getUser((0, import_node_path20.join)(path6, "users")),
2079
- /**
2080
- * Returns all user from EventCatalog
2081
- * @returns User[]|Undefined
2082
- */
2083
- getUsers: getUsers((0, import_node_path20.join)(path6)),
2084
- /**
2085
- * Remove a user by the user id
2086
- *
2087
- * @param id - The id of the user you want to remove
2088
- *
2089
- */
2090
- rmUserById: rmUserById((0, import_node_path20.join)(path6, "users")),
2091
- /**
2092
- * ================================
2093
- * Custom Docs
2094
- * ================================
2095
- */
2096
- /**
2097
- * Returns a custom doc from EventCatalog
2098
- * @param path - The path to the custom doc to retrieve
2099
- * @returns CustomDoc|Undefined
2100
- */
2101
- getCustomDoc: getCustomDoc((0, import_node_path20.join)(path6, "docs")),
2102
- /**
2103
- * Returns all custom docs from EventCatalog
2104
- * @param options - Optional options to get custom docs from a specific path
2105
- * @returns CustomDoc[]|Undefined
2106
- */
2107
- getCustomDocs: getCustomDocs((0, import_node_path20.join)(path6, "docs")),
2108
- /**
2109
- * Writes a custom doc to EventCatalog
2110
- * @param customDoc - The custom doc to write
2111
- * @param options - Optional options to write the custom doc
2112
- *
2113
- */
2114
- writeCustomDoc: writeCustomDoc((0, import_node_path20.join)(path6, "docs")),
2115
- /**
2116
- * Removes a custom doc from EventCatalog
2117
- * @param path - The path to the custom doc to remove
2118
- *
2119
- */
2120
- rmCustomDoc: rmCustomDoc((0, import_node_path20.join)(path6, "docs")),
2121
- /**
2122
- * Dumps the catalog to a JSON file.
2123
- * @param directory - The directory to dump the catalog to
2124
- * @returns A JSON file with the catalog
2125
- */
2126
- dumpCatalog: dumpCatalog((0, import_node_path20.join)(path6)),
2127
- /**
2128
- * Returns the event catalog configuration file.
2129
- * The event catalog configuration file is the file that contains the configuration for the event catalog.
2130
- *
2131
- * @param directory - The directory of the catalog.
2132
- * @returns A JSON object with the configuration for the event catalog.
2133
- */
2134
- getEventCatalogConfigurationFile: getEventCatalogConfigurationFile((0, import_node_path20.join)(path6)),
2135
- /**
2136
- * ================================
2137
- * Resources Utils
2138
- * ================================
2139
- */
2140
- /**
2141
- * Returns the path to a given resource by id and version
2142
- */
2143
- getResourcePath,
2144
- /**
2145
- * Returns the folder name of a given resource
2146
- */
2147
- getResourceFolderName,
2148
- /**
2149
- * ================================
2150
- * General Message Utils
2151
- * ================================
2152
- */
2153
- /**
2154
- * Returns a message from EventCatalog by a given schema path.
2155
- *
2156
- * @param path - The path to the message to retrieve
2157
- * @returns Message|Undefined
2158
- */
2159
- getMessageBySchemaPath: getMessageBySchemaPath((0, import_node_path20.join)(path6)),
2160
- /**
2161
- * Returns the producers and consumers (services) for a given message
2162
- * @param id - The id of the message to get the producers and consumers for
2163
- * @param version - Optional version of the message
2164
- * @returns { producers: Service[], consumers: Service[] }
2165
- */
2166
- getProducersAndConsumersForMessage: getProducersAndConsumersForMessage((0, import_node_path20.join)(path6)),
2167
- /**
2168
- * Returns the consumers of a given schema path
2169
- * @param path - The path to the schema to get the consumers for
2170
- * @returns Service[]
2171
- */
2172
- getConsumersOfSchema: getConsumersOfSchema((0, import_node_path20.join)(path6)),
2173
- /**
2174
- * Returns the producers of a given schema path
2175
- * @param path - The path to the schema to get the producers for
2176
- * @returns Service[]
2177
- */
2178
- getProducersOfSchema: getProducersOfSchema((0, import_node_path20.join)(path6)),
2179
- /**
2180
- * Returns the owners for a given resource (e.g domain, service, event, command, query, etc.)
2181
- * @param id - The id of the resource to get the owners for
2182
- * @param version - Optional version of the resource
2183
- * @returns { owners: User[] }
2184
- */
2185
- getOwnersForResource: getOwnersForResource((0, import_node_path20.join)(path6)),
2186
- /**
2187
- * ================================
2188
- * Entities
2189
- * ================================
2190
- */
2191
- /**
2192
- * Returns an entity from EventCatalog
2193
- * @param id - The id of the entity to retrieve
2194
- * @param version - Optional id of the version to get (supports semver)
2195
- * @returns Entity|Undefined
2196
- */
2197
- getEntity: getEntity((0, import_node_path20.join)(path6)),
2198
- /**
2199
- * Returns all entities from EventCatalog
2200
- * @param latestOnly - optional boolean, set to true to get only latest versions
2201
- * @returns Entity[]|Undefined
2202
- */
2203
- getEntities: getEntities((0, import_node_path20.join)(path6)),
2204
- /**
2205
- * Adds an entity to EventCatalog
2206
- *
2207
- * @param entity - The entity to write
2208
- * @param options - Optional options to write the entity
2209
- *
2210
- */
2211
- writeEntity: writeEntity((0, import_node_path20.join)(path6, "entities")),
2212
- /**
2213
- * Remove an entity from EventCatalog (modeled on the standard POSIX rm utility)
2214
- *
2215
- * @param path - The path to your entity, e.g. `/User`
2216
- *
2217
- */
2218
- rmEntity: rmEntity((0, import_node_path20.join)(path6, "entities")),
2219
- /**
2220
- * Remove an entity by an entity id
2221
- *
2222
- * @param id - The id of the entity you want to remove
2223
- *
2224
- */
2225
- rmEntityById: rmEntityById((0, import_node_path20.join)(path6)),
2226
- /**
2227
- * Moves a given entity id to the version directory
2228
- * @param id - The id of the entity to version
2229
- */
2230
- versionEntity: versionEntity((0, import_node_path20.join)(path6)),
2231
- /**
2232
- * Check to see if an entity version exists
2233
- * @param id - The id of the entity
2234
- * @param version - The version of the entity (supports semver)
2235
- * @returns
2236
- */
2237
- entityHasVersion: entityHasVersion((0, import_node_path20.join)(path6)),
2238
- /**
2239
- * ================================
2240
- * Data Stores
2241
- * ================================
2242
- */
2243
- /**
2244
- * Adds a data store to EventCatalog
2245
- * @param dataStore - The data store to write
2246
- * @param options - Optional options to write the data store
2247
- *
2248
- */
2249
- writeDataStore: writeDataStore((0, import_node_path20.join)(path6, "containers")),
2250
- /**
2251
- * Returns a data store from EventCatalog
2252
- * @param id - The id of the data store to retrieve
2253
- * @param version - Optional id of the version to get (supports semver)
2254
- * @returns Container|Undefined
2255
- */
2256
- getDataStore: getDataStore((0, import_node_path20.join)(path6)),
2257
- /**
2258
- * Returns all data stores from EventCatalog
2259
- * @param latestOnly - optional boolean, set to true to get only latest versions
2260
- * @returns Container[]|Undefined
2261
- */
2262
- getDataStores: getDataStores((0, import_node_path20.join)(path6)),
2263
- /**
2264
- * Version a data store by its id
2265
- * @param id - The id of the data store to version
2266
- */
2267
- versionDataStore: versionDataStore((0, import_node_path20.join)(path6, "containers")),
2268
- /**
2269
- * Remove a data store by its path
2270
- * @param path - The path to the data store to remove
2271
- */
2272
- rmDataStore: rmDataStore((0, import_node_path20.join)(path6, "containers")),
2273
- /**
2274
- * Remove a data store by its id
2275
- * @param id - The id of the data store to remove
2276
- */
2277
- rmDataStoreById: rmDataStoreById((0, import_node_path20.join)(path6)),
2278
- /**
2279
- * Check to see if a data store version exists
2280
- * @param id - The id of the data store
2281
- * @param version - The version of the data store (supports semver)
2282
- * @returns
2283
- */
2284
- dataStoreHasVersion: dataStoreHasVersion((0, import_node_path20.join)(path6)),
2285
- /**
2286
- * Adds a file to a data store by its id
2287
- * @param id - The id of the data store to add the file to
2288
- * @param file - File contents to add including the content and the file name
2289
- * @param version - Optional version of the data store to add the file to
2290
- * @returns
2291
- */
2292
- addFileToDataStore: addFileToDataStore((0, import_node_path20.join)(path6)),
2293
- /**
2294
- * Writes a data store to a service by its id
2295
- * @param dataStore - The data store to write
2296
- * @param service - The service to write the data store to
2297
- * @returns
2298
- */
2299
- writeDataStoreToService: writeDataStoreToService((0, import_node_path20.join)(path6)),
2300
- /**
2301
- * ================================
2302
- * Data Products
2303
- * ================================
2304
- */
2305
- /**
2306
- * Adds a data product to EventCatalog
2307
- * @param dataProduct - The data product to write
2308
- * @param options - Optional options to write the data product
2309
- *
2310
- */
2311
- writeDataProduct: writeDataProduct((0, import_node_path20.join)(path6, "data-products")),
2312
- /**
2313
- * Writes a data product to a domain in EventCatalog
2314
- * @param dataProduct - The data product to write
2315
- * @param domain - The domain to write the data product to
2316
- * @param options - Optional options to write the data product
2317
- *
2318
- */
2319
- writeDataProductToDomain: writeDataProductToDomain((0, import_node_path20.join)(path6, "domains")),
2320
- /**
2321
- * Returns a data product from EventCatalog
2322
- * @param id - The id of the data product to retrieve
2323
- * @param version - Optional id of the version to get (supports semver)
2324
- * @returns DataProduct|Undefined
2325
- */
2326
- getDataProduct: getDataProduct((0, import_node_path20.join)(path6)),
2327
- /**
2328
- * Returns all data products from EventCatalog
2329
- * @param latestOnly - optional boolean, set to true to get only latest versions
2330
- * @returns DataProduct[]|Undefined
2331
- */
2332
- getDataProducts: getDataProducts((0, import_node_path20.join)(path6)),
2333
- /**
2334
- * Version a data product by its id
2335
- * @param id - The id of the data product to version
2336
- */
2337
- versionDataProduct: versionDataProduct((0, import_node_path20.join)(path6)),
2338
- /**
2339
- * Remove a data product by its path
2340
- * @param path - The path to the data product to remove
2341
- */
2342
- rmDataProduct: rmDataProduct((0, import_node_path20.join)(path6, "data-products")),
2343
- /**
2344
- * Remove a data product by its id
2345
- * @param id - The id of the data product to remove
2346
- * @param version - Optional version of the data product to remove
2347
- */
2348
- rmDataProductById: rmDataProductById((0, import_node_path20.join)(path6)),
2349
- /**
2350
- * Check to see if a data product version exists
2351
- * @param id - The id of the data product
2352
- * @param version - The version of the data product (supports semver)
2353
- * @returns
2354
- */
2355
- dataProductHasVersion: dataProductHasVersion((0, import_node_path20.join)(path6)),
2356
- /**
2357
- * Adds a file to a data product by its id
2358
- * @param id - The id of the data product to add the file to
2359
- * @param file - File contents to add including the content and the file name
2360
- * @param version - Optional version of the data product to add the file to
2361
- * @returns
2362
- */
2363
- addFileToDataProduct: addFileToDataProduct((0, import_node_path20.join)(path6)),
2364
- /**
2365
- * Adds a data product to a domain
2366
- * @param id - The id of the domain
2367
- * @param dataProduct - The id and version of the data product to add
2368
- * @param version - (Optional) The version of the domain to add the data product to
2369
- * @returns
2370
- */
2371
- addDataProductToDomain: addDataProductToDomain((0, import_node_path20.join)(path6, "domains")),
2372
- /**
2373
- * ================================
2374
- * Diagrams
2375
- * ================================
2376
- */
2377
- /**
2378
- * Returns a diagram from EventCatalog
2379
- * @param id - The id of the diagram to retrieve
2380
- * @param version - Optional id of the version to get (supports semver)
2381
- * @returns Diagram|Undefined
2382
- */
2383
- getDiagram: getDiagram((0, import_node_path20.join)(path6)),
2384
- /**
2385
- * Returns all diagrams from EventCatalog
2386
- * @param latestOnly - optional boolean, set to true to get only latest versions
2387
- * @returns Diagram[]|Undefined
2388
- */
2389
- getDiagrams: getDiagrams((0, import_node_path20.join)(path6)),
2390
- /**
2391
- * Adds a diagram to EventCatalog
2392
- *
2393
- * @param diagram - The diagram to write
2394
- * @param options - Optional options to write the diagram
2395
- *
2396
- */
2397
- writeDiagram: writeDiagram((0, import_node_path20.join)(path6, "diagrams")),
2398
- /**
2399
- * Remove a diagram from EventCatalog (modeled on the standard POSIX rm utility)
2400
- *
2401
- * @param path - The path to your diagram, e.g. `/ArchitectureDiagram`
2402
- *
2403
- */
2404
- rmDiagram: rmDiagram((0, import_node_path20.join)(path6, "diagrams")),
2405
- /**
2406
- * Remove a diagram by a diagram id
2407
- *
2408
- * @param id - The id of the diagram you want to remove
2409
- *
2410
- */
2411
- rmDiagramById: rmDiagramById((0, import_node_path20.join)(path6)),
2412
- /**
2413
- * Moves a given diagram id to the version directory
2414
- * @param id - The id of the diagram to version
2415
- */
2416
- versionDiagram: versionDiagram((0, import_node_path20.join)(path6)),
2417
- /**
2418
- * Check to see if a diagram version exists
2419
- * @param id - The id of the diagram
2420
- * @param version - The version of the diagram (supports semver)
2421
- * @returns
2422
- */
2423
- diagramHasVersion: diagramHasVersion((0, import_node_path20.join)(path6)),
2424
- /**
2425
- * Adds a file to the given diagram
2426
- * @param id - The id of the diagram to add the file to
2427
- * @param file - File contents to add including the content and the file name
2428
- * @param version - Optional version of the diagram to add the file to
2429
- * @returns
2430
- */
2431
- addFileToDiagram: addFileToDiagram((0, import_node_path20.join)(path6))
2432
- };
2433
- };
2434
- //# sourceMappingURL=index.js.map