@eventcatalog/sdk 2.6.4 → 2.6.6
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/channels.js +3 -3
- package/dist/channels.js.map +1 -1
- package/dist/channels.mjs +3 -3
- package/dist/channels.mjs.map +1 -1
- package/dist/commands.js +3 -3
- package/dist/commands.js.map +1 -1
- package/dist/commands.mjs +3 -3
- package/dist/commands.mjs.map +1 -1
- package/dist/custom-docs.js.map +1 -1
- package/dist/custom-docs.mjs.map +1 -1
- package/dist/domains.js +3 -3
- package/dist/domains.js.map +1 -1
- package/dist/domains.mjs +3 -3
- package/dist/domains.mjs.map +1 -1
- package/dist/eventcatalog.js +224 -149
- package/dist/eventcatalog.js.map +1 -1
- package/dist/eventcatalog.mjs +223 -148
- package/dist/eventcatalog.mjs.map +1 -1
- package/dist/events.js +3 -3
- package/dist/events.js.map +1 -1
- package/dist/events.mjs +3 -3
- package/dist/events.mjs.map +1 -1
- package/dist/index.d.mts +60 -30
- package/dist/index.d.ts +60 -30
- package/dist/index.js +224 -149
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +223 -148
- package/dist/index.mjs.map +1 -1
- package/dist/messages.js +3 -3
- package/dist/messages.js.map +1 -1
- package/dist/messages.mjs +4 -4
- package/dist/messages.mjs.map +1 -1
- package/dist/queries.js +3 -3
- package/dist/queries.js.map +1 -1
- package/dist/queries.mjs +3 -3
- package/dist/queries.mjs.map +1 -1
- package/dist/services.d.mts +45 -1
- package/dist/services.d.ts +45 -1
- package/dist/services.js +27 -3
- package/dist/services.js.map +1 -1
- package/dist/services.mjs +25 -4
- package/dist/services.mjs.map +1 -1
- package/dist/teams.d.mts +8 -1
- package/dist/teams.d.ts +8 -1
- package/dist/teams.js +122 -11
- package/dist/teams.js.map +1 -1
- package/dist/teams.mjs +121 -11
- package/dist/teams.mjs.map +1 -1
- package/package.json +1 -1
package/dist/eventcatalog.js
CHANGED
|
@@ -35,10 +35,10 @@ __export(eventcatalog_exports, {
|
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(eventcatalog_exports);
|
|
37
37
|
var import_fs = __toESM(require("fs"));
|
|
38
|
-
var
|
|
38
|
+
var import_node_path14 = __toESM(require("path"));
|
|
39
39
|
|
|
40
40
|
// src/index.ts
|
|
41
|
-
var
|
|
41
|
+
var import_node_path13 = require("path");
|
|
42
42
|
|
|
43
43
|
// src/events.ts
|
|
44
44
|
var import_promises2 = __toESM(require("fs/promises"));
|
|
@@ -59,13 +59,13 @@ var versionExists = async (catalogDir, id, version) => {
|
|
|
59
59
|
var findFileById = async (catalogDir, id, version) => {
|
|
60
60
|
const files = await getFiles(`${catalogDir}/**/index.{md,mdx}`);
|
|
61
61
|
const matchedFiles = await searchFilesForId(files, id) || [];
|
|
62
|
-
const latestVersion = matchedFiles.find((
|
|
62
|
+
const latestVersion = matchedFiles.find((path5) => !path5.includes("versioned"));
|
|
63
63
|
if (!version) {
|
|
64
64
|
return latestVersion;
|
|
65
65
|
}
|
|
66
|
-
const parsedFiles = matchedFiles.map((
|
|
67
|
-
const { data } = import_gray_matter.default.read(
|
|
68
|
-
return { ...data, path:
|
|
66
|
+
const parsedFiles = matchedFiles.map((path5) => {
|
|
67
|
+
const { data } = import_gray_matter.default.read(path5);
|
|
68
|
+
return { ...data, path: path5 };
|
|
69
69
|
});
|
|
70
70
|
const semverRange = (0, import_semver.validRange)(version);
|
|
71
71
|
if (semverRange && (0, import_semver.valid)(version)) {
|
|
@@ -106,8 +106,8 @@ var getFiles = async (pattern, ignore = "") => {
|
|
|
106
106
|
);
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
|
-
var readMdxFile = async (
|
|
110
|
-
const { data } = import_gray_matter.default.read(
|
|
109
|
+
var readMdxFile = async (path5) => {
|
|
110
|
+
const { data } = import_gray_matter.default.read(path5);
|
|
111
111
|
const { markdown, ...frontmatter } = data;
|
|
112
112
|
return { ...frontmatter, markdown };
|
|
113
113
|
};
|
|
@@ -190,8 +190,8 @@ var writeResource = async (catalogDir, resource, options = {
|
|
|
190
190
|
versionExistingContent: false,
|
|
191
191
|
format: "mdx"
|
|
192
192
|
}) => {
|
|
193
|
-
const
|
|
194
|
-
const fullPath = (0, import_path.join)(catalogDir,
|
|
193
|
+
const path5 = options.path || `/${resource.id}`;
|
|
194
|
+
const fullPath = (0, import_path.join)(catalogDir, path5);
|
|
195
195
|
const format = options.format || "mdx";
|
|
196
196
|
import_node_fs2.default.mkdirSync(fullPath, { recursive: true });
|
|
197
197
|
const lockPath = (0, import_path.join)(fullPath, `index.${format}`);
|
|
@@ -226,10 +226,10 @@ var writeResource = async (catalogDir, resource, options = {
|
|
|
226
226
|
});
|
|
227
227
|
}
|
|
228
228
|
};
|
|
229
|
-
var getResource = async (catalogDir, id, version, options) => {
|
|
229
|
+
var getResource = async (catalogDir, id, version, options, filePath) => {
|
|
230
230
|
const attachSchema = options?.attachSchema || false;
|
|
231
|
-
const file = await findFileById(catalogDir, id, version);
|
|
232
|
-
if (!file) return;
|
|
231
|
+
const file = filePath || (id ? await findFileById(catalogDir, id, version) : void 0);
|
|
232
|
+
if (!file || !import_node_fs2.default.existsSync(file)) return;
|
|
233
233
|
const { data, content } = import_gray_matter2.default.read(file);
|
|
234
234
|
if (attachSchema && data?.schemaPath) {
|
|
235
235
|
const resourceDirectory = (0, import_path.dirname)(file);
|
|
@@ -257,6 +257,13 @@ var getResourcePath = async (catalogDir, id, version) => {
|
|
|
257
257
|
directory: (0, import_path.dirname)(file.replace(catalogDir, ""))
|
|
258
258
|
};
|
|
259
259
|
};
|
|
260
|
+
var toResource = async (catalogDir, file) => {
|
|
261
|
+
const { data, content } = import_gray_matter2.default.read(file);
|
|
262
|
+
return {
|
|
263
|
+
...data,
|
|
264
|
+
markdown: content.trim()
|
|
265
|
+
};
|
|
266
|
+
};
|
|
260
267
|
var getResources = async (catalogDir, {
|
|
261
268
|
type,
|
|
262
269
|
latestOnly = false,
|
|
@@ -354,8 +361,8 @@ var writeEventToService = (directory) => async (event, service, options = { path
|
|
|
354
361
|
pathForEvent = (0, import_node_path2.join)(pathForEvent, event.id);
|
|
355
362
|
await writeResource(directory, { ...event }, { ...options, path: pathForEvent, type: "event" });
|
|
356
363
|
};
|
|
357
|
-
var rmEvent = (directory) => async (
|
|
358
|
-
await import_promises2.default.rm((0, import_node_path2.join)(directory,
|
|
364
|
+
var rmEvent = (directory) => async (path5) => {
|
|
365
|
+
await import_promises2.default.rm((0, import_node_path2.join)(directory, path5), { recursive: true });
|
|
359
366
|
};
|
|
360
367
|
var rmEventById = (directory) => async (id, version, persistFiles) => {
|
|
361
368
|
await rmResourceById(directory, id, version, { type: "event", persistFiles });
|
|
@@ -390,8 +397,8 @@ var writeCommandToService = (directory) => async (command, service, options = {
|
|
|
390
397
|
pathForCommand = (0, import_node_path3.join)(pathForCommand, command.id);
|
|
391
398
|
await writeResource(directory, { ...command }, { ...options, path: pathForCommand, type: "command" });
|
|
392
399
|
};
|
|
393
|
-
var rmCommand = (directory) => async (
|
|
394
|
-
await import_promises3.default.rm((0, import_node_path3.join)(directory,
|
|
400
|
+
var rmCommand = (directory) => async (path5) => {
|
|
401
|
+
await import_promises3.default.rm((0, import_node_path3.join)(directory, path5), { recursive: true });
|
|
395
402
|
};
|
|
396
403
|
var rmCommandById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "command", persistFiles });
|
|
397
404
|
var versionCommand = (directory) => async (id) => versionResource(directory, id);
|
|
@@ -424,8 +431,8 @@ var writeQueryToService = (directory) => async (query, service, options = { path
|
|
|
424
431
|
pathForQuery = (0, import_node_path4.join)(pathForQuery, query.id);
|
|
425
432
|
await writeResource(directory, { ...query }, { ...options, path: pathForQuery, type: "query" });
|
|
426
433
|
};
|
|
427
|
-
var rmQuery = (directory) => async (
|
|
428
|
-
await import_promises4.default.rm((0, import_node_path4.join)(directory,
|
|
434
|
+
var rmQuery = (directory) => async (path5) => {
|
|
435
|
+
await import_promises4.default.rm((0, import_node_path4.join)(directory, path5), { recursive: true });
|
|
429
436
|
};
|
|
430
437
|
var rmQueryById = (directory) => async (id, version, persistFiles) => {
|
|
431
438
|
await rmResourceById(directory, id, version, { type: "query", persistFiles });
|
|
@@ -444,6 +451,10 @@ var queryHasVersion = (directory) => async (id, version) => {
|
|
|
444
451
|
var import_promises5 = __toESM(require("fs/promises"));
|
|
445
452
|
var import_node_path5 = require("path");
|
|
446
453
|
var getService = (directory) => async (id, version) => getResource(directory, id, version, { type: "service" });
|
|
454
|
+
var getServiceByPath = (directory) => async (path5) => {
|
|
455
|
+
const service = await getResource(directory, void 0, void 0, { type: "service" }, path5);
|
|
456
|
+
return service;
|
|
457
|
+
};
|
|
447
458
|
var getServices = (directory) => async (options) => getResources(directory, {
|
|
448
459
|
type: "services",
|
|
449
460
|
ignore: ["**/events/**", "**/commands/**", "**/queries/**", "**/entities/**", "**/subdomains/**/entities/**"],
|
|
@@ -465,8 +476,8 @@ var writeService = (directory) => async (service, options = {
|
|
|
465
476
|
};
|
|
466
477
|
var writeVersionedService = (directory) => async (service) => {
|
|
467
478
|
const resource = { ...service };
|
|
468
|
-
const
|
|
469
|
-
return await writeService(directory)(resource, { path:
|
|
479
|
+
const path5 = getVersionedDirectory(service.id, service.version);
|
|
480
|
+
return await writeService(directory)(resource, { path: path5 });
|
|
470
481
|
};
|
|
471
482
|
var writeServiceToDomain = (directory) => async (service, domain, options = { path: "", format: "mdx", override: false }) => {
|
|
472
483
|
let pathForService = domain.version && domain.version !== "latest" ? `/${domain.id}/versioned/${domain.version}/services` : `/${domain.id}/services`;
|
|
@@ -474,8 +485,8 @@ var writeServiceToDomain = (directory) => async (service, domain, options = { pa
|
|
|
474
485
|
await writeResource(directory, { ...service }, { ...options, path: pathForService, type: "service" });
|
|
475
486
|
};
|
|
476
487
|
var versionService = (directory) => async (id) => versionResource(directory, id);
|
|
477
|
-
var rmService = (directory) => async (
|
|
478
|
-
await import_promises5.default.rm((0, import_node_path5.join)(directory,
|
|
488
|
+
var rmService = (directory) => async (path5) => {
|
|
489
|
+
await import_promises5.default.rm((0, import_node_path5.join)(directory, path5), { recursive: true });
|
|
479
490
|
};
|
|
480
491
|
var rmServiceById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "service", persistFiles });
|
|
481
492
|
var addFileToService = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
|
|
@@ -530,8 +541,8 @@ var addMessageToService = (directory) => async (id, direction, event, version) =
|
|
|
530
541
|
if (!existingResource) {
|
|
531
542
|
throw new Error(`Cannot find service ${id} in the catalog`);
|
|
532
543
|
}
|
|
533
|
-
const
|
|
534
|
-
const pathToResource = (0, import_node_path5.join)(
|
|
544
|
+
const path5 = existingResource.split(/[\\/]+services/)[0];
|
|
545
|
+
const pathToResource = (0, import_node_path5.join)(path5, "services");
|
|
535
546
|
await rmServiceById(directory)(id, version);
|
|
536
547
|
await writeService(pathToResource)(service, { format: extension === ".md" ? "md" : "mdx" });
|
|
537
548
|
};
|
|
@@ -539,6 +550,13 @@ var serviceHasVersion = (directory) => async (id, version) => {
|
|
|
539
550
|
const file = await findFileById(directory, id, version);
|
|
540
551
|
return !!file;
|
|
541
552
|
};
|
|
553
|
+
var isService = (directory) => async (path5) => {
|
|
554
|
+
const service = await getServiceByPath(directory)(path5);
|
|
555
|
+
const relativePath = (0, import_node_path5.relative)(directory, path5);
|
|
556
|
+
const segments = relativePath.split(/[/\\]+/);
|
|
557
|
+
return !!service && segments.includes("services");
|
|
558
|
+
};
|
|
559
|
+
var toService = (directory) => async (file) => toResource(directory, file);
|
|
542
560
|
|
|
543
561
|
// src/domains.ts
|
|
544
562
|
var import_promises6 = __toESM(require("fs/promises"));
|
|
@@ -567,8 +585,8 @@ var writeDomain = (directory) => async (domain, options = {
|
|
|
567
585
|
return await writeResource(directory, resource, { ...options, type: "domain" });
|
|
568
586
|
};
|
|
569
587
|
var versionDomain = (directory) => async (id) => versionResource(directory, id);
|
|
570
|
-
var rmDomain = (directory) => async (
|
|
571
|
-
await import_promises6.default.rm((0, import_node_path6.join)(directory,
|
|
588
|
+
var rmDomain = (directory) => async (path5) => {
|
|
589
|
+
await import_promises6.default.rm((0, import_node_path6.join)(directory, path5), { recursive: true });
|
|
572
590
|
};
|
|
573
591
|
var rmDomainById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "domain", persistFiles });
|
|
574
592
|
var addFileToDomain = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
|
|
@@ -629,8 +647,8 @@ var import_node_path7 = require("path");
|
|
|
629
647
|
var getChannel = (directory) => async (id, version) => getResource(directory, id, version, { type: "channel" });
|
|
630
648
|
var getChannels = (directory) => async (options) => getResources(directory, { type: "channels", ...options });
|
|
631
649
|
var writeChannel = (directory) => async (channel, options = { path: "" }) => writeResource(directory, { ...channel }, { ...options, type: "channel" });
|
|
632
|
-
var rmChannel = (directory) => async (
|
|
633
|
-
await import_promises7.default.rm((0, import_node_path7.join)(directory,
|
|
650
|
+
var rmChannel = (directory) => async (path5) => {
|
|
651
|
+
await import_promises7.default.rm((0, import_node_path7.join)(directory, path5), { recursive: true });
|
|
634
652
|
};
|
|
635
653
|
var rmChannelById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "channel", persistFiles });
|
|
636
654
|
var versionChannel = (directory) => async (id) => versionResource(directory, id);
|
|
@@ -671,8 +689,8 @@ var addMessageToChannel = (directory, collection) => async (id, _message, versio
|
|
|
671
689
|
if (!existingResource) {
|
|
672
690
|
throw new Error(`Cannot find message ${id} in the catalog`);
|
|
673
691
|
}
|
|
674
|
-
const
|
|
675
|
-
const pathToResource = (0, import_node_path7.join)(
|
|
692
|
+
const path5 = existingResource.split(`/[\\/]+${collection}`)[0];
|
|
693
|
+
const pathToResource = (0, import_node_path7.join)(path5, collection);
|
|
676
694
|
await rmMessageById(directory)(_message.id, _message.version, true);
|
|
677
695
|
await writeMessage(pathToResource)(message, { format: extension === ".md" ? "md" : "mdx" });
|
|
678
696
|
};
|
|
@@ -681,8 +699,8 @@ var addMessageToChannel = (directory, collection) => async (id, _message, versio
|
|
|
681
699
|
var import_node_path8 = require("path");
|
|
682
700
|
var import_gray_matter4 = __toESM(require("gray-matter"));
|
|
683
701
|
var import_semver3 = require("semver");
|
|
684
|
-
var getMessageBySchemaPath = (directory) => async (
|
|
685
|
-
const pathToMessage = (0, import_node_path8.dirname)(
|
|
702
|
+
var getMessageBySchemaPath = (directory) => async (path5, options) => {
|
|
703
|
+
const pathToMessage = (0, import_node_path8.dirname)(path5);
|
|
686
704
|
try {
|
|
687
705
|
const files = await getFiles(`${directory}/${pathToMessage}/index.{md,mdx}`);
|
|
688
706
|
if (!files || files.length === 0) {
|
|
@@ -700,7 +718,7 @@ var getMessageBySchemaPath = (directory) => async (path4, options) => {
|
|
|
700
718
|
}
|
|
701
719
|
return message;
|
|
702
720
|
} catch (error) {
|
|
703
|
-
console.error(`Failed to get message for schema path ${
|
|
721
|
+
console.error(`Failed to get message for schema path ${path5}. Error processing directory ${pathToMessage}:`, error);
|
|
704
722
|
if (error instanceof Error) {
|
|
705
723
|
error.message = `Failed to retrieve message from ${pathToMessage}: ${error.message}`;
|
|
706
724
|
throw error;
|
|
@@ -794,10 +812,16 @@ var rmCustomDoc = (directory) => async (filePath) => {
|
|
|
794
812
|
|
|
795
813
|
// src/teams.ts
|
|
796
814
|
var import_promises9 = __toESM(require("fs/promises"));
|
|
815
|
+
var import_node_fs6 = __toESM(require("fs"));
|
|
816
|
+
var import_node_path11 = require("path");
|
|
817
|
+
var import_gray_matter7 = __toESM(require("gray-matter"));
|
|
818
|
+
var import_node_path12 = __toESM(require("path"));
|
|
819
|
+
|
|
820
|
+
// src/users.ts
|
|
797
821
|
var import_node_fs5 = __toESM(require("fs"));
|
|
798
822
|
var import_node_path10 = require("path");
|
|
799
823
|
var import_gray_matter6 = __toESM(require("gray-matter"));
|
|
800
|
-
var
|
|
824
|
+
var getUser = (catalogDir) => async (id) => {
|
|
801
825
|
const files = await getFiles(`${catalogDir}/${id}.{md,mdx}`);
|
|
802
826
|
if (files.length == 0) return void 0;
|
|
803
827
|
const file = files[0];
|
|
@@ -806,11 +830,12 @@ var getTeam = (catalogDir) => async (id) => {
|
|
|
806
830
|
...data,
|
|
807
831
|
id: data.id,
|
|
808
832
|
name: data.name,
|
|
833
|
+
avatarUrl: data.avatarUrl,
|
|
809
834
|
markdown: content.trim()
|
|
810
835
|
};
|
|
811
836
|
};
|
|
812
|
-
var
|
|
813
|
-
const files = await getFiles(`${catalogDir}/
|
|
837
|
+
var getUsers = (catalogDir) => async (options) => {
|
|
838
|
+
const files = await getFiles(`${catalogDir}/users/*.{md,mdx}`);
|
|
814
839
|
if (files.length === 0) return [];
|
|
815
840
|
return files.map((file) => {
|
|
816
841
|
const { data, content } = import_gray_matter6.default.read(file);
|
|
@@ -818,31 +843,29 @@ var getTeams = (catalogDir) => async (options) => {
|
|
|
818
843
|
...data,
|
|
819
844
|
id: data.id,
|
|
820
845
|
name: data.name,
|
|
846
|
+
avatarUrl: data.avatarUrl,
|
|
821
847
|
markdown: content.trim()
|
|
822
848
|
};
|
|
823
849
|
});
|
|
824
850
|
};
|
|
825
|
-
var
|
|
826
|
-
const resource = { ...
|
|
827
|
-
const
|
|
828
|
-
const exists =
|
|
851
|
+
var writeUser = (catalogDir) => async (user, options = {}) => {
|
|
852
|
+
const resource = { ...user };
|
|
853
|
+
const currentUser = await getUser(catalogDir)(resource.id);
|
|
854
|
+
const exists = currentUser !== void 0;
|
|
829
855
|
if (exists && !options.override) {
|
|
830
|
-
throw new Error(`Failed to write ${resource.id} (
|
|
856
|
+
throw new Error(`Failed to write ${resource.id} (user) as it already exists`);
|
|
831
857
|
}
|
|
832
858
|
const { markdown, ...frontmatter } = resource;
|
|
833
859
|
const document = import_gray_matter6.default.stringify(markdown, frontmatter);
|
|
834
860
|
import_node_fs5.default.mkdirSync((0, import_node_path10.join)(catalogDir, ""), { recursive: true });
|
|
835
861
|
import_node_fs5.default.writeFileSync((0, import_node_path10.join)(catalogDir, "", `${resource.id}.mdx`), document);
|
|
836
862
|
};
|
|
837
|
-
var
|
|
838
|
-
|
|
863
|
+
var rmUserById = (catalogDir) => async (id) => {
|
|
864
|
+
import_node_fs5.default.rmSync((0, import_node_path10.join)(catalogDir, `${id}.mdx`), { recursive: true });
|
|
839
865
|
};
|
|
840
866
|
|
|
841
|
-
// src/
|
|
842
|
-
var
|
|
843
|
-
var import_node_path11 = require("path");
|
|
844
|
-
var import_gray_matter7 = __toESM(require("gray-matter"));
|
|
845
|
-
var getUser = (catalogDir) => async (id) => {
|
|
867
|
+
// src/teams.ts
|
|
868
|
+
var getTeam = (catalogDir) => async (id) => {
|
|
846
869
|
const files = await getFiles(`${catalogDir}/${id}.{md,mdx}`);
|
|
847
870
|
if (files.length == 0) return void 0;
|
|
848
871
|
const file = files[0];
|
|
@@ -851,12 +874,11 @@ var getUser = (catalogDir) => async (id) => {
|
|
|
851
874
|
...data,
|
|
852
875
|
id: data.id,
|
|
853
876
|
name: data.name,
|
|
854
|
-
avatarUrl: data.avatarUrl,
|
|
855
877
|
markdown: content.trim()
|
|
856
878
|
};
|
|
857
879
|
};
|
|
858
|
-
var
|
|
859
|
-
const files = await getFiles(`${catalogDir}
|
|
880
|
+
var getTeams = (catalogDir) => async (options) => {
|
|
881
|
+
const files = await getFiles(`${catalogDir}/*.{md,mdx}`);
|
|
860
882
|
if (files.length === 0) return [];
|
|
861
883
|
return files.map((file) => {
|
|
862
884
|
const { data, content } = import_gray_matter7.default.read(file);
|
|
@@ -864,29 +886,46 @@ var getUsers = (catalogDir) => async (options) => {
|
|
|
864
886
|
...data,
|
|
865
887
|
id: data.id,
|
|
866
888
|
name: data.name,
|
|
867
|
-
avatarUrl: data.avatarUrl,
|
|
868
889
|
markdown: content.trim()
|
|
869
890
|
};
|
|
870
891
|
});
|
|
871
892
|
};
|
|
872
|
-
var
|
|
873
|
-
const resource = { ...
|
|
874
|
-
const
|
|
875
|
-
const exists =
|
|
893
|
+
var writeTeam = (catalogDir) => async (team, options = {}) => {
|
|
894
|
+
const resource = { ...team };
|
|
895
|
+
const currentTeam = await getTeam(catalogDir)(resource.id);
|
|
896
|
+
const exists = currentTeam !== void 0;
|
|
876
897
|
if (exists && !options.override) {
|
|
877
|
-
throw new Error(`Failed to write ${resource.id} (
|
|
898
|
+
throw new Error(`Failed to write ${resource.id} (team) as it already exists`);
|
|
878
899
|
}
|
|
879
900
|
const { markdown, ...frontmatter } = resource;
|
|
880
901
|
const document = import_gray_matter7.default.stringify(markdown, frontmatter);
|
|
881
902
|
import_node_fs6.default.mkdirSync((0, import_node_path11.join)(catalogDir, ""), { recursive: true });
|
|
882
903
|
import_node_fs6.default.writeFileSync((0, import_node_path11.join)(catalogDir, "", `${resource.id}.mdx`), document);
|
|
883
904
|
};
|
|
884
|
-
var
|
|
885
|
-
|
|
905
|
+
var rmTeamById = (catalogDir) => async (id) => {
|
|
906
|
+
await import_promises9.default.rm((0, import_node_path11.join)(catalogDir, `${id}.mdx`), { recursive: true });
|
|
907
|
+
};
|
|
908
|
+
var getOwnersForResource = (catalogDir) => async (id, version) => {
|
|
909
|
+
const resource = await getResource(catalogDir, id, version);
|
|
910
|
+
let owners = [];
|
|
911
|
+
if (!resource) return [];
|
|
912
|
+
if (!resource.owners) return [];
|
|
913
|
+
for (const owner of resource.owners) {
|
|
914
|
+
const team = await getTeam(import_node_path12.default.join(catalogDir, "teams"))(owner);
|
|
915
|
+
if (team) {
|
|
916
|
+
owners.push(team);
|
|
917
|
+
} else {
|
|
918
|
+
const user = await getUser(import_node_path12.default.join(catalogDir, "users"))(owner);
|
|
919
|
+
if (user) {
|
|
920
|
+
owners.push(user);
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
return owners;
|
|
886
925
|
};
|
|
887
926
|
|
|
888
927
|
// src/index.ts
|
|
889
|
-
var index_default = (
|
|
928
|
+
var index_default = (path5) => {
|
|
890
929
|
return {
|
|
891
930
|
/**
|
|
892
931
|
* Returns an events from EventCatalog
|
|
@@ -894,13 +933,13 @@ var index_default = (path4) => {
|
|
|
894
933
|
* @param version - Optional id of the version to get (supports semver)
|
|
895
934
|
* @returns Event|Undefined
|
|
896
935
|
*/
|
|
897
|
-
getEvent: getEvent((0,
|
|
936
|
+
getEvent: getEvent((0, import_node_path13.join)(path5)),
|
|
898
937
|
/**
|
|
899
938
|
* Returns all events from EventCatalog
|
|
900
939
|
* @param latestOnly - optional boolean, set to true to get only latest versions
|
|
901
940
|
* @returns Event[]|Undefined
|
|
902
941
|
*/
|
|
903
|
-
getEvents: getEvents((0,
|
|
942
|
+
getEvents: getEvents((0, import_node_path13.join)(path5)),
|
|
904
943
|
/**
|
|
905
944
|
* Adds an event to EventCatalog
|
|
906
945
|
*
|
|
@@ -908,7 +947,7 @@ var index_default = (path4) => {
|
|
|
908
947
|
* @param options - Optional options to write the event
|
|
909
948
|
*
|
|
910
949
|
*/
|
|
911
|
-
writeEvent: writeEvent((0,
|
|
950
|
+
writeEvent: writeEvent((0, import_node_path13.join)(path5, "events")),
|
|
912
951
|
/**
|
|
913
952
|
* Adds an event to a service in EventCatalog
|
|
914
953
|
*
|
|
@@ -917,26 +956,26 @@ var index_default = (path4) => {
|
|
|
917
956
|
* @param options - Optional options to write the event
|
|
918
957
|
*
|
|
919
958
|
*/
|
|
920
|
-
writeEventToService: writeEventToService((0,
|
|
959
|
+
writeEventToService: writeEventToService((0, import_node_path13.join)(path5)),
|
|
921
960
|
/**
|
|
922
961
|
* Remove an event to EventCatalog (modeled on the standard POSIX rm utility)
|
|
923
962
|
*
|
|
924
963
|
* @param path - The path to your event, e.g. `/Inventory/InventoryAdjusted`
|
|
925
964
|
*
|
|
926
965
|
*/
|
|
927
|
-
rmEvent: rmEvent((0,
|
|
966
|
+
rmEvent: rmEvent((0, import_node_path13.join)(path5, "events")),
|
|
928
967
|
/**
|
|
929
968
|
* Remove an event by an Event id
|
|
930
969
|
*
|
|
931
970
|
* @param id - The id of the event you want to remove
|
|
932
971
|
*
|
|
933
972
|
*/
|
|
934
|
-
rmEventById: rmEventById((0,
|
|
973
|
+
rmEventById: rmEventById((0, import_node_path13.join)(path5)),
|
|
935
974
|
/**
|
|
936
975
|
* Moves a given event id to the version directory
|
|
937
976
|
* @param directory
|
|
938
977
|
*/
|
|
939
|
-
versionEvent: versionEvent((0,
|
|
978
|
+
versionEvent: versionEvent((0, import_node_path13.join)(path5)),
|
|
940
979
|
/**
|
|
941
980
|
* Adds a file to the given event
|
|
942
981
|
* @param id - The id of the event to add the file to
|
|
@@ -944,7 +983,7 @@ var index_default = (path4) => {
|
|
|
944
983
|
* @param version - Optional version of the event to add the file to
|
|
945
984
|
* @returns
|
|
946
985
|
*/
|
|
947
|
-
addFileToEvent: addFileToEvent((0,
|
|
986
|
+
addFileToEvent: addFileToEvent((0, import_node_path13.join)(path5)),
|
|
948
987
|
/**
|
|
949
988
|
* Adds a schema to the given event
|
|
950
989
|
* @param id - The id of the event to add the schema to
|
|
@@ -952,14 +991,14 @@ var index_default = (path4) => {
|
|
|
952
991
|
* @param version - Optional version of the event to add the schema to
|
|
953
992
|
* @returns
|
|
954
993
|
*/
|
|
955
|
-
addSchemaToEvent: addSchemaToEvent((0,
|
|
994
|
+
addSchemaToEvent: addSchemaToEvent((0, import_node_path13.join)(path5)),
|
|
956
995
|
/**
|
|
957
996
|
* Check to see if an event version exists
|
|
958
997
|
* @param id - The id of the event
|
|
959
998
|
* @param version - The version of the event (supports semver)
|
|
960
999
|
* @returns
|
|
961
1000
|
*/
|
|
962
|
-
eventHasVersion: eventHasVersion((0,
|
|
1001
|
+
eventHasVersion: eventHasVersion((0, import_node_path13.join)(path5)),
|
|
963
1002
|
/**
|
|
964
1003
|
* ================================
|
|
965
1004
|
* Commands
|
|
@@ -971,13 +1010,13 @@ var index_default = (path4) => {
|
|
|
971
1010
|
* @param version - Optional id of the version to get (supports semver)
|
|
972
1011
|
* @returns Command|Undefined
|
|
973
1012
|
*/
|
|
974
|
-
getCommand: getCommand((0,
|
|
1013
|
+
getCommand: getCommand((0, import_node_path13.join)(path5)),
|
|
975
1014
|
/**
|
|
976
1015
|
* Returns all commands from EventCatalog
|
|
977
1016
|
* @param latestOnly - optional boolean, set to true to get only latest versions
|
|
978
1017
|
* @returns Command[]|Undefined
|
|
979
1018
|
*/
|
|
980
|
-
getCommands: getCommands((0,
|
|
1019
|
+
getCommands: getCommands((0, import_node_path13.join)(path5)),
|
|
981
1020
|
/**
|
|
982
1021
|
* Adds an command to EventCatalog
|
|
983
1022
|
*
|
|
@@ -985,7 +1024,7 @@ var index_default = (path4) => {
|
|
|
985
1024
|
* @param options - Optional options to write the command
|
|
986
1025
|
*
|
|
987
1026
|
*/
|
|
988
|
-
writeCommand: writeCommand((0,
|
|
1027
|
+
writeCommand: writeCommand((0, import_node_path13.join)(path5, "commands")),
|
|
989
1028
|
/**
|
|
990
1029
|
* Adds a command to a service in EventCatalog
|
|
991
1030
|
*
|
|
@@ -994,26 +1033,26 @@ var index_default = (path4) => {
|
|
|
994
1033
|
* @param options - Optional options to write the command
|
|
995
1034
|
*
|
|
996
1035
|
*/
|
|
997
|
-
writeCommandToService: writeCommandToService((0,
|
|
1036
|
+
writeCommandToService: writeCommandToService((0, import_node_path13.join)(path5)),
|
|
998
1037
|
/**
|
|
999
1038
|
* Remove an command to EventCatalog (modeled on the standard POSIX rm utility)
|
|
1000
1039
|
*
|
|
1001
1040
|
* @param path - The path to your command, e.g. `/Inventory/InventoryAdjusted`
|
|
1002
1041
|
*
|
|
1003
1042
|
*/
|
|
1004
|
-
rmCommand: rmCommand((0,
|
|
1043
|
+
rmCommand: rmCommand((0, import_node_path13.join)(path5, "commands")),
|
|
1005
1044
|
/**
|
|
1006
1045
|
* Remove an command by an Event id
|
|
1007
1046
|
*
|
|
1008
1047
|
* @param id - The id of the command you want to remove
|
|
1009
1048
|
*
|
|
1010
1049
|
*/
|
|
1011
|
-
rmCommandById: rmCommandById((0,
|
|
1050
|
+
rmCommandById: rmCommandById((0, import_node_path13.join)(path5)),
|
|
1012
1051
|
/**
|
|
1013
1052
|
* Moves a given command id to the version directory
|
|
1014
1053
|
* @param directory
|
|
1015
1054
|
*/
|
|
1016
|
-
versionCommand: versionCommand((0,
|
|
1055
|
+
versionCommand: versionCommand((0, import_node_path13.join)(path5)),
|
|
1017
1056
|
/**
|
|
1018
1057
|
* Adds a file to the given command
|
|
1019
1058
|
* @param id - The id of the command to add the file to
|
|
@@ -1021,7 +1060,7 @@ var index_default = (path4) => {
|
|
|
1021
1060
|
* @param version - Optional version of the command to add the file to
|
|
1022
1061
|
* @returns
|
|
1023
1062
|
*/
|
|
1024
|
-
addFileToCommand: addFileToCommand((0,
|
|
1063
|
+
addFileToCommand: addFileToCommand((0, import_node_path13.join)(path5)),
|
|
1025
1064
|
/**
|
|
1026
1065
|
* Adds a schema to the given command
|
|
1027
1066
|
* @param id - The id of the command to add the schema to
|
|
@@ -1029,14 +1068,14 @@ var index_default = (path4) => {
|
|
|
1029
1068
|
* @param version - Optional version of the command to add the schema to
|
|
1030
1069
|
* @returns
|
|
1031
1070
|
*/
|
|
1032
|
-
addSchemaToCommand: addSchemaToCommand((0,
|
|
1071
|
+
addSchemaToCommand: addSchemaToCommand((0, import_node_path13.join)(path5)),
|
|
1033
1072
|
/**
|
|
1034
1073
|
* Check to see if a command version exists
|
|
1035
1074
|
* @param id - The id of the command
|
|
1036
1075
|
* @param version - The version of the command (supports semver)
|
|
1037
1076
|
* @returns
|
|
1038
1077
|
*/
|
|
1039
|
-
commandHasVersion: commandHasVersion((0,
|
|
1078
|
+
commandHasVersion: commandHasVersion((0, import_node_path13.join)(path5)),
|
|
1040
1079
|
/**
|
|
1041
1080
|
* ================================
|
|
1042
1081
|
* Queries
|
|
@@ -1048,13 +1087,13 @@ var index_default = (path4) => {
|
|
|
1048
1087
|
* @param version - Optional id of the version to get (supports semver)
|
|
1049
1088
|
* @returns Query|Undefined
|
|
1050
1089
|
*/
|
|
1051
|
-
getQuery: getQuery((0,
|
|
1090
|
+
getQuery: getQuery((0, import_node_path13.join)(path5)),
|
|
1052
1091
|
/**
|
|
1053
1092
|
* Returns all queries from EventCatalog
|
|
1054
1093
|
* @param latestOnly - optional boolean, set to true to get only latest versions
|
|
1055
1094
|
* @returns Query[]|Undefined
|
|
1056
1095
|
*/
|
|
1057
|
-
getQueries: getQueries((0,
|
|
1096
|
+
getQueries: getQueries((0, import_node_path13.join)(path5)),
|
|
1058
1097
|
/**
|
|
1059
1098
|
* Adds a query to EventCatalog
|
|
1060
1099
|
*
|
|
@@ -1062,7 +1101,7 @@ var index_default = (path4) => {
|
|
|
1062
1101
|
* @param options - Optional options to write the event
|
|
1063
1102
|
*
|
|
1064
1103
|
*/
|
|
1065
|
-
writeQuery: writeQuery((0,
|
|
1104
|
+
writeQuery: writeQuery((0, import_node_path13.join)(path5, "queries")),
|
|
1066
1105
|
/**
|
|
1067
1106
|
* Adds a query to a service in EventCatalog
|
|
1068
1107
|
*
|
|
@@ -1071,26 +1110,26 @@ var index_default = (path4) => {
|
|
|
1071
1110
|
* @param options - Optional options to write the query
|
|
1072
1111
|
*
|
|
1073
1112
|
*/
|
|
1074
|
-
writeQueryToService: writeQueryToService((0,
|
|
1113
|
+
writeQueryToService: writeQueryToService((0, import_node_path13.join)(path5)),
|
|
1075
1114
|
/**
|
|
1076
1115
|
* Remove an query to EventCatalog (modeled on the standard POSIX rm utility)
|
|
1077
1116
|
*
|
|
1078
1117
|
* @param path - The path to your query, e.g. `/Orders/GetOrder`
|
|
1079
1118
|
*
|
|
1080
1119
|
*/
|
|
1081
|
-
rmQuery: rmQuery((0,
|
|
1120
|
+
rmQuery: rmQuery((0, import_node_path13.join)(path5, "queries")),
|
|
1082
1121
|
/**
|
|
1083
1122
|
* Remove a query by a Query id
|
|
1084
1123
|
*
|
|
1085
1124
|
* @param id - The id of the query you want to remove
|
|
1086
1125
|
*
|
|
1087
1126
|
*/
|
|
1088
|
-
rmQueryById: rmQueryById((0,
|
|
1127
|
+
rmQueryById: rmQueryById((0, import_node_path13.join)(path5)),
|
|
1089
1128
|
/**
|
|
1090
1129
|
* Moves a given query id to the version directory
|
|
1091
1130
|
* @param directory
|
|
1092
1131
|
*/
|
|
1093
|
-
versionQuery: versionQuery((0,
|
|
1132
|
+
versionQuery: versionQuery((0, import_node_path13.join)(path5)),
|
|
1094
1133
|
/**
|
|
1095
1134
|
* Adds a file to the given query
|
|
1096
1135
|
* @param id - The id of the query to add the file to
|
|
@@ -1098,7 +1137,7 @@ var index_default = (path4) => {
|
|
|
1098
1137
|
* @param version - Optional version of the query to add the file to
|
|
1099
1138
|
* @returns
|
|
1100
1139
|
*/
|
|
1101
|
-
addFileToQuery: addFileToQuery((0,
|
|
1140
|
+
addFileToQuery: addFileToQuery((0, import_node_path13.join)(path5)),
|
|
1102
1141
|
/**
|
|
1103
1142
|
* Adds a schema to the given query
|
|
1104
1143
|
* @param id - The id of the query to add the schema to
|
|
@@ -1106,14 +1145,14 @@ var index_default = (path4) => {
|
|
|
1106
1145
|
* @param version - Optional version of the query to add the schema to
|
|
1107
1146
|
* @returns
|
|
1108
1147
|
*/
|
|
1109
|
-
addSchemaToQuery: addSchemaToQuery((0,
|
|
1148
|
+
addSchemaToQuery: addSchemaToQuery((0, import_node_path13.join)(path5)),
|
|
1110
1149
|
/**
|
|
1111
1150
|
* Check to see if an query version exists
|
|
1112
1151
|
* @param id - The id of the query
|
|
1113
1152
|
* @param version - The version of the query (supports semver)
|
|
1114
1153
|
* @returns
|
|
1115
1154
|
*/
|
|
1116
|
-
queryHasVersion: queryHasVersion((0,
|
|
1155
|
+
queryHasVersion: queryHasVersion((0, import_node_path13.join)(path5)),
|
|
1117
1156
|
/**
|
|
1118
1157
|
* ================================
|
|
1119
1158
|
* Channels
|
|
@@ -1125,13 +1164,13 @@ var index_default = (path4) => {
|
|
|
1125
1164
|
* @param version - Optional id of the version to get (supports semver)
|
|
1126
1165
|
* @returns Channel|Undefined
|
|
1127
1166
|
*/
|
|
1128
|
-
getChannel: getChannel((0,
|
|
1167
|
+
getChannel: getChannel((0, import_node_path13.join)(path5)),
|
|
1129
1168
|
/**
|
|
1130
1169
|
* Returns all channels from EventCatalog
|
|
1131
1170
|
* @param latestOnly - optional boolean, set to true to get only latest versions
|
|
1132
1171
|
* @returns Channel[]|Undefined
|
|
1133
1172
|
*/
|
|
1134
|
-
getChannels: getChannels((0,
|
|
1173
|
+
getChannels: getChannels((0, import_node_path13.join)(path5)),
|
|
1135
1174
|
/**
|
|
1136
1175
|
* Adds an channel to EventCatalog
|
|
1137
1176
|
*
|
|
@@ -1139,33 +1178,33 @@ var index_default = (path4) => {
|
|
|
1139
1178
|
* @param options - Optional options to write the channel
|
|
1140
1179
|
*
|
|
1141
1180
|
*/
|
|
1142
|
-
writeChannel: writeChannel((0,
|
|
1181
|
+
writeChannel: writeChannel((0, import_node_path13.join)(path5, "channels")),
|
|
1143
1182
|
/**
|
|
1144
1183
|
* Remove an channel to EventCatalog (modeled on the standard POSIX rm utility)
|
|
1145
1184
|
*
|
|
1146
1185
|
* @param path - The path to your channel, e.g. `/Inventory/InventoryAdjusted`
|
|
1147
1186
|
*
|
|
1148
1187
|
*/
|
|
1149
|
-
rmChannel: rmChannel((0,
|
|
1188
|
+
rmChannel: rmChannel((0, import_node_path13.join)(path5, "channels")),
|
|
1150
1189
|
/**
|
|
1151
1190
|
* Remove an channel by an Event id
|
|
1152
1191
|
*
|
|
1153
1192
|
* @param id - The id of the channel you want to remove
|
|
1154
1193
|
*
|
|
1155
1194
|
*/
|
|
1156
|
-
rmChannelById: rmChannelById((0,
|
|
1195
|
+
rmChannelById: rmChannelById((0, import_node_path13.join)(path5)),
|
|
1157
1196
|
/**
|
|
1158
1197
|
* Moves a given channel id to the version directory
|
|
1159
1198
|
* @param directory
|
|
1160
1199
|
*/
|
|
1161
|
-
versionChannel: versionChannel((0,
|
|
1200
|
+
versionChannel: versionChannel((0, import_node_path13.join)(path5)),
|
|
1162
1201
|
/**
|
|
1163
1202
|
* Check to see if a channel version exists
|
|
1164
1203
|
* @param id - The id of the channel
|
|
1165
1204
|
* @param version - The version of the channel (supports semver)
|
|
1166
1205
|
* @returns
|
|
1167
1206
|
*/
|
|
1168
|
-
channelHasVersion: channelHasVersion((0,
|
|
1207
|
+
channelHasVersion: channelHasVersion((0, import_node_path13.join)(path5)),
|
|
1169
1208
|
/**
|
|
1170
1209
|
* Add a channel to an event
|
|
1171
1210
|
*
|
|
@@ -1182,7 +1221,7 @@ var index_default = (path4) => {
|
|
|
1182
1221
|
*
|
|
1183
1222
|
* ```
|
|
1184
1223
|
*/
|
|
1185
|
-
addEventToChannel: addMessageToChannel((0,
|
|
1224
|
+
addEventToChannel: addMessageToChannel((0, import_node_path13.join)(path5), "events"),
|
|
1186
1225
|
/**
|
|
1187
1226
|
* Add a channel to an command
|
|
1188
1227
|
*
|
|
@@ -1199,7 +1238,7 @@ var index_default = (path4) => {
|
|
|
1199
1238
|
*
|
|
1200
1239
|
* ```
|
|
1201
1240
|
*/
|
|
1202
|
-
addCommandToChannel: addMessageToChannel((0,
|
|
1241
|
+
addCommandToChannel: addMessageToChannel((0, import_node_path13.join)(path5), "commands"),
|
|
1203
1242
|
/**
|
|
1204
1243
|
* Add a channel to an query
|
|
1205
1244
|
*
|
|
@@ -1216,7 +1255,7 @@ var index_default = (path4) => {
|
|
|
1216
1255
|
*
|
|
1217
1256
|
* ```
|
|
1218
1257
|
*/
|
|
1219
|
-
addQueryToChannel: addMessageToChannel((0,
|
|
1258
|
+
addQueryToChannel: addMessageToChannel((0, import_node_path13.join)(path5), "queries"),
|
|
1220
1259
|
/**
|
|
1221
1260
|
* ================================
|
|
1222
1261
|
* SERVICES
|
|
@@ -1229,14 +1268,14 @@ var index_default = (path4) => {
|
|
|
1229
1268
|
* @param options - Optional options to write the event
|
|
1230
1269
|
*
|
|
1231
1270
|
*/
|
|
1232
|
-
writeService: writeService((0,
|
|
1271
|
+
writeService: writeService((0, import_node_path13.join)(path5, "services")),
|
|
1233
1272
|
/**
|
|
1234
1273
|
* Adds a versioned service to EventCatalog
|
|
1235
1274
|
*
|
|
1236
1275
|
* @param service - The service to write
|
|
1237
1276
|
*
|
|
1238
1277
|
*/
|
|
1239
|
-
writeVersionedService: writeVersionedService((0,
|
|
1278
|
+
writeVersionedService: writeVersionedService((0, import_node_path13.join)(path5, "services")),
|
|
1240
1279
|
/**
|
|
1241
1280
|
* Adds a service to a domain in EventCatalog
|
|
1242
1281
|
*
|
|
@@ -1245,39 +1284,45 @@ var index_default = (path4) => {
|
|
|
1245
1284
|
* @param options - Optional options to write the event
|
|
1246
1285
|
*
|
|
1247
1286
|
*/
|
|
1248
|
-
writeServiceToDomain: writeServiceToDomain((0,
|
|
1287
|
+
writeServiceToDomain: writeServiceToDomain((0, import_node_path13.join)(path5, "domains")),
|
|
1249
1288
|
/**
|
|
1250
1289
|
* Returns a service from EventCatalog
|
|
1251
1290
|
* @param id - The id of the service to retrieve
|
|
1252
1291
|
* @param version - Optional id of the version to get (supports semver)
|
|
1253
1292
|
* @returns Service|Undefined
|
|
1254
1293
|
*/
|
|
1255
|
-
getService: getService((0,
|
|
1294
|
+
getService: getService((0, import_node_path13.join)(path5)),
|
|
1295
|
+
/**
|
|
1296
|
+
* Returns a service from EventCatalog by it's path.
|
|
1297
|
+
* @param path - The path to the service to retrieve
|
|
1298
|
+
* @returns Service|Undefined
|
|
1299
|
+
*/
|
|
1300
|
+
getServiceByPath: getServiceByPath((0, import_node_path13.join)(path5)),
|
|
1256
1301
|
/**
|
|
1257
1302
|
* Returns all services from EventCatalog
|
|
1258
1303
|
* @param latestOnly - optional boolean, set to true to get only latest versions
|
|
1259
1304
|
* @returns Service[]|Undefined
|
|
1260
1305
|
*/
|
|
1261
|
-
getServices: getServices((0,
|
|
1306
|
+
getServices: getServices((0, import_node_path13.join)(path5)),
|
|
1262
1307
|
/**
|
|
1263
1308
|
* Moves a given service id to the version directory
|
|
1264
1309
|
* @param directory
|
|
1265
1310
|
*/
|
|
1266
|
-
versionService: versionService((0,
|
|
1311
|
+
versionService: versionService((0, import_node_path13.join)(path5)),
|
|
1267
1312
|
/**
|
|
1268
1313
|
* Remove a service from EventCatalog (modeled on the standard POSIX rm utility)
|
|
1269
1314
|
*
|
|
1270
1315
|
* @param path - The path to your service, e.g. `/InventoryService`
|
|
1271
1316
|
*
|
|
1272
1317
|
*/
|
|
1273
|
-
rmService: rmService((0,
|
|
1318
|
+
rmService: rmService((0, import_node_path13.join)(path5, "services")),
|
|
1274
1319
|
/**
|
|
1275
1320
|
* Remove an service by an service id
|
|
1276
1321
|
*
|
|
1277
1322
|
* @param id - The id of the service you want to remove
|
|
1278
1323
|
*
|
|
1279
1324
|
*/
|
|
1280
|
-
rmServiceById: rmServiceById((0,
|
|
1325
|
+
rmServiceById: rmServiceById((0, import_node_path13.join)(path5)),
|
|
1281
1326
|
/**
|
|
1282
1327
|
* Adds a file to the given service
|
|
1283
1328
|
* @param id - The id of the service to add the file to
|
|
@@ -1285,21 +1330,21 @@ var index_default = (path4) => {
|
|
|
1285
1330
|
* @param version - Optional version of the service to add the file to
|
|
1286
1331
|
* @returns
|
|
1287
1332
|
*/
|
|
1288
|
-
addFileToService: addFileToService((0,
|
|
1333
|
+
addFileToService: addFileToService((0, import_node_path13.join)(path5)),
|
|
1289
1334
|
/**
|
|
1290
1335
|
* Returns the specifications for a given service
|
|
1291
1336
|
* @param id - The id of the service to retrieve the specifications for
|
|
1292
1337
|
* @param version - Optional version of the service
|
|
1293
1338
|
* @returns
|
|
1294
1339
|
*/
|
|
1295
|
-
getSpecificationFilesForService: getSpecificationFilesForService((0,
|
|
1340
|
+
getSpecificationFilesForService: getSpecificationFilesForService((0, import_node_path13.join)(path5)),
|
|
1296
1341
|
/**
|
|
1297
1342
|
* Check to see if a service version exists
|
|
1298
1343
|
* @param id - The id of the service
|
|
1299
1344
|
* @param version - The version of the service (supports semver)
|
|
1300
1345
|
* @returns
|
|
1301
1346
|
*/
|
|
1302
|
-
serviceHasVersion: serviceHasVersion((0,
|
|
1347
|
+
serviceHasVersion: serviceHasVersion((0, import_node_path13.join)(path5)),
|
|
1303
1348
|
/**
|
|
1304
1349
|
* Add an event to a service by it's id.
|
|
1305
1350
|
*
|
|
@@ -1319,7 +1364,7 @@ var index_default = (path4) => {
|
|
|
1319
1364
|
*
|
|
1320
1365
|
* ```
|
|
1321
1366
|
*/
|
|
1322
|
-
addEventToService: addMessageToService((0,
|
|
1367
|
+
addEventToService: addMessageToService((0, import_node_path13.join)(path5)),
|
|
1323
1368
|
/**
|
|
1324
1369
|
* Add a command to a service by it's id.
|
|
1325
1370
|
*
|
|
@@ -1339,7 +1384,7 @@ var index_default = (path4) => {
|
|
|
1339
1384
|
*
|
|
1340
1385
|
* ```
|
|
1341
1386
|
*/
|
|
1342
|
-
addCommandToService: addMessageToService((0,
|
|
1387
|
+
addCommandToService: addMessageToService((0, import_node_path13.join)(path5)),
|
|
1343
1388
|
/**
|
|
1344
1389
|
* Add a query to a service by it's id.
|
|
1345
1390
|
*
|
|
@@ -1359,7 +1404,30 @@ var index_default = (path4) => {
|
|
|
1359
1404
|
*
|
|
1360
1405
|
* ```
|
|
1361
1406
|
*/
|
|
1362
|
-
addQueryToService: addMessageToService((0,
|
|
1407
|
+
addQueryToService: addMessageToService((0, import_node_path13.join)(path5)),
|
|
1408
|
+
/**
|
|
1409
|
+
* Check to see if a service exists by it's path.
|
|
1410
|
+
*
|
|
1411
|
+
* @example
|
|
1412
|
+
* ```ts
|
|
1413
|
+
* import utils from '@eventcatalog/utils';
|
|
1414
|
+
*
|
|
1415
|
+
* const { isService } = utils('/path/to/eventcatalog');
|
|
1416
|
+
*
|
|
1417
|
+
* // returns true if the path is a service
|
|
1418
|
+
* await isService('/services/InventoryService/index.mdx');
|
|
1419
|
+
* ```
|
|
1420
|
+
*
|
|
1421
|
+
* @param path - The path to the service to check
|
|
1422
|
+
* @returns boolean
|
|
1423
|
+
*/
|
|
1424
|
+
isService: isService((0, import_node_path13.join)(path5)),
|
|
1425
|
+
/**
|
|
1426
|
+
* Converts a file to a service.
|
|
1427
|
+
* @param file - The file to convert to a service.
|
|
1428
|
+
* @returns The service.
|
|
1429
|
+
*/
|
|
1430
|
+
toService: toService((0, import_node_path13.join)(path5)),
|
|
1363
1431
|
/**
|
|
1364
1432
|
* ================================
|
|
1365
1433
|
* Domains
|
|
@@ -1372,39 +1440,39 @@ var index_default = (path4) => {
|
|
|
1372
1440
|
* @param options - Optional options to write the event
|
|
1373
1441
|
*
|
|
1374
1442
|
*/
|
|
1375
|
-
writeDomain: writeDomain((0,
|
|
1443
|
+
writeDomain: writeDomain((0, import_node_path13.join)(path5, "domains")),
|
|
1376
1444
|
/**
|
|
1377
1445
|
* Returns a domain from EventCatalog
|
|
1378
1446
|
* @param id - The id of the domain to retrieve
|
|
1379
1447
|
* @param version - Optional id of the version to get (supports semver)
|
|
1380
1448
|
* @returns Domain|Undefined
|
|
1381
1449
|
*/
|
|
1382
|
-
getDomain: getDomain((0,
|
|
1450
|
+
getDomain: getDomain((0, import_node_path13.join)(path5, "domains")),
|
|
1383
1451
|
/**
|
|
1384
1452
|
* Returns all domains from EventCatalog
|
|
1385
1453
|
* @param latestOnly - optional boolean, set to true to get only latest versions
|
|
1386
1454
|
* @returns Domain[]|Undefined
|
|
1387
1455
|
*/
|
|
1388
|
-
getDomains: getDomains((0,
|
|
1456
|
+
getDomains: getDomains((0, import_node_path13.join)(path5)),
|
|
1389
1457
|
/**
|
|
1390
1458
|
* Moves a given domain id to the version directory
|
|
1391
1459
|
* @param directory
|
|
1392
1460
|
*/
|
|
1393
|
-
versionDomain: versionDomain((0,
|
|
1461
|
+
versionDomain: versionDomain((0, import_node_path13.join)(path5, "domains")),
|
|
1394
1462
|
/**
|
|
1395
1463
|
* Remove a domain from EventCatalog (modeled on the standard POSIX rm utility)
|
|
1396
1464
|
*
|
|
1397
1465
|
* @param path - The path to your domain, e.g. `/Payment`
|
|
1398
1466
|
*
|
|
1399
1467
|
*/
|
|
1400
|
-
rmDomain: rmDomain((0,
|
|
1468
|
+
rmDomain: rmDomain((0, import_node_path13.join)(path5, "domains")),
|
|
1401
1469
|
/**
|
|
1402
1470
|
* Remove an service by an domain id
|
|
1403
1471
|
*
|
|
1404
1472
|
* @param id - The id of the domain you want to remove
|
|
1405
1473
|
*
|
|
1406
1474
|
*/
|
|
1407
|
-
rmDomainById: rmDomainById((0,
|
|
1475
|
+
rmDomainById: rmDomainById((0, import_node_path13.join)(path5, "domains")),
|
|
1408
1476
|
/**
|
|
1409
1477
|
* Adds a file to the given domain
|
|
1410
1478
|
* @param id - The id of the domain to add the file to
|
|
@@ -1412,28 +1480,28 @@ var index_default = (path4) => {
|
|
|
1412
1480
|
* @param version - Optional version of the domain to add the file to
|
|
1413
1481
|
* @returns
|
|
1414
1482
|
*/
|
|
1415
|
-
addFileToDomain: addFileToDomain((0,
|
|
1483
|
+
addFileToDomain: addFileToDomain((0, import_node_path13.join)(path5, "domains")),
|
|
1416
1484
|
/**
|
|
1417
1485
|
* Adds an ubiquitous language dictionary to a domain
|
|
1418
1486
|
* @param id - The id of the domain to add the ubiquitous language to
|
|
1419
1487
|
* @param ubiquitousLanguageDictionary - The ubiquitous language dictionary to add
|
|
1420
1488
|
* @param version - Optional version of the domain to add the ubiquitous language to
|
|
1421
1489
|
*/
|
|
1422
|
-
addUbiquitousLanguageToDomain: addUbiquitousLanguageToDomain((0,
|
|
1490
|
+
addUbiquitousLanguageToDomain: addUbiquitousLanguageToDomain((0, import_node_path13.join)(path5, "domains")),
|
|
1423
1491
|
/**
|
|
1424
1492
|
* Get the ubiquitous language dictionary from a domain
|
|
1425
1493
|
* @param id - The id of the domain to get the ubiquitous language from
|
|
1426
1494
|
* @param version - Optional version of the domain to get the ubiquitous language from
|
|
1427
1495
|
* @returns
|
|
1428
1496
|
*/
|
|
1429
|
-
getUbiquitousLanguageFromDomain: getUbiquitousLanguageFromDomain((0,
|
|
1497
|
+
getUbiquitousLanguageFromDomain: getUbiquitousLanguageFromDomain((0, import_node_path13.join)(path5, "domains")),
|
|
1430
1498
|
/**
|
|
1431
1499
|
* Check to see if a domain version exists
|
|
1432
1500
|
* @param id - The id of the domain
|
|
1433
1501
|
* @param version - The version of the domain (supports semver)
|
|
1434
1502
|
* @returns
|
|
1435
1503
|
*/
|
|
1436
|
-
domainHasVersion: domainHasVersion((0,
|
|
1504
|
+
domainHasVersion: domainHasVersion((0, import_node_path13.join)(path5)),
|
|
1437
1505
|
/**
|
|
1438
1506
|
* Adds a given service to a domain
|
|
1439
1507
|
* @param id - The id of the domain
|
|
@@ -1441,7 +1509,7 @@ var index_default = (path4) => {
|
|
|
1441
1509
|
* @param version - (Optional) The version of the domain to add the service to
|
|
1442
1510
|
* @returns
|
|
1443
1511
|
*/
|
|
1444
|
-
addServiceToDomain: addServiceToDomain((0,
|
|
1512
|
+
addServiceToDomain: addServiceToDomain((0, import_node_path13.join)(path5, "domains")),
|
|
1445
1513
|
/**
|
|
1446
1514
|
* Adds a given subdomain to a domain
|
|
1447
1515
|
* @param id - The id of the domain
|
|
@@ -1449,7 +1517,7 @@ var index_default = (path4) => {
|
|
|
1449
1517
|
* @param version - (Optional) The version of the domain to add the subdomain to
|
|
1450
1518
|
* @returns
|
|
1451
1519
|
*/
|
|
1452
|
-
addSubDomainToDomain: addSubDomainToDomain((0,
|
|
1520
|
+
addSubDomainToDomain: addSubDomainToDomain((0, import_node_path13.join)(path5, "domains")),
|
|
1453
1521
|
/**
|
|
1454
1522
|
* ================================
|
|
1455
1523
|
* Teams
|
|
@@ -1462,25 +1530,25 @@ var index_default = (path4) => {
|
|
|
1462
1530
|
* @param options - Optional options to write the team
|
|
1463
1531
|
*
|
|
1464
1532
|
*/
|
|
1465
|
-
writeTeam: writeTeam((0,
|
|
1533
|
+
writeTeam: writeTeam((0, import_node_path13.join)(path5, "teams")),
|
|
1466
1534
|
/**
|
|
1467
1535
|
* Returns a team from EventCatalog
|
|
1468
1536
|
* @param id - The id of the team to retrieve
|
|
1469
1537
|
* @returns Team|Undefined
|
|
1470
1538
|
*/
|
|
1471
|
-
getTeam: getTeam((0,
|
|
1539
|
+
getTeam: getTeam((0, import_node_path13.join)(path5, "teams")),
|
|
1472
1540
|
/**
|
|
1473
1541
|
* Returns all teams from EventCatalog
|
|
1474
1542
|
* @returns Team[]|Undefined
|
|
1475
1543
|
*/
|
|
1476
|
-
getTeams: getTeams((0,
|
|
1544
|
+
getTeams: getTeams((0, import_node_path13.join)(path5, "teams")),
|
|
1477
1545
|
/**
|
|
1478
1546
|
* Remove a team by the team id
|
|
1479
1547
|
*
|
|
1480
1548
|
* @param id - The id of the team you want to remove
|
|
1481
1549
|
*
|
|
1482
1550
|
*/
|
|
1483
|
-
rmTeamById: rmTeamById((0,
|
|
1551
|
+
rmTeamById: rmTeamById((0, import_node_path13.join)(path5, "teams")),
|
|
1484
1552
|
/**
|
|
1485
1553
|
* ================================
|
|
1486
1554
|
* Users
|
|
@@ -1493,25 +1561,25 @@ var index_default = (path4) => {
|
|
|
1493
1561
|
* @param options - Optional options to write the user
|
|
1494
1562
|
*
|
|
1495
1563
|
*/
|
|
1496
|
-
writeUser: writeUser((0,
|
|
1564
|
+
writeUser: writeUser((0, import_node_path13.join)(path5, "users")),
|
|
1497
1565
|
/**
|
|
1498
1566
|
* Returns a user from EventCatalog
|
|
1499
1567
|
* @param id - The id of the user to retrieve
|
|
1500
1568
|
* @returns User|Undefined
|
|
1501
1569
|
*/
|
|
1502
|
-
getUser: getUser((0,
|
|
1570
|
+
getUser: getUser((0, import_node_path13.join)(path5, "users")),
|
|
1503
1571
|
/**
|
|
1504
1572
|
* Returns all user from EventCatalog
|
|
1505
1573
|
* @returns User[]|Undefined
|
|
1506
1574
|
*/
|
|
1507
|
-
getUsers: getUsers((0,
|
|
1575
|
+
getUsers: getUsers((0, import_node_path13.join)(path5)),
|
|
1508
1576
|
/**
|
|
1509
1577
|
* Remove a user by the user id
|
|
1510
1578
|
*
|
|
1511
1579
|
* @param id - The id of the user you want to remove
|
|
1512
1580
|
*
|
|
1513
1581
|
*/
|
|
1514
|
-
rmUserById: rmUserById((0,
|
|
1582
|
+
rmUserById: rmUserById((0, import_node_path13.join)(path5, "users")),
|
|
1515
1583
|
/**
|
|
1516
1584
|
* ================================
|
|
1517
1585
|
* Custom Docs
|
|
@@ -1522,32 +1590,32 @@ var index_default = (path4) => {
|
|
|
1522
1590
|
* @param path - The path to the custom doc to retrieve
|
|
1523
1591
|
* @returns CustomDoc|Undefined
|
|
1524
1592
|
*/
|
|
1525
|
-
getCustomDoc: getCustomDoc((0,
|
|
1593
|
+
getCustomDoc: getCustomDoc((0, import_node_path13.join)(path5, "docs")),
|
|
1526
1594
|
/**
|
|
1527
1595
|
* Returns all custom docs from EventCatalog
|
|
1528
1596
|
* @param options - Optional options to get custom docs from a specific path
|
|
1529
1597
|
* @returns CustomDoc[]|Undefined
|
|
1530
1598
|
*/
|
|
1531
|
-
getCustomDocs: getCustomDocs((0,
|
|
1599
|
+
getCustomDocs: getCustomDocs((0, import_node_path13.join)(path5, "docs")),
|
|
1532
1600
|
/**
|
|
1533
1601
|
* Writes a custom doc to EventCatalog
|
|
1534
1602
|
* @param customDoc - The custom doc to write
|
|
1535
1603
|
* @param options - Optional options to write the custom doc
|
|
1536
1604
|
*
|
|
1537
1605
|
*/
|
|
1538
|
-
writeCustomDoc: writeCustomDoc((0,
|
|
1606
|
+
writeCustomDoc: writeCustomDoc((0, import_node_path13.join)(path5, "docs")),
|
|
1539
1607
|
/**
|
|
1540
1608
|
* Removes a custom doc from EventCatalog
|
|
1541
1609
|
* @param path - The path to the custom doc to remove
|
|
1542
1610
|
*
|
|
1543
1611
|
*/
|
|
1544
|
-
rmCustomDoc: rmCustomDoc((0,
|
|
1612
|
+
rmCustomDoc: rmCustomDoc((0, import_node_path13.join)(path5, "docs")),
|
|
1545
1613
|
/**
|
|
1546
1614
|
* Dumps the catalog to a JSON file.
|
|
1547
1615
|
* @param directory - The directory to dump the catalog to
|
|
1548
1616
|
* @returns A JSON file with the catalog
|
|
1549
1617
|
*/
|
|
1550
|
-
dumpCatalog: dumpCatalog((0,
|
|
1618
|
+
dumpCatalog: dumpCatalog((0, import_node_path13.join)(path5)),
|
|
1551
1619
|
/**
|
|
1552
1620
|
* Returns the event catalog configuration file.
|
|
1553
1621
|
* The event catalog configuration file is the file that contains the configuration for the event catalog.
|
|
@@ -1555,7 +1623,7 @@ var index_default = (path4) => {
|
|
|
1555
1623
|
* @param directory - The directory of the catalog.
|
|
1556
1624
|
* @returns A JSON object with the configuration for the event catalog.
|
|
1557
1625
|
*/
|
|
1558
|
-
getEventCatalogConfigurationFile: getEventCatalogConfigurationFile((0,
|
|
1626
|
+
getEventCatalogConfigurationFile: getEventCatalogConfigurationFile((0, import_node_path13.join)(path5)),
|
|
1559
1627
|
/**
|
|
1560
1628
|
* ================================
|
|
1561
1629
|
* Resources Utils
|
|
@@ -1576,14 +1644,21 @@ var index_default = (path4) => {
|
|
|
1576
1644
|
* @param path - The path to the message to retrieve
|
|
1577
1645
|
* @returns Message|Undefined
|
|
1578
1646
|
*/
|
|
1579
|
-
getMessageBySchemaPath: getMessageBySchemaPath((0,
|
|
1647
|
+
getMessageBySchemaPath: getMessageBySchemaPath((0, import_node_path13.join)(path5)),
|
|
1580
1648
|
/**
|
|
1581
1649
|
* Returns the producers and consumers (services) for a given message
|
|
1582
1650
|
* @param id - The id of the message to get the producers and consumers for
|
|
1583
1651
|
* @param version - Optional version of the message
|
|
1584
1652
|
* @returns { producers: Service[], consumers: Service[] }
|
|
1585
1653
|
*/
|
|
1586
|
-
getProducersAndConsumersForMessage: getProducersAndConsumersForMessage((0,
|
|
1654
|
+
getProducersAndConsumersForMessage: getProducersAndConsumersForMessage((0, import_node_path13.join)(path5)),
|
|
1655
|
+
/**
|
|
1656
|
+
* Returns the owners for a given resource (e.g domain, service, event, command, query, etc.)
|
|
1657
|
+
* @param id - The id of the resource to get the owners for
|
|
1658
|
+
* @param version - Optional version of the resource
|
|
1659
|
+
* @returns { owners: User[] }
|
|
1660
|
+
*/
|
|
1661
|
+
getOwnersForResource: getOwnersForResource((0, import_node_path13.join)(path5))
|
|
1587
1662
|
};
|
|
1588
1663
|
};
|
|
1589
1664
|
|
|
@@ -1591,7 +1666,7 @@ var index_default = (path4) => {
|
|
|
1591
1666
|
var DUMP_VERSION = "0.0.1";
|
|
1592
1667
|
var getEventCatalogVersion = async (catalogDir) => {
|
|
1593
1668
|
try {
|
|
1594
|
-
const packageJson = import_fs.default.readFileSync((0,
|
|
1669
|
+
const packageJson = import_fs.default.readFileSync((0, import_node_path14.join)(catalogDir, "package.json"), "utf8");
|
|
1595
1670
|
const packageJsonObject = JSON.parse(packageJson);
|
|
1596
1671
|
return packageJsonObject["dependencies"]["@eventcatalog/core"];
|
|
1597
1672
|
} catch (error) {
|
|
@@ -1604,7 +1679,7 @@ var hydrateResource = async (catalogDir, resources = [], { attachSchema = false
|
|
|
1604
1679
|
const resourcePath = await getResourcePath(catalogDir, resource.id, resource.version);
|
|
1605
1680
|
let schema = "";
|
|
1606
1681
|
if (resource.schemaPath && resourcePath?.fullPath) {
|
|
1607
|
-
const pathToSchema =
|
|
1682
|
+
const pathToSchema = import_node_path14.default.join(import_node_path14.default.dirname(resourcePath?.fullPath), resource.schemaPath);
|
|
1608
1683
|
if (import_fs.default.existsSync(pathToSchema)) {
|
|
1609
1684
|
schema = import_fs.default.readFileSync(pathToSchema, "utf8");
|
|
1610
1685
|
}
|
|
@@ -1625,8 +1700,8 @@ var filterCollection = (collection, options) => {
|
|
|
1625
1700
|
};
|
|
1626
1701
|
var getEventCatalogConfigurationFile = (directory) => async () => {
|
|
1627
1702
|
try {
|
|
1628
|
-
const
|
|
1629
|
-
const configModule = await import(
|
|
1703
|
+
const path5 = (0, import_node_path14.join)(directory, "eventcatalog.config.js");
|
|
1704
|
+
const configModule = await import(path5);
|
|
1630
1705
|
return configModule.default;
|
|
1631
1706
|
} catch (error) {
|
|
1632
1707
|
console.error("Error getting event catalog configuration file", error);
|
|
@@ -1634,7 +1709,7 @@ var getEventCatalogConfigurationFile = (directory) => async () => {
|
|
|
1634
1709
|
}
|
|
1635
1710
|
};
|
|
1636
1711
|
var dumpCatalog = (directory) => async (options) => {
|
|
1637
|
-
const { getDomains: getDomains2, getServices: getServices2, getEvents: getEvents2, getQueries: getQueries2, getCommands: getCommands2, getChannels: getChannels2, getTeams: getTeams2, getUsers:
|
|
1712
|
+
const { getDomains: getDomains2, getServices: getServices2, getEvents: getEvents2, getQueries: getQueries2, getCommands: getCommands2, getChannels: getChannels2, getTeams: getTeams2, getUsers: getUsers3 } = index_default(directory);
|
|
1638
1713
|
const { includeMarkdown = true } = options || {};
|
|
1639
1714
|
const domains = await getDomains2();
|
|
1640
1715
|
const services = await getServices2();
|
|
@@ -1642,7 +1717,7 @@ var dumpCatalog = (directory) => async (options) => {
|
|
|
1642
1717
|
const commands = await getCommands2();
|
|
1643
1718
|
const queries = await getQueries2();
|
|
1644
1719
|
const teams = await getTeams2();
|
|
1645
|
-
const users = await
|
|
1720
|
+
const users = await getUsers3();
|
|
1646
1721
|
const channels = await getChannels2();
|
|
1647
1722
|
const [
|
|
1648
1723
|
hydratedDomains,
|