@eventcatalog/sdk 2.12.0 → 2.13.0-beta.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,2351 +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_path19 = 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/index.ts
1316
- var src_default = (path6) => {
1317
- return {
1318
- /**
1319
- * Returns an events from EventCatalog
1320
- * @param id - The id of the event to retrieve
1321
- * @param version - Optional id of the version to get (supports semver)
1322
- * @returns Event|Undefined
1323
- */
1324
- getEvent: getEvent((0, import_node_path19.join)(path6)),
1325
- /**
1326
- * Returns all events from EventCatalog
1327
- * @param latestOnly - optional boolean, set to true to get only latest versions
1328
- * @returns Event[]|Undefined
1329
- */
1330
- getEvents: getEvents((0, import_node_path19.join)(path6)),
1331
- /**
1332
- * Adds an event to EventCatalog
1333
- *
1334
- * @param event - The event to write
1335
- * @param options - Optional options to write the event
1336
- *
1337
- */
1338
- writeEvent: writeEvent((0, import_node_path19.join)(path6, "events")),
1339
- /**
1340
- * Adds an event to a service in EventCatalog
1341
- *
1342
- * @param event - The event to write to the service
1343
- * @param service - The service and it's id to write to the event to
1344
- * @param options - Optional options to write the event
1345
- *
1346
- */
1347
- writeEventToService: writeEventToService((0, import_node_path19.join)(path6)),
1348
- /**
1349
- * Remove an event to EventCatalog (modeled on the standard POSIX rm utility)
1350
- *
1351
- * @param path - The path to your event, e.g. `/Inventory/InventoryAdjusted`
1352
- *
1353
- */
1354
- rmEvent: rmEvent((0, import_node_path19.join)(path6, "events")),
1355
- /**
1356
- * Remove an event by an Event id
1357
- *
1358
- * @param id - The id of the event you want to remove
1359
- *
1360
- */
1361
- rmEventById: rmEventById((0, import_node_path19.join)(path6)),
1362
- /**
1363
- * Moves a given event id to the version directory
1364
- * @param directory
1365
- */
1366
- versionEvent: versionEvent((0, import_node_path19.join)(path6)),
1367
- /**
1368
- * Adds a file to the given event
1369
- * @param id - The id of the event to add the file to
1370
- * @param file - File contents to add including the content and the file name
1371
- * @param version - Optional version of the event to add the file to
1372
- * @returns
1373
- */
1374
- addFileToEvent: addFileToEvent((0, import_node_path19.join)(path6)),
1375
- /**
1376
- * Adds a schema to the given event
1377
- * @param id - The id of the event to add the schema to
1378
- * @param schema - Schema contents to add including the content and the file name
1379
- * @param version - Optional version of the event to add the schema to
1380
- * @returns
1381
- */
1382
- addSchemaToEvent: addSchemaToEvent((0, import_node_path19.join)(path6)),
1383
- /**
1384
- * Check to see if an event version exists
1385
- * @param id - The id of the event
1386
- * @param version - The version of the event (supports semver)
1387
- * @returns
1388
- */
1389
- eventHasVersion: eventHasVersion((0, import_node_path19.join)(path6)),
1390
- /**
1391
- * ================================
1392
- * Commands
1393
- * ================================
1394
- */
1395
- /**
1396
- * Returns a command from EventCatalog
1397
- * @param id - The id of the command to retrieve
1398
- * @param version - Optional id of the version to get (supports semver)
1399
- * @returns Command|Undefined
1400
- */
1401
- getCommand: getCommand((0, import_node_path19.join)(path6)),
1402
- /**
1403
- * Returns all commands from EventCatalog
1404
- * @param latestOnly - optional boolean, set to true to get only latest versions
1405
- * @returns Command[]|Undefined
1406
- */
1407
- getCommands: getCommands((0, import_node_path19.join)(path6)),
1408
- /**
1409
- * Adds an command to EventCatalog
1410
- *
1411
- * @param command - The command to write
1412
- * @param options - Optional options to write the command
1413
- *
1414
- */
1415
- writeCommand: writeCommand((0, import_node_path19.join)(path6, "commands")),
1416
- /**
1417
- * Adds a command to a service in EventCatalog
1418
- *
1419
- * @param command - The command to write to the service
1420
- * @param service - The service and it's id to write to the command to
1421
- * @param options - Optional options to write the command
1422
- *
1423
- */
1424
- writeCommandToService: writeCommandToService((0, import_node_path19.join)(path6)),
1425
- /**
1426
- * Remove an command to EventCatalog (modeled on the standard POSIX rm utility)
1427
- *
1428
- * @param path - The path to your command, e.g. `/Inventory/InventoryAdjusted`
1429
- *
1430
- */
1431
- rmCommand: rmCommand((0, import_node_path19.join)(path6, "commands")),
1432
- /**
1433
- * Remove an command by an Event id
1434
- *
1435
- * @param id - The id of the command you want to remove
1436
- *
1437
- */
1438
- rmCommandById: rmCommandById((0, import_node_path19.join)(path6)),
1439
- /**
1440
- * Moves a given command id to the version directory
1441
- * @param directory
1442
- */
1443
- versionCommand: versionCommand((0, import_node_path19.join)(path6)),
1444
- /**
1445
- * Adds a file to the given command
1446
- * @param id - The id of the command to add the file to
1447
- * @param file - File contents to add including the content and the file name
1448
- * @param version - Optional version of the command to add the file to
1449
- * @returns
1450
- */
1451
- addFileToCommand: addFileToCommand((0, import_node_path19.join)(path6)),
1452
- /**
1453
- * Adds a schema to the given command
1454
- * @param id - The id of the command to add the schema to
1455
- * @param schema - Schema contents to add including the content and the file name
1456
- * @param version - Optional version of the command to add the schema to
1457
- * @returns
1458
- */
1459
- addSchemaToCommand: addSchemaToCommand((0, import_node_path19.join)(path6)),
1460
- /**
1461
- * Check to see if a command version exists
1462
- * @param id - The id of the command
1463
- * @param version - The version of the command (supports semver)
1464
- * @returns
1465
- */
1466
- commandHasVersion: commandHasVersion((0, import_node_path19.join)(path6)),
1467
- /**
1468
- * ================================
1469
- * Queries
1470
- * ================================
1471
- */
1472
- /**
1473
- * Returns a query from EventCatalog
1474
- * @param id - The id of the query to retrieve
1475
- * @param version - Optional id of the version to get (supports semver)
1476
- * @returns Query|Undefined
1477
- */
1478
- getQuery: getQuery((0, import_node_path19.join)(path6)),
1479
- /**
1480
- * Returns all queries from EventCatalog
1481
- * @param latestOnly - optional boolean, set to true to get only latest versions
1482
- * @returns Query[]|Undefined
1483
- */
1484
- getQueries: getQueries((0, import_node_path19.join)(path6)),
1485
- /**
1486
- * Adds a query to EventCatalog
1487
- *
1488
- * @param query - The query to write
1489
- * @param options - Optional options to write the event
1490
- *
1491
- */
1492
- writeQuery: writeQuery((0, import_node_path19.join)(path6, "queries")),
1493
- /**
1494
- * Adds a query to a service in EventCatalog
1495
- *
1496
- * @param query - The query to write to the service
1497
- * @param service - The service and it's id to write to the query to
1498
- * @param options - Optional options to write the query
1499
- *
1500
- */
1501
- writeQueryToService: writeQueryToService((0, import_node_path19.join)(path6)),
1502
- /**
1503
- * Remove an query to EventCatalog (modeled on the standard POSIX rm utility)
1504
- *
1505
- * @param path - The path to your query, e.g. `/Orders/GetOrder`
1506
- *
1507
- */
1508
- rmQuery: rmQuery((0, import_node_path19.join)(path6, "queries")),
1509
- /**
1510
- * Remove a query by a Query id
1511
- *
1512
- * @param id - The id of the query you want to remove
1513
- *
1514
- */
1515
- rmQueryById: rmQueryById((0, import_node_path19.join)(path6)),
1516
- /**
1517
- * Moves a given query id to the version directory
1518
- * @param directory
1519
- */
1520
- versionQuery: versionQuery((0, import_node_path19.join)(path6)),
1521
- /**
1522
- * Adds a file to the given query
1523
- * @param id - The id of the query to add the file to
1524
- * @param file - File contents to add including the content and the file name
1525
- * @param version - Optional version of the query to add the file to
1526
- * @returns
1527
- */
1528
- addFileToQuery: addFileToQuery((0, import_node_path19.join)(path6)),
1529
- /**
1530
- * Adds a schema to the given query
1531
- * @param id - The id of the query to add the schema to
1532
- * @param schema - Schema contents to add including the content and the file name
1533
- * @param version - Optional version of the query to add the schema to
1534
- * @returns
1535
- */
1536
- addSchemaToQuery: addSchemaToQuery((0, import_node_path19.join)(path6)),
1537
- /**
1538
- * Check to see if an query version exists
1539
- * @param id - The id of the query
1540
- * @param version - The version of the query (supports semver)
1541
- * @returns
1542
- */
1543
- queryHasVersion: queryHasVersion((0, import_node_path19.join)(path6)),
1544
- /**
1545
- * ================================
1546
- * Channels
1547
- * ================================
1548
- */
1549
- /**
1550
- * Returns a channel from EventCatalog
1551
- * @param id - The id of the channel to retrieve
1552
- * @param version - Optional id of the version to get (supports semver)
1553
- * @returns Channel|Undefined
1554
- */
1555
- getChannel: getChannel((0, import_node_path19.join)(path6)),
1556
- /**
1557
- * Returns all channels from EventCatalog
1558
- * @param latestOnly - optional boolean, set to true to get only latest versions
1559
- * @returns Channel[]|Undefined
1560
- */
1561
- getChannels: getChannels((0, import_node_path19.join)(path6)),
1562
- /**
1563
- * Adds an channel to EventCatalog
1564
- *
1565
- * @param command - The channel to write
1566
- * @param options - Optional options to write the channel
1567
- *
1568
- */
1569
- writeChannel: writeChannel((0, import_node_path19.join)(path6, "channels")),
1570
- /**
1571
- * Remove an channel to EventCatalog (modeled on the standard POSIX rm utility)
1572
- *
1573
- * @param path - The path to your channel, e.g. `/Inventory/InventoryAdjusted`
1574
- *
1575
- */
1576
- rmChannel: rmChannel((0, import_node_path19.join)(path6, "channels")),
1577
- /**
1578
- * Remove an channel by an Event id
1579
- *
1580
- * @param id - The id of the channel you want to remove
1581
- *
1582
- */
1583
- rmChannelById: rmChannelById((0, import_node_path19.join)(path6)),
1584
- /**
1585
- * Moves a given channel id to the version directory
1586
- * @param directory
1587
- */
1588
- versionChannel: versionChannel((0, import_node_path19.join)(path6)),
1589
- /**
1590
- * Check to see if a channel version exists
1591
- * @param id - The id of the channel
1592
- * @param version - The version of the channel (supports semver)
1593
- * @returns
1594
- */
1595
- channelHasVersion: channelHasVersion((0, import_node_path19.join)(path6)),
1596
- /**
1597
- * Add a channel to an event
1598
- *
1599
- * Optionally specify a version to add the channel to a specific version of the event.
1600
- *
1601
- * @example
1602
- * ```ts
1603
- * import utils from '@eventcatalog/utils';
1604
- *
1605
- * const { addEventToChannel } = utils('/path/to/eventcatalog');
1606
- *
1607
- * // adds a new event (InventoryUpdatedEvent) to the inventory.{env}.events channel
1608
- * await addEventToChannel('inventory.{env}.events channel', { id: 'InventoryUpdatedEvent', version: '2.0.0', parameters: { env: 'dev' } });
1609
- *
1610
- * ```
1611
- */
1612
- addEventToChannel: addMessageToChannel((0, import_node_path19.join)(path6), "events"),
1613
- /**
1614
- * Add a channel to an command
1615
- *
1616
- * Optionally specify a version to add the channel to a specific version of the command.
1617
- *
1618
- * @example
1619
- * ```ts
1620
- * import utils from '@eventcatalog/utils';
1621
- *
1622
- * const { addCommandToChannel } = utils('/path/to/eventcatalog');
1623
- *
1624
- * // adds a new command (UpdateInventory) to the inventory.{env}.events channel
1625
- * await addCommandToChannel('inventory.{env}.events channel', { id: 'UpdateInventory', version: '2.0.0', parameters: { env: 'dev' } });
1626
- *
1627
- * ```
1628
- */
1629
- addCommandToChannel: addMessageToChannel((0, import_node_path19.join)(path6), "commands"),
1630
- /**
1631
- * Add a channel to an query
1632
- *
1633
- * Optionally specify a version to add the channel to a specific version of the query.
1634
- *
1635
- * @example
1636
- * ```ts
1637
- * import utils from '@eventcatalog/utils';
1638
- *
1639
- * const { addQueryToChannel } = utils('/path/to/eventcatalog');
1640
- *
1641
- * // adds a new query (GetInventory) to the inventory.{env}.events channel
1642
- * await addQueryToChannel('inventory.{env}.events channel', { id: 'GetInventory', version: '2.0.0', parameters: { env: 'dev' } });
1643
- *
1644
- * ```
1645
- */
1646
- addQueryToChannel: addMessageToChannel((0, import_node_path19.join)(path6), "queries"),
1647
- /**
1648
- * ================================
1649
- * SERVICES
1650
- * ================================
1651
- */
1652
- /**
1653
- * Adds a service to EventCatalog
1654
- *
1655
- * @param service - The service to write
1656
- * @param options - Optional options to write the event
1657
- *
1658
- */
1659
- writeService: writeService((0, import_node_path19.join)(path6, "services")),
1660
- /**
1661
- * Adds a versioned service to EventCatalog
1662
- *
1663
- * @param service - The service to write
1664
- *
1665
- */
1666
- writeVersionedService: writeVersionedService((0, import_node_path19.join)(path6, "services")),
1667
- /**
1668
- * Adds a service to a domain in EventCatalog
1669
- *
1670
- * @param service - The service to write
1671
- * @param domain - The domain to add the service to
1672
- * @param options - Optional options to write the event
1673
- *
1674
- */
1675
- writeServiceToDomain: writeServiceToDomain((0, import_node_path19.join)(path6, "domains")),
1676
- /**
1677
- * Returns a service from EventCatalog
1678
- * @param id - The id of the service to retrieve
1679
- * @param version - Optional id of the version to get (supports semver)
1680
- * @returns Service|Undefined
1681
- */
1682
- getService: getService((0, import_node_path19.join)(path6)),
1683
- /**
1684
- * Returns a service from EventCatalog by it's path.
1685
- * @param path - The path to the service to retrieve
1686
- * @returns Service|Undefined
1687
- */
1688
- getServiceByPath: getServiceByPath((0, import_node_path19.join)(path6)),
1689
- /**
1690
- * Returns all services from EventCatalog
1691
- * @param latestOnly - optional boolean, set to true to get only latest versions
1692
- * @returns Service[]|Undefined
1693
- */
1694
- getServices: getServices((0, import_node_path19.join)(path6)),
1695
- /**
1696
- * Moves a given service id to the version directory
1697
- * @param directory
1698
- */
1699
- versionService: versionService((0, import_node_path19.join)(path6)),
1700
- /**
1701
- * Remove a service from EventCatalog (modeled on the standard POSIX rm utility)
1702
- *
1703
- * @param path - The path to your service, e.g. `/InventoryService`
1704
- *
1705
- */
1706
- rmService: rmService((0, import_node_path19.join)(path6, "services")),
1707
- /**
1708
- * Remove an service by an service id
1709
- *
1710
- * @param id - The id of the service you want to remove
1711
- *
1712
- */
1713
- rmServiceById: rmServiceById((0, import_node_path19.join)(path6)),
1714
- /**
1715
- * Adds a file to the given service
1716
- * @param id - The id of the service to add the file to
1717
- * @param file - File contents to add including the content and the file name
1718
- * @param version - Optional version of the service to add the file to
1719
- * @returns
1720
- */
1721
- addFileToService: addFileToService((0, import_node_path19.join)(path6)),
1722
- /**
1723
- * Returns the specifications for a given service
1724
- * @param id - The id of the service to retrieve the specifications for
1725
- * @param version - Optional version of the service
1726
- * @returns
1727
- */
1728
- getSpecificationFilesForService: getSpecificationFilesForService((0, import_node_path19.join)(path6)),
1729
- /**
1730
- * Check to see if a service version exists
1731
- * @param id - The id of the service
1732
- * @param version - The version of the service (supports semver)
1733
- * @returns
1734
- */
1735
- serviceHasVersion: serviceHasVersion((0, import_node_path19.join)(path6)),
1736
- /**
1737
- * Add an event to a service by it's id.
1738
- *
1739
- * Optionally specify a version to add the event to a specific version of the service.
1740
- *
1741
- * @example
1742
- * ```ts
1743
- * import utils from '@eventcatalog/utils';
1744
- *
1745
- * const { addEventToService } = utils('/path/to/eventcatalog');
1746
- *
1747
- * // adds a new event (InventoryUpdatedEvent) that the InventoryService will send
1748
- * await addEventToService('InventoryService', 'sends', { event: 'InventoryUpdatedEvent', version: '2.0.0' });
1749
- *
1750
- * // adds a new event (OrderComplete) that the InventoryService will receive
1751
- * await addEventToService('InventoryService', 'receives', { event: 'OrderComplete', version: '2.0.0' });
1752
- *
1753
- * ```
1754
- */
1755
- addEventToService: addMessageToService((0, import_node_path19.join)(path6)),
1756
- /**
1757
- * Add a data store to a service by it's id.
1758
- *
1759
- * Optionally specify a version to add the data store to a specific version of the service.
1760
- *
1761
- * @example
1762
- * ```ts
1763
- * import utils from '@eventcatalog/utils';
1764
- *
1765
- * const { addDataStoreToService } = utils('/path/to/eventcatalog');
1766
- *
1767
- * // adds a new data store (orders-db) that the InventoryService will write to
1768
- * await addDataStoreToService('InventoryService', 'writesTo', { id: 'orders-db', version: '2.0.0' });
1769
- *
1770
- * ```
1771
- */
1772
- addDataStoreToService: addDataStoreToService((0, import_node_path19.join)(path6)),
1773
- /**
1774
- * Add a command to a service by it's id.
1775
- *
1776
- * Optionally specify a version to add the event to a specific version of the service.
1777
- *
1778
- * @example
1779
- * ```ts
1780
- * import utils from '@eventcatalog/utils';
1781
- *
1782
- * const { addCommandToService } = utils('/path/to/eventcatalog');
1783
- *
1784
- * // adds a new command (UpdateInventoryCommand) that the InventoryService will send
1785
- * await addCommandToService('InventoryService', 'sends', { command: 'UpdateInventoryCommand', version: '2.0.0' });
1786
- *
1787
- * // adds a new command (VerifyInventory) that the InventoryService will receive
1788
- * await addCommandToService('InventoryService', 'receives', { command: 'VerifyInventory', version: '2.0.0' });
1789
- *
1790
- * ```
1791
- */
1792
- addCommandToService: addMessageToService((0, import_node_path19.join)(path6)),
1793
- /**
1794
- * Add a query to a service by it's id.
1795
- *
1796
- * Optionally specify a version to add the event to a specific version of the service.
1797
- *
1798
- * @example
1799
- * ```ts
1800
- * import utils from '@eventcatalog/utils';
1801
- *
1802
- * const { addQueryToService } = utils('/path/to/eventcatalog');
1803
- *
1804
- * // adds a new query (UpdateInventory) that the InventoryService will send
1805
- * await addQueryToService('InventoryService', 'sends', { command: 'UpdateInventory', version: '2.0.0' });
1806
- *
1807
- * // adds a new command (VerifyInventory) that the InventoryService will receive
1808
- * await addQueryToService('InventoryService', 'receives', { command: 'VerifyInventory', version: '2.0.0' });
1809
- *
1810
- * ```
1811
- */
1812
- addQueryToService: addMessageToService((0, import_node_path19.join)(path6)),
1813
- /**
1814
- * Add an entity to a service by its id.
1815
- *
1816
- * @example
1817
- * ```ts
1818
- * import utils from '@eventcatalog/utils';
1819
- *
1820
- * const { addEntityToService } = utils('/path/to/eventcatalog');
1821
- *
1822
- * // adds a new entity (User) to the InventoryService
1823
- * await addEntityToService('InventoryService', { id: 'User', version: '1.0.0' });
1824
- *
1825
- * // adds a new entity (Product) to a specific version of the InventoryService
1826
- * await addEntityToService('InventoryService', { id: 'Product', version: '1.0.0' }, '2.0.0');
1827
- *
1828
- * ```
1829
- */
1830
- addEntityToService: addEntityToService((0, import_node_path19.join)(path6)),
1831
- /**
1832
- * Check to see if a service exists by it's path.
1833
- *
1834
- * @example
1835
- * ```ts
1836
- * import utils from '@eventcatalog/utils';
1837
- *
1838
- * const { isService } = utils('/path/to/eventcatalog');
1839
- *
1840
- * // returns true if the path is a service
1841
- * await isService('/services/InventoryService/index.mdx');
1842
- * ```
1843
- *
1844
- * @param path - The path to the service to check
1845
- * @returns boolean
1846
- */
1847
- isService: isService((0, import_node_path19.join)(path6)),
1848
- /**
1849
- * Converts a file to a service.
1850
- * @param file - The file to convert to a service.
1851
- * @returns The service.
1852
- */
1853
- toService: toService((0, import_node_path19.join)(path6)),
1854
- /**
1855
- * ================================
1856
- * Domains
1857
- * ================================
1858
- */
1859
- /**
1860
- * Adds a domain to EventCatalog
1861
- *
1862
- * @param domain - The domain to write
1863
- * @param options - Optional options to write the event
1864
- *
1865
- */
1866
- writeDomain: writeDomain((0, import_node_path19.join)(path6, "domains")),
1867
- /**
1868
- * Returns a domain from EventCatalog
1869
- * @param id - The id of the domain to retrieve
1870
- * @param version - Optional id of the version to get (supports semver)
1871
- * @returns Domain|Undefined
1872
- */
1873
- getDomain: getDomain((0, import_node_path19.join)(path6, "domains")),
1874
- /**
1875
- * Returns all domains from EventCatalog
1876
- * @param latestOnly - optional boolean, set to true to get only latest versions
1877
- * @returns Domain[]|Undefined
1878
- */
1879
- getDomains: getDomains((0, import_node_path19.join)(path6)),
1880
- /**
1881
- * Moves a given domain id to the version directory
1882
- * @param directory
1883
- */
1884
- versionDomain: versionDomain((0, import_node_path19.join)(path6, "domains")),
1885
- /**
1886
- * Remove a domain from EventCatalog (modeled on the standard POSIX rm utility)
1887
- *
1888
- * @param path - The path to your domain, e.g. `/Payment`
1889
- *
1890
- */
1891
- rmDomain: rmDomain((0, import_node_path19.join)(path6, "domains")),
1892
- /**
1893
- * Remove an service by an domain id
1894
- *
1895
- * @param id - The id of the domain you want to remove
1896
- *
1897
- */
1898
- rmDomainById: rmDomainById((0, import_node_path19.join)(path6, "domains")),
1899
- /**
1900
- * Adds a file to the given domain
1901
- * @param id - The id of the domain to add the file to
1902
- * @param file - File contents to add including the content and the file name
1903
- * @param version - Optional version of the domain to add the file to
1904
- * @returns
1905
- */
1906
- addFileToDomain: addFileToDomain((0, import_node_path19.join)(path6, "domains")),
1907
- /**
1908
- * Adds an ubiquitous language dictionary to a domain
1909
- * @param id - The id of the domain to add the ubiquitous language to
1910
- * @param ubiquitousLanguageDictionary - The ubiquitous language dictionary to add
1911
- * @param version - Optional version of the domain to add the ubiquitous language to
1912
- */
1913
- addUbiquitousLanguageToDomain: addUbiquitousLanguageToDomain((0, import_node_path19.join)(path6, "domains")),
1914
- /**
1915
- * Get the ubiquitous language dictionary from a domain
1916
- * @param id - The id of the domain to get the ubiquitous language from
1917
- * @param version - Optional version of the domain to get the ubiquitous language from
1918
- * @returns
1919
- */
1920
- getUbiquitousLanguageFromDomain: getUbiquitousLanguageFromDomain((0, import_node_path19.join)(path6, "domains")),
1921
- /**
1922
- * Check to see if a domain version exists
1923
- * @param id - The id of the domain
1924
- * @param version - The version of the domain (supports semver)
1925
- * @returns
1926
- */
1927
- domainHasVersion: domainHasVersion((0, import_node_path19.join)(path6)),
1928
- /**
1929
- * Adds a given service to a domain
1930
- * @param id - The id of the domain
1931
- * @param service - The id and version of the service to add
1932
- * @param version - (Optional) The version of the domain to add the service to
1933
- * @returns
1934
- */
1935
- addServiceToDomain: addServiceToDomain((0, import_node_path19.join)(path6, "domains")),
1936
- /**
1937
- * Adds a given subdomain to a domain
1938
- * @param id - The id of the domain
1939
- * @param subDomain - The id and version of the subdomain to add
1940
- * @param version - (Optional) The version of the domain to add the subdomain to
1941
- * @returns
1942
- */
1943
- addSubDomainToDomain: addSubDomainToDomain((0, import_node_path19.join)(path6, "domains")),
1944
- /**
1945
- * Adds an entity to a domain
1946
- * @param id - The id of the domain
1947
- * @param entity - The id and version of the entity to add
1948
- * @param version - (Optional) The version of the domain to add the entity to
1949
- * @returns
1950
- */
1951
- addEntityToDomain: addEntityToDomain((0, import_node_path19.join)(path6, "domains")),
1952
- /**
1953
- * Add an event to a domain by its id.
1954
- *
1955
- * @example
1956
- * ```ts
1957
- * import utils from '@eventcatalog/utils';
1958
- *
1959
- * const { addEventToDomain } = utils('/path/to/eventcatalog');
1960
- *
1961
- * // adds a new event (OrderCreated) that the Orders domain will send
1962
- * await addEventToDomain('Orders', 'sends', { id: 'OrderCreated', version: '2.0.0' });
1963
- *
1964
- * // adds a new event (PaymentProcessed) that the Orders domain will receive
1965
- * await addEventToDomain('Orders', 'receives', { id: 'PaymentProcessed', version: '2.0.0' });
1966
- *
1967
- * ```
1968
- */
1969
- addEventToDomain: addMessageToDomain((0, import_node_path19.join)(path6, "domains")),
1970
- /**
1971
- * Add a command to a domain by its id.
1972
- *
1973
- * @example
1974
- * ```ts
1975
- * import utils from '@eventcatalog/utils';
1976
- *
1977
- * const { addCommandToDomain } = utils('/path/to/eventcatalog');
1978
- *
1979
- * // adds a new command (ProcessOrder) that the Orders domain will send
1980
- * await addCommandToDomain('Orders', 'sends', { id: 'ProcessOrder', version: '2.0.0' });
1981
- *
1982
- * // adds a new command (CancelOrder) that the Orders domain will receive
1983
- * await addCommandToDomain('Orders', 'receives', { id: 'CancelOrder', version: '2.0.0' });
1984
- *
1985
- * ```
1986
- */
1987
- addCommandToDomain: addMessageToDomain((0, import_node_path19.join)(path6, "domains")),
1988
- /**
1989
- * Add a query to a domain by its id.
1990
- *
1991
- * @example
1992
- * ```ts
1993
- * import utils from '@eventcatalog/utils';
1994
- *
1995
- * const { addQueryToDomain } = utils('/path/to/eventcatalog');
1996
- *
1997
- * // adds a new query (GetOrderStatus) that the Orders domain will send
1998
- * await addQueryToDomain('Orders', 'sends', { id: 'GetOrderStatus', version: '2.0.0' });
1999
- *
2000
- * // adds a new query (GetInventory) that the Orders domain will receive
2001
- * await addQueryToDomain('Orders', 'receives', { id: 'GetInventory', version: '2.0.0' });
2002
- *
2003
- * ```
2004
- */
2005
- addQueryToDomain: addMessageToDomain((0, import_node_path19.join)(path6, "domains")),
2006
- /**
2007
- * ================================
2008
- * Teams
2009
- * ================================
2010
- */
2011
- /**
2012
- * Adds a team to EventCatalog
2013
- *
2014
- * @param team - The team to write
2015
- * @param options - Optional options to write the team
2016
- *
2017
- */
2018
- writeTeam: writeTeam((0, import_node_path19.join)(path6, "teams")),
2019
- /**
2020
- * Returns a team from EventCatalog
2021
- * @param id - The id of the team to retrieve
2022
- * @returns Team|Undefined
2023
- */
2024
- getTeam: getTeam((0, import_node_path19.join)(path6, "teams")),
2025
- /**
2026
- * Returns all teams from EventCatalog
2027
- * @returns Team[]|Undefined
2028
- */
2029
- getTeams: getTeams((0, import_node_path19.join)(path6, "teams")),
2030
- /**
2031
- * Remove a team by the team id
2032
- *
2033
- * @param id - The id of the team you want to remove
2034
- *
2035
- */
2036
- rmTeamById: rmTeamById((0, import_node_path19.join)(path6, "teams")),
2037
- /**
2038
- * ================================
2039
- * Users
2040
- * ================================
2041
- */
2042
- /**
2043
- * Adds a user to EventCatalog
2044
- *
2045
- * @param user - The user to write
2046
- * @param options - Optional options to write the user
2047
- *
2048
- */
2049
- writeUser: writeUser((0, import_node_path19.join)(path6, "users")),
2050
- /**
2051
- * Returns a user from EventCatalog
2052
- * @param id - The id of the user to retrieve
2053
- * @returns User|Undefined
2054
- */
2055
- getUser: getUser((0, import_node_path19.join)(path6, "users")),
2056
- /**
2057
- * Returns all user from EventCatalog
2058
- * @returns User[]|Undefined
2059
- */
2060
- getUsers: getUsers((0, import_node_path19.join)(path6)),
2061
- /**
2062
- * Remove a user by the user id
2063
- *
2064
- * @param id - The id of the user you want to remove
2065
- *
2066
- */
2067
- rmUserById: rmUserById((0, import_node_path19.join)(path6, "users")),
2068
- /**
2069
- * ================================
2070
- * Custom Docs
2071
- * ================================
2072
- */
2073
- /**
2074
- * Returns a custom doc from EventCatalog
2075
- * @param path - The path to the custom doc to retrieve
2076
- * @returns CustomDoc|Undefined
2077
- */
2078
- getCustomDoc: getCustomDoc((0, import_node_path19.join)(path6, "docs")),
2079
- /**
2080
- * Returns all custom docs from EventCatalog
2081
- * @param options - Optional options to get custom docs from a specific path
2082
- * @returns CustomDoc[]|Undefined
2083
- */
2084
- getCustomDocs: getCustomDocs((0, import_node_path19.join)(path6, "docs")),
2085
- /**
2086
- * Writes a custom doc to EventCatalog
2087
- * @param customDoc - The custom doc to write
2088
- * @param options - Optional options to write the custom doc
2089
- *
2090
- */
2091
- writeCustomDoc: writeCustomDoc((0, import_node_path19.join)(path6, "docs")),
2092
- /**
2093
- * Removes a custom doc from EventCatalog
2094
- * @param path - The path to the custom doc to remove
2095
- *
2096
- */
2097
- rmCustomDoc: rmCustomDoc((0, import_node_path19.join)(path6, "docs")),
2098
- /**
2099
- * Dumps the catalog to a JSON file.
2100
- * @param directory - The directory to dump the catalog to
2101
- * @returns A JSON file with the catalog
2102
- */
2103
- dumpCatalog: dumpCatalog((0, import_node_path19.join)(path6)),
2104
- /**
2105
- * Returns the event catalog configuration file.
2106
- * The event catalog configuration file is the file that contains the configuration for the event catalog.
2107
- *
2108
- * @param directory - The directory of the catalog.
2109
- * @returns A JSON object with the configuration for the event catalog.
2110
- */
2111
- getEventCatalogConfigurationFile: getEventCatalogConfigurationFile((0, import_node_path19.join)(path6)),
2112
- /**
2113
- * ================================
2114
- * Resources Utils
2115
- * ================================
2116
- */
2117
- /**
2118
- * Returns the path to a given resource by id and version
2119
- */
2120
- getResourcePath,
2121
- /**
2122
- * Returns the folder name of a given resource
2123
- */
2124
- getResourceFolderName,
2125
- /**
2126
- * ================================
2127
- * General Message Utils
2128
- * ================================
2129
- */
2130
- /**
2131
- * Returns a message from EventCatalog by a given schema path.
2132
- *
2133
- * @param path - The path to the message to retrieve
2134
- * @returns Message|Undefined
2135
- */
2136
- getMessageBySchemaPath: getMessageBySchemaPath((0, import_node_path19.join)(path6)),
2137
- /**
2138
- * Returns the producers and consumers (services) for a given message
2139
- * @param id - The id of the message to get the producers and consumers for
2140
- * @param version - Optional version of the message
2141
- * @returns { producers: Service[], consumers: Service[] }
2142
- */
2143
- getProducersAndConsumersForMessage: getProducersAndConsumersForMessage((0, import_node_path19.join)(path6)),
2144
- /**
2145
- * Returns the consumers of a given schema path
2146
- * @param path - The path to the schema to get the consumers for
2147
- * @returns Service[]
2148
- */
2149
- getConsumersOfSchema: getConsumersOfSchema((0, import_node_path19.join)(path6)),
2150
- /**
2151
- * Returns the producers of a given schema path
2152
- * @param path - The path to the schema to get the producers for
2153
- * @returns Service[]
2154
- */
2155
- getProducersOfSchema: getProducersOfSchema((0, import_node_path19.join)(path6)),
2156
- /**
2157
- * Returns the owners for a given resource (e.g domain, service, event, command, query, etc.)
2158
- * @param id - The id of the resource to get the owners for
2159
- * @param version - Optional version of the resource
2160
- * @returns { owners: User[] }
2161
- */
2162
- getOwnersForResource: getOwnersForResource((0, import_node_path19.join)(path6)),
2163
- /**
2164
- * ================================
2165
- * Entities
2166
- * ================================
2167
- */
2168
- /**
2169
- * Returns an entity from EventCatalog
2170
- * @param id - The id of the entity to retrieve
2171
- * @param version - Optional id of the version to get (supports semver)
2172
- * @returns Entity|Undefined
2173
- */
2174
- getEntity: getEntity((0, import_node_path19.join)(path6)),
2175
- /**
2176
- * Returns all entities from EventCatalog
2177
- * @param latestOnly - optional boolean, set to true to get only latest versions
2178
- * @returns Entity[]|Undefined
2179
- */
2180
- getEntities: getEntities((0, import_node_path19.join)(path6)),
2181
- /**
2182
- * Adds an entity to EventCatalog
2183
- *
2184
- * @param entity - The entity to write
2185
- * @param options - Optional options to write the entity
2186
- *
2187
- */
2188
- writeEntity: writeEntity((0, import_node_path19.join)(path6, "entities")),
2189
- /**
2190
- * Remove an entity from EventCatalog (modeled on the standard POSIX rm utility)
2191
- *
2192
- * @param path - The path to your entity, e.g. `/User`
2193
- *
2194
- */
2195
- rmEntity: rmEntity((0, import_node_path19.join)(path6, "entities")),
2196
- /**
2197
- * Remove an entity by an entity id
2198
- *
2199
- * @param id - The id of the entity you want to remove
2200
- *
2201
- */
2202
- rmEntityById: rmEntityById((0, import_node_path19.join)(path6)),
2203
- /**
2204
- * Moves a given entity id to the version directory
2205
- * @param id - The id of the entity to version
2206
- */
2207
- versionEntity: versionEntity((0, import_node_path19.join)(path6)),
2208
- /**
2209
- * Check to see if an entity version exists
2210
- * @param id - The id of the entity
2211
- * @param version - The version of the entity (supports semver)
2212
- * @returns
2213
- */
2214
- entityHasVersion: entityHasVersion((0, import_node_path19.join)(path6)),
2215
- /**
2216
- * ================================
2217
- * Data Stores
2218
- * ================================
2219
- */
2220
- /**
2221
- * Adds a data store to EventCatalog
2222
- * @param dataStore - The data store to write
2223
- * @param options - Optional options to write the data store
2224
- *
2225
- */
2226
- writeDataStore: writeDataStore((0, import_node_path19.join)(path6, "containers")),
2227
- /**
2228
- * Returns a data store from EventCatalog
2229
- * @param id - The id of the data store to retrieve
2230
- * @param version - Optional id of the version to get (supports semver)
2231
- * @returns Container|Undefined
2232
- */
2233
- getDataStore: getDataStore((0, import_node_path19.join)(path6)),
2234
- /**
2235
- * Returns all data stores from EventCatalog
2236
- * @param latestOnly - optional boolean, set to true to get only latest versions
2237
- * @returns Container[]|Undefined
2238
- */
2239
- getDataStores: getDataStores((0, import_node_path19.join)(path6)),
2240
- /**
2241
- * Version a data store by its id
2242
- * @param id - The id of the data store to version
2243
- */
2244
- versionDataStore: versionDataStore((0, import_node_path19.join)(path6, "containers")),
2245
- /**
2246
- * Remove a data store by its path
2247
- * @param path - The path to the data store to remove
2248
- */
2249
- rmDataStore: rmDataStore((0, import_node_path19.join)(path6, "containers")),
2250
- /**
2251
- * Remove a data store by its id
2252
- * @param id - The id of the data store to remove
2253
- */
2254
- rmDataStoreById: rmDataStoreById((0, import_node_path19.join)(path6)),
2255
- /**
2256
- * Check to see if a data store version exists
2257
- * @param id - The id of the data store
2258
- * @param version - The version of the data store (supports semver)
2259
- * @returns
2260
- */
2261
- dataStoreHasVersion: dataStoreHasVersion((0, import_node_path19.join)(path6)),
2262
- /**
2263
- * Adds a file to a data store by its id
2264
- * @param id - The id of the data store to add the file to
2265
- * @param file - File contents to add including the content and the file name
2266
- * @param version - Optional version of the data store to add the file to
2267
- * @returns
2268
- */
2269
- addFileToDataStore: addFileToDataStore((0, import_node_path19.join)(path6)),
2270
- /**
2271
- * Writes a data store to a service by its id
2272
- * @param dataStore - The data store to write
2273
- * @param service - The service to write the data store to
2274
- * @returns
2275
- */
2276
- writeDataStoreToService: writeDataStoreToService((0, import_node_path19.join)(path6)),
2277
- /**
2278
- * ================================
2279
- * Data Products
2280
- * ================================
2281
- */
2282
- /**
2283
- * Adds a data product to EventCatalog
2284
- * @param dataProduct - The data product to write
2285
- * @param options - Optional options to write the data product
2286
- *
2287
- */
2288
- writeDataProduct: writeDataProduct((0, import_node_path19.join)(path6, "data-products")),
2289
- /**
2290
- * Writes a data product to a domain in EventCatalog
2291
- * @param dataProduct - The data product to write
2292
- * @param domain - The domain to write the data product to
2293
- * @param options - Optional options to write the data product
2294
- *
2295
- */
2296
- writeDataProductToDomain: writeDataProductToDomain((0, import_node_path19.join)(path6, "domains")),
2297
- /**
2298
- * Returns a data product from EventCatalog
2299
- * @param id - The id of the data product to retrieve
2300
- * @param version - Optional id of the version to get (supports semver)
2301
- * @returns DataProduct|Undefined
2302
- */
2303
- getDataProduct: getDataProduct((0, import_node_path19.join)(path6)),
2304
- /**
2305
- * Returns all data products from EventCatalog
2306
- * @param latestOnly - optional boolean, set to true to get only latest versions
2307
- * @returns DataProduct[]|Undefined
2308
- */
2309
- getDataProducts: getDataProducts((0, import_node_path19.join)(path6)),
2310
- /**
2311
- * Version a data product by its id
2312
- * @param id - The id of the data product to version
2313
- */
2314
- versionDataProduct: versionDataProduct((0, import_node_path19.join)(path6)),
2315
- /**
2316
- * Remove a data product by its path
2317
- * @param path - The path to the data product to remove
2318
- */
2319
- rmDataProduct: rmDataProduct((0, import_node_path19.join)(path6, "data-products")),
2320
- /**
2321
- * Remove a data product by its id
2322
- * @param id - The id of the data product to remove
2323
- * @param version - Optional version of the data product to remove
2324
- */
2325
- rmDataProductById: rmDataProductById((0, import_node_path19.join)(path6)),
2326
- /**
2327
- * Check to see if a data product version exists
2328
- * @param id - The id of the data product
2329
- * @param version - The version of the data product (supports semver)
2330
- * @returns
2331
- */
2332
- dataProductHasVersion: dataProductHasVersion((0, import_node_path19.join)(path6)),
2333
- /**
2334
- * Adds a file to a data product by its id
2335
- * @param id - The id of the data product to add the file to
2336
- * @param file - File contents to add including the content and the file name
2337
- * @param version - Optional version of the data product to add the file to
2338
- * @returns
2339
- */
2340
- addFileToDataProduct: addFileToDataProduct((0, import_node_path19.join)(path6)),
2341
- /**
2342
- * Adds a data product to a domain
2343
- * @param id - The id of the domain
2344
- * @param dataProduct - The id and version of the data product to add
2345
- * @param version - (Optional) The version of the domain to add the data product to
2346
- * @returns
2347
- */
2348
- addDataProductToDomain: addDataProductToDomain((0, import_node_path19.join)(path6, "domains"))
2349
- };
2350
- };
2351
- //# sourceMappingURL=index.js.map