@eventcatalog/sdk 2.8.2 → 2.8.3
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/eventcatalog.js +53 -0
- package/dist/eventcatalog.js.map +1 -1
- package/dist/eventcatalog.mjs +53 -0
- package/dist/eventcatalog.mjs.map +1 -1
- package/dist/index.d.mts +30 -13
- package/dist/index.d.ts +30 -13
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -0
- package/dist/index.mjs.map +1 -1
- package/dist/messages.js.map +1 -1
- package/dist/messages.mjs.map +1 -1
- package/dist/services.d.mts +25 -1
- package/dist/services.d.ts +25 -1
- package/dist/services.js +38 -0
- package/dist/services.js.map +1 -1
- package/dist/services.mjs +37 -0
- package/dist/services.mjs.map +1 -1
- package/dist/types.d.d.mts +2 -0
- package/dist/types.d.d.ts +2 -0
- package/dist/types.d.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -135,12 +135,7 @@ declare const _default: (path: string) => {
|
|
|
135
135
|
*/
|
|
136
136
|
writeCommand: (command: Command, options?: {
|
|
137
137
|
path?: string;
|
|
138
|
-
override
|
|
139
|
-
* Remove an event by an Event id
|
|
140
|
-
*
|
|
141
|
-
* @param id - The id of the event you want to remove
|
|
142
|
-
*
|
|
143
|
-
*/: boolean;
|
|
138
|
+
override?: boolean;
|
|
144
139
|
versionExistingContent?: boolean;
|
|
145
140
|
format?: "md" | "mdx";
|
|
146
141
|
}) => Promise<void>;
|
|
@@ -566,6 +561,26 @@ declare const _default: (path: string) => {
|
|
|
566
561
|
id: string;
|
|
567
562
|
version: string;
|
|
568
563
|
}, version?: string) => Promise<void>;
|
|
564
|
+
/**
|
|
565
|
+
* Add a data store to a service by it's id.
|
|
566
|
+
*
|
|
567
|
+
* Optionally specify a version to add the data store to a specific version of the service.
|
|
568
|
+
*
|
|
569
|
+
* @example
|
|
570
|
+
* ```ts
|
|
571
|
+
* import utils from '@eventcatalog/utils';
|
|
572
|
+
*
|
|
573
|
+
* const { addDataStoreToService } = utils('/path/to/eventcatalog');
|
|
574
|
+
*
|
|
575
|
+
* // adds a new data store (orders-db) that the InventoryService will write to
|
|
576
|
+
* await addDataStoreToService('InventoryService', 'writesTo', { id: 'orders-db', version: '2.0.0' });
|
|
577
|
+
*
|
|
578
|
+
* ```
|
|
579
|
+
*/
|
|
580
|
+
addDataStoreToService: (id: string, operation: "writesTo" | "readsFrom", dataStore: {
|
|
581
|
+
id: string;
|
|
582
|
+
version: string;
|
|
583
|
+
}, version?: string) => Promise<void>;
|
|
569
584
|
/**
|
|
570
585
|
* Add a command to a service by it's id.
|
|
571
586
|
*
|
|
@@ -669,12 +684,7 @@ declare const _default: (path: string) => {
|
|
|
669
684
|
*
|
|
670
685
|
*/
|
|
671
686
|
writeDomain: (domain: Domain, options?: {
|
|
672
|
-
path
|
|
673
|
-
* Remove an event to EventCatalog (modeled on the standard POSIX rm utility)
|
|
674
|
-
*
|
|
675
|
-
* @param path - The path to your event, e.g. `/Inventory/InventoryAdjusted`
|
|
676
|
-
*
|
|
677
|
-
*/: string;
|
|
687
|
+
path?: string;
|
|
678
688
|
override?: boolean;
|
|
679
689
|
versionExistingContent?: boolean;
|
|
680
690
|
format?: "md" | "mdx";
|
|
@@ -985,7 +995,14 @@ declare const _default: (path: string) => {
|
|
|
985
995
|
path?: string;
|
|
986
996
|
override?: boolean;
|
|
987
997
|
versionExistingContent?: boolean;
|
|
988
|
-
format
|
|
998
|
+
format? /**
|
|
999
|
+
* Adds an event to a service in EventCatalog
|
|
1000
|
+
*
|
|
1001
|
+
* @param event - The event to write to the service
|
|
1002
|
+
* @param service - The service and it's id to write to the event to
|
|
1003
|
+
* @param options - Optional options to write the event
|
|
1004
|
+
*
|
|
1005
|
+
*/: "md" | "mdx";
|
|
989
1006
|
}) => Promise<void>;
|
|
990
1007
|
/**
|
|
991
1008
|
* Remove an entity from EventCatalog (modeled on the standard POSIX rm utility)
|
package/dist/index.d.ts
CHANGED
|
@@ -135,12 +135,7 @@ declare const _default: (path: string) => {
|
|
|
135
135
|
*/
|
|
136
136
|
writeCommand: (command: Command, options?: {
|
|
137
137
|
path?: string;
|
|
138
|
-
override
|
|
139
|
-
* Remove an event by an Event id
|
|
140
|
-
*
|
|
141
|
-
* @param id - The id of the event you want to remove
|
|
142
|
-
*
|
|
143
|
-
*/: boolean;
|
|
138
|
+
override?: boolean;
|
|
144
139
|
versionExistingContent?: boolean;
|
|
145
140
|
format?: "md" | "mdx";
|
|
146
141
|
}) => Promise<void>;
|
|
@@ -566,6 +561,26 @@ declare const _default: (path: string) => {
|
|
|
566
561
|
id: string;
|
|
567
562
|
version: string;
|
|
568
563
|
}, version?: string) => Promise<void>;
|
|
564
|
+
/**
|
|
565
|
+
* Add a data store to a service by it's id.
|
|
566
|
+
*
|
|
567
|
+
* Optionally specify a version to add the data store to a specific version of the service.
|
|
568
|
+
*
|
|
569
|
+
* @example
|
|
570
|
+
* ```ts
|
|
571
|
+
* import utils from '@eventcatalog/utils';
|
|
572
|
+
*
|
|
573
|
+
* const { addDataStoreToService } = utils('/path/to/eventcatalog');
|
|
574
|
+
*
|
|
575
|
+
* // adds a new data store (orders-db) that the InventoryService will write to
|
|
576
|
+
* await addDataStoreToService('InventoryService', 'writesTo', { id: 'orders-db', version: '2.0.0' });
|
|
577
|
+
*
|
|
578
|
+
* ```
|
|
579
|
+
*/
|
|
580
|
+
addDataStoreToService: (id: string, operation: "writesTo" | "readsFrom", dataStore: {
|
|
581
|
+
id: string;
|
|
582
|
+
version: string;
|
|
583
|
+
}, version?: string) => Promise<void>;
|
|
569
584
|
/**
|
|
570
585
|
* Add a command to a service by it's id.
|
|
571
586
|
*
|
|
@@ -669,12 +684,7 @@ declare const _default: (path: string) => {
|
|
|
669
684
|
*
|
|
670
685
|
*/
|
|
671
686
|
writeDomain: (domain: Domain, options?: {
|
|
672
|
-
path
|
|
673
|
-
* Remove an event to EventCatalog (modeled on the standard POSIX rm utility)
|
|
674
|
-
*
|
|
675
|
-
* @param path - The path to your event, e.g. `/Inventory/InventoryAdjusted`
|
|
676
|
-
*
|
|
677
|
-
*/: string;
|
|
687
|
+
path?: string;
|
|
678
688
|
override?: boolean;
|
|
679
689
|
versionExistingContent?: boolean;
|
|
680
690
|
format?: "md" | "mdx";
|
|
@@ -985,7 +995,14 @@ declare const _default: (path: string) => {
|
|
|
985
995
|
path?: string;
|
|
986
996
|
override?: boolean;
|
|
987
997
|
versionExistingContent?: boolean;
|
|
988
|
-
format
|
|
998
|
+
format? /**
|
|
999
|
+
* Adds an event to a service in EventCatalog
|
|
1000
|
+
*
|
|
1001
|
+
* @param event - The event to write to the service
|
|
1002
|
+
* @param service - The service and it's id to write to the event to
|
|
1003
|
+
* @param options - Optional options to write the event
|
|
1004
|
+
*
|
|
1005
|
+
*/: "md" | "mdx";
|
|
989
1006
|
}) => Promise<void>;
|
|
990
1007
|
/**
|
|
991
1008
|
* Remove an entity from EventCatalog (modeled on the standard POSIX rm utility)
|
package/dist/index.js
CHANGED
|
@@ -605,6 +605,42 @@ var addEntityToService = (directory) => async (id, entity, version) => {
|
|
|
605
605
|
await rmServiceById(directory)(id, version);
|
|
606
606
|
await writeService(pathToResource)(service, { format: extension === ".md" ? "md" : "mdx" });
|
|
607
607
|
};
|
|
608
|
+
var addDataStoreToService = (directory) => async (id, operation, dataStore, version) => {
|
|
609
|
+
let service = await getService(directory)(id, version);
|
|
610
|
+
const servicePath = await getResourcePath(directory, id, version);
|
|
611
|
+
const extension = (0, import_node_path6.extname)(servicePath?.fullPath || "");
|
|
612
|
+
if (operation === "writesTo") {
|
|
613
|
+
if (service.writesTo === void 0) {
|
|
614
|
+
service.writesTo = [];
|
|
615
|
+
}
|
|
616
|
+
for (let i = 0; i < service.writesTo.length; i++) {
|
|
617
|
+
if (service.writesTo[i].id === dataStore.id && service.writesTo[i].version === dataStore.version) {
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
service.writesTo.push({ id: dataStore.id, version: dataStore.version });
|
|
622
|
+
} else if (operation === "readsFrom") {
|
|
623
|
+
if (service.readsFrom === void 0) {
|
|
624
|
+
service.readsFrom = [];
|
|
625
|
+
}
|
|
626
|
+
for (let i = 0; i < service.readsFrom.length; i++) {
|
|
627
|
+
if (service.readsFrom[i].id === dataStore.id && service.readsFrom[i].version === dataStore.version) {
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
service.readsFrom.push({ id: dataStore.id, version: dataStore.version });
|
|
632
|
+
} else {
|
|
633
|
+
throw new Error(`Operation ${operation} is invalid, only 'writesTo' and 'readsFrom' are supported`);
|
|
634
|
+
}
|
|
635
|
+
const existingResource = await findFileById(directory, id, version);
|
|
636
|
+
if (!existingResource) {
|
|
637
|
+
throw new Error(`Cannot find service ${id} in the catalog`);
|
|
638
|
+
}
|
|
639
|
+
const path5 = existingResource.split(/[\\/]+services/)[0];
|
|
640
|
+
const pathToResource = (0, import_node_path6.join)(path5, "services");
|
|
641
|
+
await rmServiceById(directory)(id, version);
|
|
642
|
+
await writeService(pathToResource)(service, { format: extension === ".md" ? "md" : "mdx" });
|
|
643
|
+
};
|
|
608
644
|
|
|
609
645
|
// src/domains.ts
|
|
610
646
|
var import_promises6 = __toESM(require("fs/promises"));
|
|
@@ -1607,6 +1643,23 @@ var index_default = (path5) => {
|
|
|
1607
1643
|
* ```
|
|
1608
1644
|
*/
|
|
1609
1645
|
addEventToService: addMessageToService((0, import_node_path17.join)(path5)),
|
|
1646
|
+
/**
|
|
1647
|
+
* Add a data store to a service by it's id.
|
|
1648
|
+
*
|
|
1649
|
+
* Optionally specify a version to add the data store to a specific version of the service.
|
|
1650
|
+
*
|
|
1651
|
+
* @example
|
|
1652
|
+
* ```ts
|
|
1653
|
+
* import utils from '@eventcatalog/utils';
|
|
1654
|
+
*
|
|
1655
|
+
* const { addDataStoreToService } = utils('/path/to/eventcatalog');
|
|
1656
|
+
*
|
|
1657
|
+
* // adds a new data store (orders-db) that the InventoryService will write to
|
|
1658
|
+
* await addDataStoreToService('InventoryService', 'writesTo', { id: 'orders-db', version: '2.0.0' });
|
|
1659
|
+
*
|
|
1660
|
+
* ```
|
|
1661
|
+
*/
|
|
1662
|
+
addDataStoreToService: addDataStoreToService((0, import_node_path17.join)(path5)),
|
|
1610
1663
|
/**
|
|
1611
1664
|
* Add a command to a service by it's id.
|
|
1612
1665
|
*
|