@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.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/eventcatalog.ts
|
|
2
2
|
import fs10 from "fs";
|
|
3
|
-
import
|
|
3
|
+
import path4, { join as join14 } from "path";
|
|
4
4
|
|
|
5
5
|
// src/index.ts
|
|
6
6
|
import { join as join13 } from "path";
|
|
@@ -24,13 +24,13 @@ var versionExists = async (catalogDir, id, version) => {
|
|
|
24
24
|
var findFileById = async (catalogDir, id, version) => {
|
|
25
25
|
const files = await getFiles(`${catalogDir}/**/index.{md,mdx}`);
|
|
26
26
|
const matchedFiles = await searchFilesForId(files, id) || [];
|
|
27
|
-
const latestVersion = matchedFiles.find((
|
|
27
|
+
const latestVersion = matchedFiles.find((path5) => !path5.includes("versioned"));
|
|
28
28
|
if (!version) {
|
|
29
29
|
return latestVersion;
|
|
30
30
|
}
|
|
31
|
-
const parsedFiles = matchedFiles.map((
|
|
32
|
-
const { data } = matter.read(
|
|
33
|
-
return { ...data, path:
|
|
31
|
+
const parsedFiles = matchedFiles.map((path5) => {
|
|
32
|
+
const { data } = matter.read(path5);
|
|
33
|
+
return { ...data, path: path5 };
|
|
34
34
|
});
|
|
35
35
|
const semverRange = validRange(version);
|
|
36
36
|
if (semverRange && valid(version)) {
|
|
@@ -71,8 +71,8 @@ var getFiles = async (pattern, ignore = "") => {
|
|
|
71
71
|
);
|
|
72
72
|
}
|
|
73
73
|
};
|
|
74
|
-
var readMdxFile = async (
|
|
75
|
-
const { data } = matter.read(
|
|
74
|
+
var readMdxFile = async (path5) => {
|
|
75
|
+
const { data } = matter.read(path5);
|
|
76
76
|
const { markdown, ...frontmatter } = data;
|
|
77
77
|
return { ...frontmatter, markdown };
|
|
78
78
|
};
|
|
@@ -155,8 +155,8 @@ var writeResource = async (catalogDir, resource, options = {
|
|
|
155
155
|
versionExistingContent: false,
|
|
156
156
|
format: "mdx"
|
|
157
157
|
}) => {
|
|
158
|
-
const
|
|
159
|
-
const fullPath = join2(catalogDir,
|
|
158
|
+
const path5 = options.path || `/${resource.id}`;
|
|
159
|
+
const fullPath = join2(catalogDir, path5);
|
|
160
160
|
const format = options.format || "mdx";
|
|
161
161
|
fsSync2.mkdirSync(fullPath, { recursive: true });
|
|
162
162
|
const lockPath = join2(fullPath, `index.${format}`);
|
|
@@ -191,10 +191,10 @@ var writeResource = async (catalogDir, resource, options = {
|
|
|
191
191
|
});
|
|
192
192
|
}
|
|
193
193
|
};
|
|
194
|
-
var getResource = async (catalogDir, id, version, options) => {
|
|
194
|
+
var getResource = async (catalogDir, id, version, options, filePath) => {
|
|
195
195
|
const attachSchema = options?.attachSchema || false;
|
|
196
|
-
const file = await findFileById(catalogDir, id, version);
|
|
197
|
-
if (!file) return;
|
|
196
|
+
const file = filePath || (id ? await findFileById(catalogDir, id, version) : void 0);
|
|
197
|
+
if (!file || !fsSync2.existsSync(file)) return;
|
|
198
198
|
const { data, content } = matter2.read(file);
|
|
199
199
|
if (attachSchema && data?.schemaPath) {
|
|
200
200
|
const resourceDirectory = dirname2(file);
|
|
@@ -222,6 +222,13 @@ var getResourcePath = async (catalogDir, id, version) => {
|
|
|
222
222
|
directory: dirname2(file.replace(catalogDir, ""))
|
|
223
223
|
};
|
|
224
224
|
};
|
|
225
|
+
var toResource = async (catalogDir, file) => {
|
|
226
|
+
const { data, content } = matter2.read(file);
|
|
227
|
+
return {
|
|
228
|
+
...data,
|
|
229
|
+
markdown: content.trim()
|
|
230
|
+
};
|
|
231
|
+
};
|
|
225
232
|
var getResources = async (catalogDir, {
|
|
226
233
|
type,
|
|
227
234
|
latestOnly = false,
|
|
@@ -319,8 +326,8 @@ var writeEventToService = (directory) => async (event, service, options = { path
|
|
|
319
326
|
pathForEvent = join3(pathForEvent, event.id);
|
|
320
327
|
await writeResource(directory, { ...event }, { ...options, path: pathForEvent, type: "event" });
|
|
321
328
|
};
|
|
322
|
-
var rmEvent = (directory) => async (
|
|
323
|
-
await fs2.rm(join3(directory,
|
|
329
|
+
var rmEvent = (directory) => async (path5) => {
|
|
330
|
+
await fs2.rm(join3(directory, path5), { recursive: true });
|
|
324
331
|
};
|
|
325
332
|
var rmEventById = (directory) => async (id, version, persistFiles) => {
|
|
326
333
|
await rmResourceById(directory, id, version, { type: "event", persistFiles });
|
|
@@ -355,8 +362,8 @@ var writeCommandToService = (directory) => async (command, service, options = {
|
|
|
355
362
|
pathForCommand = join4(pathForCommand, command.id);
|
|
356
363
|
await writeResource(directory, { ...command }, { ...options, path: pathForCommand, type: "command" });
|
|
357
364
|
};
|
|
358
|
-
var rmCommand = (directory) => async (
|
|
359
|
-
await fs3.rm(join4(directory,
|
|
365
|
+
var rmCommand = (directory) => async (path5) => {
|
|
366
|
+
await fs3.rm(join4(directory, path5), { recursive: true });
|
|
360
367
|
};
|
|
361
368
|
var rmCommandById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "command", persistFiles });
|
|
362
369
|
var versionCommand = (directory) => async (id) => versionResource(directory, id);
|
|
@@ -389,8 +396,8 @@ var writeQueryToService = (directory) => async (query, service, options = { path
|
|
|
389
396
|
pathForQuery = join5(pathForQuery, query.id);
|
|
390
397
|
await writeResource(directory, { ...query }, { ...options, path: pathForQuery, type: "query" });
|
|
391
398
|
};
|
|
392
|
-
var rmQuery = (directory) => async (
|
|
393
|
-
await fs4.rm(join5(directory,
|
|
399
|
+
var rmQuery = (directory) => async (path5) => {
|
|
400
|
+
await fs4.rm(join5(directory, path5), { recursive: true });
|
|
394
401
|
};
|
|
395
402
|
var rmQueryById = (directory) => async (id, version, persistFiles) => {
|
|
396
403
|
await rmResourceById(directory, id, version, { type: "query", persistFiles });
|
|
@@ -407,8 +414,12 @@ var queryHasVersion = (directory) => async (id, version) => {
|
|
|
407
414
|
|
|
408
415
|
// src/services.ts
|
|
409
416
|
import fs5 from "fs/promises";
|
|
410
|
-
import { join as join6, dirname as dirname4, extname } from "path";
|
|
417
|
+
import { join as join6, dirname as dirname4, extname, relative as relative2 } from "path";
|
|
411
418
|
var getService = (directory) => async (id, version) => getResource(directory, id, version, { type: "service" });
|
|
419
|
+
var getServiceByPath = (directory) => async (path5) => {
|
|
420
|
+
const service = await getResource(directory, void 0, void 0, { type: "service" }, path5);
|
|
421
|
+
return service;
|
|
422
|
+
};
|
|
412
423
|
var getServices = (directory) => async (options) => getResources(directory, {
|
|
413
424
|
type: "services",
|
|
414
425
|
ignore: ["**/events/**", "**/commands/**", "**/queries/**", "**/entities/**", "**/subdomains/**/entities/**"],
|
|
@@ -430,8 +441,8 @@ var writeService = (directory) => async (service, options = {
|
|
|
430
441
|
};
|
|
431
442
|
var writeVersionedService = (directory) => async (service) => {
|
|
432
443
|
const resource = { ...service };
|
|
433
|
-
const
|
|
434
|
-
return await writeService(directory)(resource, { path:
|
|
444
|
+
const path5 = getVersionedDirectory(service.id, service.version);
|
|
445
|
+
return await writeService(directory)(resource, { path: path5 });
|
|
435
446
|
};
|
|
436
447
|
var writeServiceToDomain = (directory) => async (service, domain, options = { path: "", format: "mdx", override: false }) => {
|
|
437
448
|
let pathForService = domain.version && domain.version !== "latest" ? `/${domain.id}/versioned/${domain.version}/services` : `/${domain.id}/services`;
|
|
@@ -439,8 +450,8 @@ var writeServiceToDomain = (directory) => async (service, domain, options = { pa
|
|
|
439
450
|
await writeResource(directory, { ...service }, { ...options, path: pathForService, type: "service" });
|
|
440
451
|
};
|
|
441
452
|
var versionService = (directory) => async (id) => versionResource(directory, id);
|
|
442
|
-
var rmService = (directory) => async (
|
|
443
|
-
await fs5.rm(join6(directory,
|
|
453
|
+
var rmService = (directory) => async (path5) => {
|
|
454
|
+
await fs5.rm(join6(directory, path5), { recursive: true });
|
|
444
455
|
};
|
|
445
456
|
var rmServiceById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "service", persistFiles });
|
|
446
457
|
var addFileToService = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
|
|
@@ -495,8 +506,8 @@ var addMessageToService = (directory) => async (id, direction, event, version) =
|
|
|
495
506
|
if (!existingResource) {
|
|
496
507
|
throw new Error(`Cannot find service ${id} in the catalog`);
|
|
497
508
|
}
|
|
498
|
-
const
|
|
499
|
-
const pathToResource = join6(
|
|
509
|
+
const path5 = existingResource.split(/[\\/]+services/)[0];
|
|
510
|
+
const pathToResource = join6(path5, "services");
|
|
500
511
|
await rmServiceById(directory)(id, version);
|
|
501
512
|
await writeService(pathToResource)(service, { format: extension === ".md" ? "md" : "mdx" });
|
|
502
513
|
};
|
|
@@ -504,6 +515,13 @@ var serviceHasVersion = (directory) => async (id, version) => {
|
|
|
504
515
|
const file = await findFileById(directory, id, version);
|
|
505
516
|
return !!file;
|
|
506
517
|
};
|
|
518
|
+
var isService = (directory) => async (path5) => {
|
|
519
|
+
const service = await getServiceByPath(directory)(path5);
|
|
520
|
+
const relativePath = relative2(directory, path5);
|
|
521
|
+
const segments = relativePath.split(/[/\\]+/);
|
|
522
|
+
return !!service && segments.includes("services");
|
|
523
|
+
};
|
|
524
|
+
var toService = (directory) => async (file) => toResource(directory, file);
|
|
507
525
|
|
|
508
526
|
// src/domains.ts
|
|
509
527
|
import fs6 from "fs/promises";
|
|
@@ -532,8 +550,8 @@ var writeDomain = (directory) => async (domain, options = {
|
|
|
532
550
|
return await writeResource(directory, resource, { ...options, type: "domain" });
|
|
533
551
|
};
|
|
534
552
|
var versionDomain = (directory) => async (id) => versionResource(directory, id);
|
|
535
|
-
var rmDomain = (directory) => async (
|
|
536
|
-
await fs6.rm(join7(directory,
|
|
553
|
+
var rmDomain = (directory) => async (path5) => {
|
|
554
|
+
await fs6.rm(join7(directory, path5), { recursive: true });
|
|
537
555
|
};
|
|
538
556
|
var rmDomainById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "domain", persistFiles });
|
|
539
557
|
var addFileToDomain = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
|
|
@@ -594,8 +612,8 @@ import { join as join8, extname as extname2 } from "path";
|
|
|
594
612
|
var getChannel = (directory) => async (id, version) => getResource(directory, id, version, { type: "channel" });
|
|
595
613
|
var getChannels = (directory) => async (options) => getResources(directory, { type: "channels", ...options });
|
|
596
614
|
var writeChannel = (directory) => async (channel, options = { path: "" }) => writeResource(directory, { ...channel }, { ...options, type: "channel" });
|
|
597
|
-
var rmChannel = (directory) => async (
|
|
598
|
-
await fs7.rm(join8(directory,
|
|
615
|
+
var rmChannel = (directory) => async (path5) => {
|
|
616
|
+
await fs7.rm(join8(directory, path5), { recursive: true });
|
|
599
617
|
};
|
|
600
618
|
var rmChannelById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "channel", persistFiles });
|
|
601
619
|
var versionChannel = (directory) => async (id) => versionResource(directory, id);
|
|
@@ -636,8 +654,8 @@ var addMessageToChannel = (directory, collection) => async (id, _message, versio
|
|
|
636
654
|
if (!existingResource) {
|
|
637
655
|
throw new Error(`Cannot find message ${id} in the catalog`);
|
|
638
656
|
}
|
|
639
|
-
const
|
|
640
|
-
const pathToResource = join8(
|
|
657
|
+
const path5 = existingResource.split(`/[\\/]+${collection}`)[0];
|
|
658
|
+
const pathToResource = join8(path5, collection);
|
|
641
659
|
await rmMessageById(directory)(_message.id, _message.version, true);
|
|
642
660
|
await writeMessage(pathToResource)(message, { format: extension === ".md" ? "md" : "mdx" });
|
|
643
661
|
};
|
|
@@ -646,8 +664,8 @@ var addMessageToChannel = (directory, collection) => async (id, _message, versio
|
|
|
646
664
|
import { dirname as dirname5 } from "path";
|
|
647
665
|
import matter4 from "gray-matter";
|
|
648
666
|
import { satisfies as satisfies3, validRange as validRange2 } from "semver";
|
|
649
|
-
var getMessageBySchemaPath = (directory) => async (
|
|
650
|
-
const pathToMessage = dirname5(
|
|
667
|
+
var getMessageBySchemaPath = (directory) => async (path5, options) => {
|
|
668
|
+
const pathToMessage = dirname5(path5);
|
|
651
669
|
try {
|
|
652
670
|
const files = await getFiles(`${directory}/${pathToMessage}/index.{md,mdx}`);
|
|
653
671
|
if (!files || files.length === 0) {
|
|
@@ -665,7 +683,7 @@ var getMessageBySchemaPath = (directory) => async (path4, options) => {
|
|
|
665
683
|
}
|
|
666
684
|
return message;
|
|
667
685
|
} catch (error) {
|
|
668
|
-
console.error(`Failed to get message for schema path ${
|
|
686
|
+
console.error(`Failed to get message for schema path ${path5}. Error processing directory ${pathToMessage}:`, error);
|
|
669
687
|
if (error instanceof Error) {
|
|
670
688
|
error.message = `Failed to retrieve message from ${pathToMessage}: ${error.message}`;
|
|
671
689
|
throw error;
|
|
@@ -759,10 +777,16 @@ var rmCustomDoc = (directory) => async (filePath) => {
|
|
|
759
777
|
|
|
760
778
|
// src/teams.ts
|
|
761
779
|
import fs9 from "fs/promises";
|
|
780
|
+
import fsSync6 from "fs";
|
|
781
|
+
import { join as join12 } from "path";
|
|
782
|
+
import matter7 from "gray-matter";
|
|
783
|
+
import path3 from "path";
|
|
784
|
+
|
|
785
|
+
// src/users.ts
|
|
762
786
|
import fsSync5 from "fs";
|
|
763
787
|
import { join as join11 } from "path";
|
|
764
788
|
import matter6 from "gray-matter";
|
|
765
|
-
var
|
|
789
|
+
var getUser = (catalogDir) => async (id) => {
|
|
766
790
|
const files = await getFiles(`${catalogDir}/${id}.{md,mdx}`);
|
|
767
791
|
if (files.length == 0) return void 0;
|
|
768
792
|
const file = files[0];
|
|
@@ -771,11 +795,12 @@ var getTeam = (catalogDir) => async (id) => {
|
|
|
771
795
|
...data,
|
|
772
796
|
id: data.id,
|
|
773
797
|
name: data.name,
|
|
798
|
+
avatarUrl: data.avatarUrl,
|
|
774
799
|
markdown: content.trim()
|
|
775
800
|
};
|
|
776
801
|
};
|
|
777
|
-
var
|
|
778
|
-
const files = await getFiles(`${catalogDir}/
|
|
802
|
+
var getUsers = (catalogDir) => async (options) => {
|
|
803
|
+
const files = await getFiles(`${catalogDir}/users/*.{md,mdx}`);
|
|
779
804
|
if (files.length === 0) return [];
|
|
780
805
|
return files.map((file) => {
|
|
781
806
|
const { data, content } = matter6.read(file);
|
|
@@ -783,31 +808,29 @@ var getTeams = (catalogDir) => async (options) => {
|
|
|
783
808
|
...data,
|
|
784
809
|
id: data.id,
|
|
785
810
|
name: data.name,
|
|
811
|
+
avatarUrl: data.avatarUrl,
|
|
786
812
|
markdown: content.trim()
|
|
787
813
|
};
|
|
788
814
|
});
|
|
789
815
|
};
|
|
790
|
-
var
|
|
791
|
-
const resource = { ...
|
|
792
|
-
const
|
|
793
|
-
const exists =
|
|
816
|
+
var writeUser = (catalogDir) => async (user, options = {}) => {
|
|
817
|
+
const resource = { ...user };
|
|
818
|
+
const currentUser = await getUser(catalogDir)(resource.id);
|
|
819
|
+
const exists = currentUser !== void 0;
|
|
794
820
|
if (exists && !options.override) {
|
|
795
|
-
throw new Error(`Failed to write ${resource.id} (
|
|
821
|
+
throw new Error(`Failed to write ${resource.id} (user) as it already exists`);
|
|
796
822
|
}
|
|
797
823
|
const { markdown, ...frontmatter } = resource;
|
|
798
824
|
const document = matter6.stringify(markdown, frontmatter);
|
|
799
825
|
fsSync5.mkdirSync(join11(catalogDir, ""), { recursive: true });
|
|
800
826
|
fsSync5.writeFileSync(join11(catalogDir, "", `${resource.id}.mdx`), document);
|
|
801
827
|
};
|
|
802
|
-
var
|
|
803
|
-
|
|
828
|
+
var rmUserById = (catalogDir) => async (id) => {
|
|
829
|
+
fsSync5.rmSync(join11(catalogDir, `${id}.mdx`), { recursive: true });
|
|
804
830
|
};
|
|
805
831
|
|
|
806
|
-
// src/
|
|
807
|
-
|
|
808
|
-
import { join as join12 } from "path";
|
|
809
|
-
import matter7 from "gray-matter";
|
|
810
|
-
var getUser = (catalogDir) => async (id) => {
|
|
832
|
+
// src/teams.ts
|
|
833
|
+
var getTeam = (catalogDir) => async (id) => {
|
|
811
834
|
const files = await getFiles(`${catalogDir}/${id}.{md,mdx}`);
|
|
812
835
|
if (files.length == 0) return void 0;
|
|
813
836
|
const file = files[0];
|
|
@@ -816,12 +839,11 @@ var getUser = (catalogDir) => async (id) => {
|
|
|
816
839
|
...data,
|
|
817
840
|
id: data.id,
|
|
818
841
|
name: data.name,
|
|
819
|
-
avatarUrl: data.avatarUrl,
|
|
820
842
|
markdown: content.trim()
|
|
821
843
|
};
|
|
822
844
|
};
|
|
823
|
-
var
|
|
824
|
-
const files = await getFiles(`${catalogDir}
|
|
845
|
+
var getTeams = (catalogDir) => async (options) => {
|
|
846
|
+
const files = await getFiles(`${catalogDir}/*.{md,mdx}`);
|
|
825
847
|
if (files.length === 0) return [];
|
|
826
848
|
return files.map((file) => {
|
|
827
849
|
const { data, content } = matter7.read(file);
|
|
@@ -829,29 +851,46 @@ var getUsers = (catalogDir) => async (options) => {
|
|
|
829
851
|
...data,
|
|
830
852
|
id: data.id,
|
|
831
853
|
name: data.name,
|
|
832
|
-
avatarUrl: data.avatarUrl,
|
|
833
854
|
markdown: content.trim()
|
|
834
855
|
};
|
|
835
856
|
});
|
|
836
857
|
};
|
|
837
|
-
var
|
|
838
|
-
const resource = { ...
|
|
839
|
-
const
|
|
840
|
-
const exists =
|
|
858
|
+
var writeTeam = (catalogDir) => async (team, options = {}) => {
|
|
859
|
+
const resource = { ...team };
|
|
860
|
+
const currentTeam = await getTeam(catalogDir)(resource.id);
|
|
861
|
+
const exists = currentTeam !== void 0;
|
|
841
862
|
if (exists && !options.override) {
|
|
842
|
-
throw new Error(`Failed to write ${resource.id} (
|
|
863
|
+
throw new Error(`Failed to write ${resource.id} (team) as it already exists`);
|
|
843
864
|
}
|
|
844
865
|
const { markdown, ...frontmatter } = resource;
|
|
845
866
|
const document = matter7.stringify(markdown, frontmatter);
|
|
846
867
|
fsSync6.mkdirSync(join12(catalogDir, ""), { recursive: true });
|
|
847
868
|
fsSync6.writeFileSync(join12(catalogDir, "", `${resource.id}.mdx`), document);
|
|
848
869
|
};
|
|
849
|
-
var
|
|
850
|
-
|
|
870
|
+
var rmTeamById = (catalogDir) => async (id) => {
|
|
871
|
+
await fs9.rm(join12(catalogDir, `${id}.mdx`), { recursive: true });
|
|
872
|
+
};
|
|
873
|
+
var getOwnersForResource = (catalogDir) => async (id, version) => {
|
|
874
|
+
const resource = await getResource(catalogDir, id, version);
|
|
875
|
+
let owners = [];
|
|
876
|
+
if (!resource) return [];
|
|
877
|
+
if (!resource.owners) return [];
|
|
878
|
+
for (const owner of resource.owners) {
|
|
879
|
+
const team = await getTeam(path3.join(catalogDir, "teams"))(owner);
|
|
880
|
+
if (team) {
|
|
881
|
+
owners.push(team);
|
|
882
|
+
} else {
|
|
883
|
+
const user = await getUser(path3.join(catalogDir, "users"))(owner);
|
|
884
|
+
if (user) {
|
|
885
|
+
owners.push(user);
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
return owners;
|
|
851
890
|
};
|
|
852
891
|
|
|
853
892
|
// src/index.ts
|
|
854
|
-
var index_default = (
|
|
893
|
+
var index_default = (path5) => {
|
|
855
894
|
return {
|
|
856
895
|
/**
|
|
857
896
|
* Returns an events from EventCatalog
|
|
@@ -859,13 +898,13 @@ var index_default = (path4) => {
|
|
|
859
898
|
* @param version - Optional id of the version to get (supports semver)
|
|
860
899
|
* @returns Event|Undefined
|
|
861
900
|
*/
|
|
862
|
-
getEvent: getEvent(join13(
|
|
901
|
+
getEvent: getEvent(join13(path5)),
|
|
863
902
|
/**
|
|
864
903
|
* Returns all events from EventCatalog
|
|
865
904
|
* @param latestOnly - optional boolean, set to true to get only latest versions
|
|
866
905
|
* @returns Event[]|Undefined
|
|
867
906
|
*/
|
|
868
|
-
getEvents: getEvents(join13(
|
|
907
|
+
getEvents: getEvents(join13(path5)),
|
|
869
908
|
/**
|
|
870
909
|
* Adds an event to EventCatalog
|
|
871
910
|
*
|
|
@@ -873,7 +912,7 @@ var index_default = (path4) => {
|
|
|
873
912
|
* @param options - Optional options to write the event
|
|
874
913
|
*
|
|
875
914
|
*/
|
|
876
|
-
writeEvent: writeEvent(join13(
|
|
915
|
+
writeEvent: writeEvent(join13(path5, "events")),
|
|
877
916
|
/**
|
|
878
917
|
* Adds an event to a service in EventCatalog
|
|
879
918
|
*
|
|
@@ -882,26 +921,26 @@ var index_default = (path4) => {
|
|
|
882
921
|
* @param options - Optional options to write the event
|
|
883
922
|
*
|
|
884
923
|
*/
|
|
885
|
-
writeEventToService: writeEventToService(join13(
|
|
924
|
+
writeEventToService: writeEventToService(join13(path5)),
|
|
886
925
|
/**
|
|
887
926
|
* Remove an event to EventCatalog (modeled on the standard POSIX rm utility)
|
|
888
927
|
*
|
|
889
928
|
* @param path - The path to your event, e.g. `/Inventory/InventoryAdjusted`
|
|
890
929
|
*
|
|
891
930
|
*/
|
|
892
|
-
rmEvent: rmEvent(join13(
|
|
931
|
+
rmEvent: rmEvent(join13(path5, "events")),
|
|
893
932
|
/**
|
|
894
933
|
* Remove an event by an Event id
|
|
895
934
|
*
|
|
896
935
|
* @param id - The id of the event you want to remove
|
|
897
936
|
*
|
|
898
937
|
*/
|
|
899
|
-
rmEventById: rmEventById(join13(
|
|
938
|
+
rmEventById: rmEventById(join13(path5)),
|
|
900
939
|
/**
|
|
901
940
|
* Moves a given event id to the version directory
|
|
902
941
|
* @param directory
|
|
903
942
|
*/
|
|
904
|
-
versionEvent: versionEvent(join13(
|
|
943
|
+
versionEvent: versionEvent(join13(path5)),
|
|
905
944
|
/**
|
|
906
945
|
* Adds a file to the given event
|
|
907
946
|
* @param id - The id of the event to add the file to
|
|
@@ -909,7 +948,7 @@ var index_default = (path4) => {
|
|
|
909
948
|
* @param version - Optional version of the event to add the file to
|
|
910
949
|
* @returns
|
|
911
950
|
*/
|
|
912
|
-
addFileToEvent: addFileToEvent(join13(
|
|
951
|
+
addFileToEvent: addFileToEvent(join13(path5)),
|
|
913
952
|
/**
|
|
914
953
|
* Adds a schema to the given event
|
|
915
954
|
* @param id - The id of the event to add the schema to
|
|
@@ -917,14 +956,14 @@ var index_default = (path4) => {
|
|
|
917
956
|
* @param version - Optional version of the event to add the schema to
|
|
918
957
|
* @returns
|
|
919
958
|
*/
|
|
920
|
-
addSchemaToEvent: addSchemaToEvent(join13(
|
|
959
|
+
addSchemaToEvent: addSchemaToEvent(join13(path5)),
|
|
921
960
|
/**
|
|
922
961
|
* Check to see if an event version exists
|
|
923
962
|
* @param id - The id of the event
|
|
924
963
|
* @param version - The version of the event (supports semver)
|
|
925
964
|
* @returns
|
|
926
965
|
*/
|
|
927
|
-
eventHasVersion: eventHasVersion(join13(
|
|
966
|
+
eventHasVersion: eventHasVersion(join13(path5)),
|
|
928
967
|
/**
|
|
929
968
|
* ================================
|
|
930
969
|
* Commands
|
|
@@ -936,13 +975,13 @@ var index_default = (path4) => {
|
|
|
936
975
|
* @param version - Optional id of the version to get (supports semver)
|
|
937
976
|
* @returns Command|Undefined
|
|
938
977
|
*/
|
|
939
|
-
getCommand: getCommand(join13(
|
|
978
|
+
getCommand: getCommand(join13(path5)),
|
|
940
979
|
/**
|
|
941
980
|
* Returns all commands from EventCatalog
|
|
942
981
|
* @param latestOnly - optional boolean, set to true to get only latest versions
|
|
943
982
|
* @returns Command[]|Undefined
|
|
944
983
|
*/
|
|
945
|
-
getCommands: getCommands(join13(
|
|
984
|
+
getCommands: getCommands(join13(path5)),
|
|
946
985
|
/**
|
|
947
986
|
* Adds an command to EventCatalog
|
|
948
987
|
*
|
|
@@ -950,7 +989,7 @@ var index_default = (path4) => {
|
|
|
950
989
|
* @param options - Optional options to write the command
|
|
951
990
|
*
|
|
952
991
|
*/
|
|
953
|
-
writeCommand: writeCommand(join13(
|
|
992
|
+
writeCommand: writeCommand(join13(path5, "commands")),
|
|
954
993
|
/**
|
|
955
994
|
* Adds a command to a service in EventCatalog
|
|
956
995
|
*
|
|
@@ -959,26 +998,26 @@ var index_default = (path4) => {
|
|
|
959
998
|
* @param options - Optional options to write the command
|
|
960
999
|
*
|
|
961
1000
|
*/
|
|
962
|
-
writeCommandToService: writeCommandToService(join13(
|
|
1001
|
+
writeCommandToService: writeCommandToService(join13(path5)),
|
|
963
1002
|
/**
|
|
964
1003
|
* Remove an command to EventCatalog (modeled on the standard POSIX rm utility)
|
|
965
1004
|
*
|
|
966
1005
|
* @param path - The path to your command, e.g. `/Inventory/InventoryAdjusted`
|
|
967
1006
|
*
|
|
968
1007
|
*/
|
|
969
|
-
rmCommand: rmCommand(join13(
|
|
1008
|
+
rmCommand: rmCommand(join13(path5, "commands")),
|
|
970
1009
|
/**
|
|
971
1010
|
* Remove an command by an Event id
|
|
972
1011
|
*
|
|
973
1012
|
* @param id - The id of the command you want to remove
|
|
974
1013
|
*
|
|
975
1014
|
*/
|
|
976
|
-
rmCommandById: rmCommandById(join13(
|
|
1015
|
+
rmCommandById: rmCommandById(join13(path5)),
|
|
977
1016
|
/**
|
|
978
1017
|
* Moves a given command id to the version directory
|
|
979
1018
|
* @param directory
|
|
980
1019
|
*/
|
|
981
|
-
versionCommand: versionCommand(join13(
|
|
1020
|
+
versionCommand: versionCommand(join13(path5)),
|
|
982
1021
|
/**
|
|
983
1022
|
* Adds a file to the given command
|
|
984
1023
|
* @param id - The id of the command to add the file to
|
|
@@ -986,7 +1025,7 @@ var index_default = (path4) => {
|
|
|
986
1025
|
* @param version - Optional version of the command to add the file to
|
|
987
1026
|
* @returns
|
|
988
1027
|
*/
|
|
989
|
-
addFileToCommand: addFileToCommand(join13(
|
|
1028
|
+
addFileToCommand: addFileToCommand(join13(path5)),
|
|
990
1029
|
/**
|
|
991
1030
|
* Adds a schema to the given command
|
|
992
1031
|
* @param id - The id of the command to add the schema to
|
|
@@ -994,14 +1033,14 @@ var index_default = (path4) => {
|
|
|
994
1033
|
* @param version - Optional version of the command to add the schema to
|
|
995
1034
|
* @returns
|
|
996
1035
|
*/
|
|
997
|
-
addSchemaToCommand: addSchemaToCommand(join13(
|
|
1036
|
+
addSchemaToCommand: addSchemaToCommand(join13(path5)),
|
|
998
1037
|
/**
|
|
999
1038
|
* Check to see if a command version exists
|
|
1000
1039
|
* @param id - The id of the command
|
|
1001
1040
|
* @param version - The version of the command (supports semver)
|
|
1002
1041
|
* @returns
|
|
1003
1042
|
*/
|
|
1004
|
-
commandHasVersion: commandHasVersion(join13(
|
|
1043
|
+
commandHasVersion: commandHasVersion(join13(path5)),
|
|
1005
1044
|
/**
|
|
1006
1045
|
* ================================
|
|
1007
1046
|
* Queries
|
|
@@ -1013,13 +1052,13 @@ var index_default = (path4) => {
|
|
|
1013
1052
|
* @param version - Optional id of the version to get (supports semver)
|
|
1014
1053
|
* @returns Query|Undefined
|
|
1015
1054
|
*/
|
|
1016
|
-
getQuery: getQuery(join13(
|
|
1055
|
+
getQuery: getQuery(join13(path5)),
|
|
1017
1056
|
/**
|
|
1018
1057
|
* Returns all queries from EventCatalog
|
|
1019
1058
|
* @param latestOnly - optional boolean, set to true to get only latest versions
|
|
1020
1059
|
* @returns Query[]|Undefined
|
|
1021
1060
|
*/
|
|
1022
|
-
getQueries: getQueries(join13(
|
|
1061
|
+
getQueries: getQueries(join13(path5)),
|
|
1023
1062
|
/**
|
|
1024
1063
|
* Adds a query to EventCatalog
|
|
1025
1064
|
*
|
|
@@ -1027,7 +1066,7 @@ var index_default = (path4) => {
|
|
|
1027
1066
|
* @param options - Optional options to write the event
|
|
1028
1067
|
*
|
|
1029
1068
|
*/
|
|
1030
|
-
writeQuery: writeQuery(join13(
|
|
1069
|
+
writeQuery: writeQuery(join13(path5, "queries")),
|
|
1031
1070
|
/**
|
|
1032
1071
|
* Adds a query to a service in EventCatalog
|
|
1033
1072
|
*
|
|
@@ -1036,26 +1075,26 @@ var index_default = (path4) => {
|
|
|
1036
1075
|
* @param options - Optional options to write the query
|
|
1037
1076
|
*
|
|
1038
1077
|
*/
|
|
1039
|
-
writeQueryToService: writeQueryToService(join13(
|
|
1078
|
+
writeQueryToService: writeQueryToService(join13(path5)),
|
|
1040
1079
|
/**
|
|
1041
1080
|
* Remove an query to EventCatalog (modeled on the standard POSIX rm utility)
|
|
1042
1081
|
*
|
|
1043
1082
|
* @param path - The path to your query, e.g. `/Orders/GetOrder`
|
|
1044
1083
|
*
|
|
1045
1084
|
*/
|
|
1046
|
-
rmQuery: rmQuery(join13(
|
|
1085
|
+
rmQuery: rmQuery(join13(path5, "queries")),
|
|
1047
1086
|
/**
|
|
1048
1087
|
* Remove a query by a Query id
|
|
1049
1088
|
*
|
|
1050
1089
|
* @param id - The id of the query you want to remove
|
|
1051
1090
|
*
|
|
1052
1091
|
*/
|
|
1053
|
-
rmQueryById: rmQueryById(join13(
|
|
1092
|
+
rmQueryById: rmQueryById(join13(path5)),
|
|
1054
1093
|
/**
|
|
1055
1094
|
* Moves a given query id to the version directory
|
|
1056
1095
|
* @param directory
|
|
1057
1096
|
*/
|
|
1058
|
-
versionQuery: versionQuery(join13(
|
|
1097
|
+
versionQuery: versionQuery(join13(path5)),
|
|
1059
1098
|
/**
|
|
1060
1099
|
* Adds a file to the given query
|
|
1061
1100
|
* @param id - The id of the query to add the file to
|
|
@@ -1063,7 +1102,7 @@ var index_default = (path4) => {
|
|
|
1063
1102
|
* @param version - Optional version of the query to add the file to
|
|
1064
1103
|
* @returns
|
|
1065
1104
|
*/
|
|
1066
|
-
addFileToQuery: addFileToQuery(join13(
|
|
1105
|
+
addFileToQuery: addFileToQuery(join13(path5)),
|
|
1067
1106
|
/**
|
|
1068
1107
|
* Adds a schema to the given query
|
|
1069
1108
|
* @param id - The id of the query to add the schema to
|
|
@@ -1071,14 +1110,14 @@ var index_default = (path4) => {
|
|
|
1071
1110
|
* @param version - Optional version of the query to add the schema to
|
|
1072
1111
|
* @returns
|
|
1073
1112
|
*/
|
|
1074
|
-
addSchemaToQuery: addSchemaToQuery(join13(
|
|
1113
|
+
addSchemaToQuery: addSchemaToQuery(join13(path5)),
|
|
1075
1114
|
/**
|
|
1076
1115
|
* Check to see if an query version exists
|
|
1077
1116
|
* @param id - The id of the query
|
|
1078
1117
|
* @param version - The version of the query (supports semver)
|
|
1079
1118
|
* @returns
|
|
1080
1119
|
*/
|
|
1081
|
-
queryHasVersion: queryHasVersion(join13(
|
|
1120
|
+
queryHasVersion: queryHasVersion(join13(path5)),
|
|
1082
1121
|
/**
|
|
1083
1122
|
* ================================
|
|
1084
1123
|
* Channels
|
|
@@ -1090,13 +1129,13 @@ var index_default = (path4) => {
|
|
|
1090
1129
|
* @param version - Optional id of the version to get (supports semver)
|
|
1091
1130
|
* @returns Channel|Undefined
|
|
1092
1131
|
*/
|
|
1093
|
-
getChannel: getChannel(join13(
|
|
1132
|
+
getChannel: getChannel(join13(path5)),
|
|
1094
1133
|
/**
|
|
1095
1134
|
* Returns all channels from EventCatalog
|
|
1096
1135
|
* @param latestOnly - optional boolean, set to true to get only latest versions
|
|
1097
1136
|
* @returns Channel[]|Undefined
|
|
1098
1137
|
*/
|
|
1099
|
-
getChannels: getChannels(join13(
|
|
1138
|
+
getChannels: getChannels(join13(path5)),
|
|
1100
1139
|
/**
|
|
1101
1140
|
* Adds an channel to EventCatalog
|
|
1102
1141
|
*
|
|
@@ -1104,33 +1143,33 @@ var index_default = (path4) => {
|
|
|
1104
1143
|
* @param options - Optional options to write the channel
|
|
1105
1144
|
*
|
|
1106
1145
|
*/
|
|
1107
|
-
writeChannel: writeChannel(join13(
|
|
1146
|
+
writeChannel: writeChannel(join13(path5, "channels")),
|
|
1108
1147
|
/**
|
|
1109
1148
|
* Remove an channel to EventCatalog (modeled on the standard POSIX rm utility)
|
|
1110
1149
|
*
|
|
1111
1150
|
* @param path - The path to your channel, e.g. `/Inventory/InventoryAdjusted`
|
|
1112
1151
|
*
|
|
1113
1152
|
*/
|
|
1114
|
-
rmChannel: rmChannel(join13(
|
|
1153
|
+
rmChannel: rmChannel(join13(path5, "channels")),
|
|
1115
1154
|
/**
|
|
1116
1155
|
* Remove an channel by an Event id
|
|
1117
1156
|
*
|
|
1118
1157
|
* @param id - The id of the channel you want to remove
|
|
1119
1158
|
*
|
|
1120
1159
|
*/
|
|
1121
|
-
rmChannelById: rmChannelById(join13(
|
|
1160
|
+
rmChannelById: rmChannelById(join13(path5)),
|
|
1122
1161
|
/**
|
|
1123
1162
|
* Moves a given channel id to the version directory
|
|
1124
1163
|
* @param directory
|
|
1125
1164
|
*/
|
|
1126
|
-
versionChannel: versionChannel(join13(
|
|
1165
|
+
versionChannel: versionChannel(join13(path5)),
|
|
1127
1166
|
/**
|
|
1128
1167
|
* Check to see if a channel version exists
|
|
1129
1168
|
* @param id - The id of the channel
|
|
1130
1169
|
* @param version - The version of the channel (supports semver)
|
|
1131
1170
|
* @returns
|
|
1132
1171
|
*/
|
|
1133
|
-
channelHasVersion: channelHasVersion(join13(
|
|
1172
|
+
channelHasVersion: channelHasVersion(join13(path5)),
|
|
1134
1173
|
/**
|
|
1135
1174
|
* Add a channel to an event
|
|
1136
1175
|
*
|
|
@@ -1147,7 +1186,7 @@ var index_default = (path4) => {
|
|
|
1147
1186
|
*
|
|
1148
1187
|
* ```
|
|
1149
1188
|
*/
|
|
1150
|
-
addEventToChannel: addMessageToChannel(join13(
|
|
1189
|
+
addEventToChannel: addMessageToChannel(join13(path5), "events"),
|
|
1151
1190
|
/**
|
|
1152
1191
|
* Add a channel to an command
|
|
1153
1192
|
*
|
|
@@ -1164,7 +1203,7 @@ var index_default = (path4) => {
|
|
|
1164
1203
|
*
|
|
1165
1204
|
* ```
|
|
1166
1205
|
*/
|
|
1167
|
-
addCommandToChannel: addMessageToChannel(join13(
|
|
1206
|
+
addCommandToChannel: addMessageToChannel(join13(path5), "commands"),
|
|
1168
1207
|
/**
|
|
1169
1208
|
* Add a channel to an query
|
|
1170
1209
|
*
|
|
@@ -1181,7 +1220,7 @@ var index_default = (path4) => {
|
|
|
1181
1220
|
*
|
|
1182
1221
|
* ```
|
|
1183
1222
|
*/
|
|
1184
|
-
addQueryToChannel: addMessageToChannel(join13(
|
|
1223
|
+
addQueryToChannel: addMessageToChannel(join13(path5), "queries"),
|
|
1185
1224
|
/**
|
|
1186
1225
|
* ================================
|
|
1187
1226
|
* SERVICES
|
|
@@ -1194,14 +1233,14 @@ var index_default = (path4) => {
|
|
|
1194
1233
|
* @param options - Optional options to write the event
|
|
1195
1234
|
*
|
|
1196
1235
|
*/
|
|
1197
|
-
writeService: writeService(join13(
|
|
1236
|
+
writeService: writeService(join13(path5, "services")),
|
|
1198
1237
|
/**
|
|
1199
1238
|
* Adds a versioned service to EventCatalog
|
|
1200
1239
|
*
|
|
1201
1240
|
* @param service - The service to write
|
|
1202
1241
|
*
|
|
1203
1242
|
*/
|
|
1204
|
-
writeVersionedService: writeVersionedService(join13(
|
|
1243
|
+
writeVersionedService: writeVersionedService(join13(path5, "services")),
|
|
1205
1244
|
/**
|
|
1206
1245
|
* Adds a service to a domain in EventCatalog
|
|
1207
1246
|
*
|
|
@@ -1210,39 +1249,45 @@ var index_default = (path4) => {
|
|
|
1210
1249
|
* @param options - Optional options to write the event
|
|
1211
1250
|
*
|
|
1212
1251
|
*/
|
|
1213
|
-
writeServiceToDomain: writeServiceToDomain(join13(
|
|
1252
|
+
writeServiceToDomain: writeServiceToDomain(join13(path5, "domains")),
|
|
1214
1253
|
/**
|
|
1215
1254
|
* Returns a service from EventCatalog
|
|
1216
1255
|
* @param id - The id of the service to retrieve
|
|
1217
1256
|
* @param version - Optional id of the version to get (supports semver)
|
|
1218
1257
|
* @returns Service|Undefined
|
|
1219
1258
|
*/
|
|
1220
|
-
getService: getService(join13(
|
|
1259
|
+
getService: getService(join13(path5)),
|
|
1260
|
+
/**
|
|
1261
|
+
* Returns a service from EventCatalog by it's path.
|
|
1262
|
+
* @param path - The path to the service to retrieve
|
|
1263
|
+
* @returns Service|Undefined
|
|
1264
|
+
*/
|
|
1265
|
+
getServiceByPath: getServiceByPath(join13(path5)),
|
|
1221
1266
|
/**
|
|
1222
1267
|
* Returns all services from EventCatalog
|
|
1223
1268
|
* @param latestOnly - optional boolean, set to true to get only latest versions
|
|
1224
1269
|
* @returns Service[]|Undefined
|
|
1225
1270
|
*/
|
|
1226
|
-
getServices: getServices(join13(
|
|
1271
|
+
getServices: getServices(join13(path5)),
|
|
1227
1272
|
/**
|
|
1228
1273
|
* Moves a given service id to the version directory
|
|
1229
1274
|
* @param directory
|
|
1230
1275
|
*/
|
|
1231
|
-
versionService: versionService(join13(
|
|
1276
|
+
versionService: versionService(join13(path5)),
|
|
1232
1277
|
/**
|
|
1233
1278
|
* Remove a service from EventCatalog (modeled on the standard POSIX rm utility)
|
|
1234
1279
|
*
|
|
1235
1280
|
* @param path - The path to your service, e.g. `/InventoryService`
|
|
1236
1281
|
*
|
|
1237
1282
|
*/
|
|
1238
|
-
rmService: rmService(join13(
|
|
1283
|
+
rmService: rmService(join13(path5, "services")),
|
|
1239
1284
|
/**
|
|
1240
1285
|
* Remove an service by an service id
|
|
1241
1286
|
*
|
|
1242
1287
|
* @param id - The id of the service you want to remove
|
|
1243
1288
|
*
|
|
1244
1289
|
*/
|
|
1245
|
-
rmServiceById: rmServiceById(join13(
|
|
1290
|
+
rmServiceById: rmServiceById(join13(path5)),
|
|
1246
1291
|
/**
|
|
1247
1292
|
* Adds a file to the given service
|
|
1248
1293
|
* @param id - The id of the service to add the file to
|
|
@@ -1250,21 +1295,21 @@ var index_default = (path4) => {
|
|
|
1250
1295
|
* @param version - Optional version of the service to add the file to
|
|
1251
1296
|
* @returns
|
|
1252
1297
|
*/
|
|
1253
|
-
addFileToService: addFileToService(join13(
|
|
1298
|
+
addFileToService: addFileToService(join13(path5)),
|
|
1254
1299
|
/**
|
|
1255
1300
|
* Returns the specifications for a given service
|
|
1256
1301
|
* @param id - The id of the service to retrieve the specifications for
|
|
1257
1302
|
* @param version - Optional version of the service
|
|
1258
1303
|
* @returns
|
|
1259
1304
|
*/
|
|
1260
|
-
getSpecificationFilesForService: getSpecificationFilesForService(join13(
|
|
1305
|
+
getSpecificationFilesForService: getSpecificationFilesForService(join13(path5)),
|
|
1261
1306
|
/**
|
|
1262
1307
|
* Check to see if a service version exists
|
|
1263
1308
|
* @param id - The id of the service
|
|
1264
1309
|
* @param version - The version of the service (supports semver)
|
|
1265
1310
|
* @returns
|
|
1266
1311
|
*/
|
|
1267
|
-
serviceHasVersion: serviceHasVersion(join13(
|
|
1312
|
+
serviceHasVersion: serviceHasVersion(join13(path5)),
|
|
1268
1313
|
/**
|
|
1269
1314
|
* Add an event to a service by it's id.
|
|
1270
1315
|
*
|
|
@@ -1284,7 +1329,7 @@ var index_default = (path4) => {
|
|
|
1284
1329
|
*
|
|
1285
1330
|
* ```
|
|
1286
1331
|
*/
|
|
1287
|
-
addEventToService: addMessageToService(join13(
|
|
1332
|
+
addEventToService: addMessageToService(join13(path5)),
|
|
1288
1333
|
/**
|
|
1289
1334
|
* Add a command to a service by it's id.
|
|
1290
1335
|
*
|
|
@@ -1304,7 +1349,7 @@ var index_default = (path4) => {
|
|
|
1304
1349
|
*
|
|
1305
1350
|
* ```
|
|
1306
1351
|
*/
|
|
1307
|
-
addCommandToService: addMessageToService(join13(
|
|
1352
|
+
addCommandToService: addMessageToService(join13(path5)),
|
|
1308
1353
|
/**
|
|
1309
1354
|
* Add a query to a service by it's id.
|
|
1310
1355
|
*
|
|
@@ -1324,7 +1369,30 @@ var index_default = (path4) => {
|
|
|
1324
1369
|
*
|
|
1325
1370
|
* ```
|
|
1326
1371
|
*/
|
|
1327
|
-
addQueryToService: addMessageToService(join13(
|
|
1372
|
+
addQueryToService: addMessageToService(join13(path5)),
|
|
1373
|
+
/**
|
|
1374
|
+
* Check to see if a service exists by it's path.
|
|
1375
|
+
*
|
|
1376
|
+
* @example
|
|
1377
|
+
* ```ts
|
|
1378
|
+
* import utils from '@eventcatalog/utils';
|
|
1379
|
+
*
|
|
1380
|
+
* const { isService } = utils('/path/to/eventcatalog');
|
|
1381
|
+
*
|
|
1382
|
+
* // returns true if the path is a service
|
|
1383
|
+
* await isService('/services/InventoryService/index.mdx');
|
|
1384
|
+
* ```
|
|
1385
|
+
*
|
|
1386
|
+
* @param path - The path to the service to check
|
|
1387
|
+
* @returns boolean
|
|
1388
|
+
*/
|
|
1389
|
+
isService: isService(join13(path5)),
|
|
1390
|
+
/**
|
|
1391
|
+
* Converts a file to a service.
|
|
1392
|
+
* @param file - The file to convert to a service.
|
|
1393
|
+
* @returns The service.
|
|
1394
|
+
*/
|
|
1395
|
+
toService: toService(join13(path5)),
|
|
1328
1396
|
/**
|
|
1329
1397
|
* ================================
|
|
1330
1398
|
* Domains
|
|
@@ -1337,39 +1405,39 @@ var index_default = (path4) => {
|
|
|
1337
1405
|
* @param options - Optional options to write the event
|
|
1338
1406
|
*
|
|
1339
1407
|
*/
|
|
1340
|
-
writeDomain: writeDomain(join13(
|
|
1408
|
+
writeDomain: writeDomain(join13(path5, "domains")),
|
|
1341
1409
|
/**
|
|
1342
1410
|
* Returns a domain from EventCatalog
|
|
1343
1411
|
* @param id - The id of the domain to retrieve
|
|
1344
1412
|
* @param version - Optional id of the version to get (supports semver)
|
|
1345
1413
|
* @returns Domain|Undefined
|
|
1346
1414
|
*/
|
|
1347
|
-
getDomain: getDomain(join13(
|
|
1415
|
+
getDomain: getDomain(join13(path5, "domains")),
|
|
1348
1416
|
/**
|
|
1349
1417
|
* Returns all domains from EventCatalog
|
|
1350
1418
|
* @param latestOnly - optional boolean, set to true to get only latest versions
|
|
1351
1419
|
* @returns Domain[]|Undefined
|
|
1352
1420
|
*/
|
|
1353
|
-
getDomains: getDomains(join13(
|
|
1421
|
+
getDomains: getDomains(join13(path5)),
|
|
1354
1422
|
/**
|
|
1355
1423
|
* Moves a given domain id to the version directory
|
|
1356
1424
|
* @param directory
|
|
1357
1425
|
*/
|
|
1358
|
-
versionDomain: versionDomain(join13(
|
|
1426
|
+
versionDomain: versionDomain(join13(path5, "domains")),
|
|
1359
1427
|
/**
|
|
1360
1428
|
* Remove a domain from EventCatalog (modeled on the standard POSIX rm utility)
|
|
1361
1429
|
*
|
|
1362
1430
|
* @param path - The path to your domain, e.g. `/Payment`
|
|
1363
1431
|
*
|
|
1364
1432
|
*/
|
|
1365
|
-
rmDomain: rmDomain(join13(
|
|
1433
|
+
rmDomain: rmDomain(join13(path5, "domains")),
|
|
1366
1434
|
/**
|
|
1367
1435
|
* Remove an service by an domain id
|
|
1368
1436
|
*
|
|
1369
1437
|
* @param id - The id of the domain you want to remove
|
|
1370
1438
|
*
|
|
1371
1439
|
*/
|
|
1372
|
-
rmDomainById: rmDomainById(join13(
|
|
1440
|
+
rmDomainById: rmDomainById(join13(path5, "domains")),
|
|
1373
1441
|
/**
|
|
1374
1442
|
* Adds a file to the given domain
|
|
1375
1443
|
* @param id - The id of the domain to add the file to
|
|
@@ -1377,28 +1445,28 @@ var index_default = (path4) => {
|
|
|
1377
1445
|
* @param version - Optional version of the domain to add the file to
|
|
1378
1446
|
* @returns
|
|
1379
1447
|
*/
|
|
1380
|
-
addFileToDomain: addFileToDomain(join13(
|
|
1448
|
+
addFileToDomain: addFileToDomain(join13(path5, "domains")),
|
|
1381
1449
|
/**
|
|
1382
1450
|
* Adds an ubiquitous language dictionary to a domain
|
|
1383
1451
|
* @param id - The id of the domain to add the ubiquitous language to
|
|
1384
1452
|
* @param ubiquitousLanguageDictionary - The ubiquitous language dictionary to add
|
|
1385
1453
|
* @param version - Optional version of the domain to add the ubiquitous language to
|
|
1386
1454
|
*/
|
|
1387
|
-
addUbiquitousLanguageToDomain: addUbiquitousLanguageToDomain(join13(
|
|
1455
|
+
addUbiquitousLanguageToDomain: addUbiquitousLanguageToDomain(join13(path5, "domains")),
|
|
1388
1456
|
/**
|
|
1389
1457
|
* Get the ubiquitous language dictionary from a domain
|
|
1390
1458
|
* @param id - The id of the domain to get the ubiquitous language from
|
|
1391
1459
|
* @param version - Optional version of the domain to get the ubiquitous language from
|
|
1392
1460
|
* @returns
|
|
1393
1461
|
*/
|
|
1394
|
-
getUbiquitousLanguageFromDomain: getUbiquitousLanguageFromDomain(join13(
|
|
1462
|
+
getUbiquitousLanguageFromDomain: getUbiquitousLanguageFromDomain(join13(path5, "domains")),
|
|
1395
1463
|
/**
|
|
1396
1464
|
* Check to see if a domain version exists
|
|
1397
1465
|
* @param id - The id of the domain
|
|
1398
1466
|
* @param version - The version of the domain (supports semver)
|
|
1399
1467
|
* @returns
|
|
1400
1468
|
*/
|
|
1401
|
-
domainHasVersion: domainHasVersion(join13(
|
|
1469
|
+
domainHasVersion: domainHasVersion(join13(path5)),
|
|
1402
1470
|
/**
|
|
1403
1471
|
* Adds a given service to a domain
|
|
1404
1472
|
* @param id - The id of the domain
|
|
@@ -1406,7 +1474,7 @@ var index_default = (path4) => {
|
|
|
1406
1474
|
* @param version - (Optional) The version of the domain to add the service to
|
|
1407
1475
|
* @returns
|
|
1408
1476
|
*/
|
|
1409
|
-
addServiceToDomain: addServiceToDomain(join13(
|
|
1477
|
+
addServiceToDomain: addServiceToDomain(join13(path5, "domains")),
|
|
1410
1478
|
/**
|
|
1411
1479
|
* Adds a given subdomain to a domain
|
|
1412
1480
|
* @param id - The id of the domain
|
|
@@ -1414,7 +1482,7 @@ var index_default = (path4) => {
|
|
|
1414
1482
|
* @param version - (Optional) The version of the domain to add the subdomain to
|
|
1415
1483
|
* @returns
|
|
1416
1484
|
*/
|
|
1417
|
-
addSubDomainToDomain: addSubDomainToDomain(join13(
|
|
1485
|
+
addSubDomainToDomain: addSubDomainToDomain(join13(path5, "domains")),
|
|
1418
1486
|
/**
|
|
1419
1487
|
* ================================
|
|
1420
1488
|
* Teams
|
|
@@ -1427,25 +1495,25 @@ var index_default = (path4) => {
|
|
|
1427
1495
|
* @param options - Optional options to write the team
|
|
1428
1496
|
*
|
|
1429
1497
|
*/
|
|
1430
|
-
writeTeam: writeTeam(join13(
|
|
1498
|
+
writeTeam: writeTeam(join13(path5, "teams")),
|
|
1431
1499
|
/**
|
|
1432
1500
|
* Returns a team from EventCatalog
|
|
1433
1501
|
* @param id - The id of the team to retrieve
|
|
1434
1502
|
* @returns Team|Undefined
|
|
1435
1503
|
*/
|
|
1436
|
-
getTeam: getTeam(join13(
|
|
1504
|
+
getTeam: getTeam(join13(path5, "teams")),
|
|
1437
1505
|
/**
|
|
1438
1506
|
* Returns all teams from EventCatalog
|
|
1439
1507
|
* @returns Team[]|Undefined
|
|
1440
1508
|
*/
|
|
1441
|
-
getTeams: getTeams(join13(
|
|
1509
|
+
getTeams: getTeams(join13(path5, "teams")),
|
|
1442
1510
|
/**
|
|
1443
1511
|
* Remove a team by the team id
|
|
1444
1512
|
*
|
|
1445
1513
|
* @param id - The id of the team you want to remove
|
|
1446
1514
|
*
|
|
1447
1515
|
*/
|
|
1448
|
-
rmTeamById: rmTeamById(join13(
|
|
1516
|
+
rmTeamById: rmTeamById(join13(path5, "teams")),
|
|
1449
1517
|
/**
|
|
1450
1518
|
* ================================
|
|
1451
1519
|
* Users
|
|
@@ -1458,25 +1526,25 @@ var index_default = (path4) => {
|
|
|
1458
1526
|
* @param options - Optional options to write the user
|
|
1459
1527
|
*
|
|
1460
1528
|
*/
|
|
1461
|
-
writeUser: writeUser(join13(
|
|
1529
|
+
writeUser: writeUser(join13(path5, "users")),
|
|
1462
1530
|
/**
|
|
1463
1531
|
* Returns a user from EventCatalog
|
|
1464
1532
|
* @param id - The id of the user to retrieve
|
|
1465
1533
|
* @returns User|Undefined
|
|
1466
1534
|
*/
|
|
1467
|
-
getUser: getUser(join13(
|
|
1535
|
+
getUser: getUser(join13(path5, "users")),
|
|
1468
1536
|
/**
|
|
1469
1537
|
* Returns all user from EventCatalog
|
|
1470
1538
|
* @returns User[]|Undefined
|
|
1471
1539
|
*/
|
|
1472
|
-
getUsers: getUsers(join13(
|
|
1540
|
+
getUsers: getUsers(join13(path5)),
|
|
1473
1541
|
/**
|
|
1474
1542
|
* Remove a user by the user id
|
|
1475
1543
|
*
|
|
1476
1544
|
* @param id - The id of the user you want to remove
|
|
1477
1545
|
*
|
|
1478
1546
|
*/
|
|
1479
|
-
rmUserById: rmUserById(join13(
|
|
1547
|
+
rmUserById: rmUserById(join13(path5, "users")),
|
|
1480
1548
|
/**
|
|
1481
1549
|
* ================================
|
|
1482
1550
|
* Custom Docs
|
|
@@ -1487,32 +1555,32 @@ var index_default = (path4) => {
|
|
|
1487
1555
|
* @param path - The path to the custom doc to retrieve
|
|
1488
1556
|
* @returns CustomDoc|Undefined
|
|
1489
1557
|
*/
|
|
1490
|
-
getCustomDoc: getCustomDoc(join13(
|
|
1558
|
+
getCustomDoc: getCustomDoc(join13(path5, "docs")),
|
|
1491
1559
|
/**
|
|
1492
1560
|
* Returns all custom docs from EventCatalog
|
|
1493
1561
|
* @param options - Optional options to get custom docs from a specific path
|
|
1494
1562
|
* @returns CustomDoc[]|Undefined
|
|
1495
1563
|
*/
|
|
1496
|
-
getCustomDocs: getCustomDocs(join13(
|
|
1564
|
+
getCustomDocs: getCustomDocs(join13(path5, "docs")),
|
|
1497
1565
|
/**
|
|
1498
1566
|
* Writes a custom doc to EventCatalog
|
|
1499
1567
|
* @param customDoc - The custom doc to write
|
|
1500
1568
|
* @param options - Optional options to write the custom doc
|
|
1501
1569
|
*
|
|
1502
1570
|
*/
|
|
1503
|
-
writeCustomDoc: writeCustomDoc(join13(
|
|
1571
|
+
writeCustomDoc: writeCustomDoc(join13(path5, "docs")),
|
|
1504
1572
|
/**
|
|
1505
1573
|
* Removes a custom doc from EventCatalog
|
|
1506
1574
|
* @param path - The path to the custom doc to remove
|
|
1507
1575
|
*
|
|
1508
1576
|
*/
|
|
1509
|
-
rmCustomDoc: rmCustomDoc(join13(
|
|
1577
|
+
rmCustomDoc: rmCustomDoc(join13(path5, "docs")),
|
|
1510
1578
|
/**
|
|
1511
1579
|
* Dumps the catalog to a JSON file.
|
|
1512
1580
|
* @param directory - The directory to dump the catalog to
|
|
1513
1581
|
* @returns A JSON file with the catalog
|
|
1514
1582
|
*/
|
|
1515
|
-
dumpCatalog: dumpCatalog(join13(
|
|
1583
|
+
dumpCatalog: dumpCatalog(join13(path5)),
|
|
1516
1584
|
/**
|
|
1517
1585
|
* Returns the event catalog configuration file.
|
|
1518
1586
|
* The event catalog configuration file is the file that contains the configuration for the event catalog.
|
|
@@ -1520,7 +1588,7 @@ var index_default = (path4) => {
|
|
|
1520
1588
|
* @param directory - The directory of the catalog.
|
|
1521
1589
|
* @returns A JSON object with the configuration for the event catalog.
|
|
1522
1590
|
*/
|
|
1523
|
-
getEventCatalogConfigurationFile: getEventCatalogConfigurationFile(join13(
|
|
1591
|
+
getEventCatalogConfigurationFile: getEventCatalogConfigurationFile(join13(path5)),
|
|
1524
1592
|
/**
|
|
1525
1593
|
* ================================
|
|
1526
1594
|
* Resources Utils
|
|
@@ -1541,14 +1609,21 @@ var index_default = (path4) => {
|
|
|
1541
1609
|
* @param path - The path to the message to retrieve
|
|
1542
1610
|
* @returns Message|Undefined
|
|
1543
1611
|
*/
|
|
1544
|
-
getMessageBySchemaPath: getMessageBySchemaPath(join13(
|
|
1612
|
+
getMessageBySchemaPath: getMessageBySchemaPath(join13(path5)),
|
|
1545
1613
|
/**
|
|
1546
1614
|
* Returns the producers and consumers (services) for a given message
|
|
1547
1615
|
* @param id - The id of the message to get the producers and consumers for
|
|
1548
1616
|
* @param version - Optional version of the message
|
|
1549
1617
|
* @returns { producers: Service[], consumers: Service[] }
|
|
1550
1618
|
*/
|
|
1551
|
-
getProducersAndConsumersForMessage: getProducersAndConsumersForMessage(join13(
|
|
1619
|
+
getProducersAndConsumersForMessage: getProducersAndConsumersForMessage(join13(path5)),
|
|
1620
|
+
/**
|
|
1621
|
+
* Returns the owners for a given resource (e.g domain, service, event, command, query, etc.)
|
|
1622
|
+
* @param id - The id of the resource to get the owners for
|
|
1623
|
+
* @param version - Optional version of the resource
|
|
1624
|
+
* @returns { owners: User[] }
|
|
1625
|
+
*/
|
|
1626
|
+
getOwnersForResource: getOwnersForResource(join13(path5))
|
|
1552
1627
|
};
|
|
1553
1628
|
};
|
|
1554
1629
|
|
|
@@ -1569,7 +1644,7 @@ var hydrateResource = async (catalogDir, resources = [], { attachSchema = false
|
|
|
1569
1644
|
const resourcePath = await getResourcePath(catalogDir, resource.id, resource.version);
|
|
1570
1645
|
let schema = "";
|
|
1571
1646
|
if (resource.schemaPath && resourcePath?.fullPath) {
|
|
1572
|
-
const pathToSchema =
|
|
1647
|
+
const pathToSchema = path4.join(path4.dirname(resourcePath?.fullPath), resource.schemaPath);
|
|
1573
1648
|
if (fs10.existsSync(pathToSchema)) {
|
|
1574
1649
|
schema = fs10.readFileSync(pathToSchema, "utf8");
|
|
1575
1650
|
}
|
|
@@ -1590,8 +1665,8 @@ var filterCollection = (collection, options) => {
|
|
|
1590
1665
|
};
|
|
1591
1666
|
var getEventCatalogConfigurationFile = (directory) => async () => {
|
|
1592
1667
|
try {
|
|
1593
|
-
const
|
|
1594
|
-
const configModule = await import(
|
|
1668
|
+
const path5 = join14(directory, "eventcatalog.config.js");
|
|
1669
|
+
const configModule = await import(path5);
|
|
1595
1670
|
return configModule.default;
|
|
1596
1671
|
} catch (error) {
|
|
1597
1672
|
console.error("Error getting event catalog configuration file", error);
|
|
@@ -1599,7 +1674,7 @@ var getEventCatalogConfigurationFile = (directory) => async () => {
|
|
|
1599
1674
|
}
|
|
1600
1675
|
};
|
|
1601
1676
|
var dumpCatalog = (directory) => async (options) => {
|
|
1602
|
-
const { getDomains: getDomains2, getServices: getServices2, getEvents: getEvents2, getQueries: getQueries2, getCommands: getCommands2, getChannels: getChannels2, getTeams: getTeams2, getUsers:
|
|
1677
|
+
const { getDomains: getDomains2, getServices: getServices2, getEvents: getEvents2, getQueries: getQueries2, getCommands: getCommands2, getChannels: getChannels2, getTeams: getTeams2, getUsers: getUsers3 } = index_default(directory);
|
|
1603
1678
|
const { includeMarkdown = true } = options || {};
|
|
1604
1679
|
const domains = await getDomains2();
|
|
1605
1680
|
const services = await getServices2();
|
|
@@ -1607,7 +1682,7 @@ var dumpCatalog = (directory) => async (options) => {
|
|
|
1607
1682
|
const commands = await getCommands2();
|
|
1608
1683
|
const queries = await getQueries2();
|
|
1609
1684
|
const teams = await getTeams2();
|
|
1610
|
-
const users = await
|
|
1685
|
+
const users = await getUsers3();
|
|
1611
1686
|
const channels = await getChannels2();
|
|
1612
1687
|
const [
|
|
1613
1688
|
hydratedDomains,
|